module Rake4LaTeX

AUX-File:

newglossary{label}{log}{out-ext}{in-ext}

newglossary{main}{glg}{gls}{glo} newglossary{ext}{TeX-extensions}{glsext_in}{glsext_out} istfilename{sample.ist}

Anschliessend makeindex rufen.

Statt ind/idx werden

verwendet.

Zusätzlich Index-file ist.

end

under/overfull:

Filesplit verbessern (testcase equal_log_analyse)

end

Constants

BUILD_RAKEFILE_OPTIONS

List of all options for Rake4LaTeX.build_rakefile

DEFAULT_SETTINGS

Define the main settings for the runner.

This values can be overwritten for each base file:

basefile = Rake4LaTeX::Basefile.set('filename')
basefile[:maxruns] =  1
basefile[:loglevel] =  Log4r::DEBUG
basefile[:program] =  :xelatex
basefile[:texerrors_allowed] =  true
Logger

With this creation we define the constants Log4r::DEBUG…

Programms

Definition of the programms and there call parameters.

There is a basic definition, you may redefine the values with your local definitions. You can define your local definition in a file ‘rake4latex.yaml’.

Each program is a Hash:

program:
  cmd: shell-cmd
  parameters:
    value: value as textstring
    name: name of the parameter
    value_key: key of the value, must be given to Rake4LaTeX.build_cmd
    optional: flag, if the parameter is optional.
    space_separated: between name and value is a space.

end

TASK_DESCRIPTION

Collect descriptions for tasks. See mk_taskdescriptions

TASK_DESCRIPTIONS
VERSION

Public Class Methods

build_cmd( programm, parameters = {}, task = nil ) click to toggle source

Build the command line to call a tool.

Bases is the configuration in Programms.

‘parameters’ contains the parameters for the call. The keys must fit to the settings in Rake4LaTeX::Programms .

end

# File lib/rake4latex/base.rb, line 146
def self.build_cmd( programm, parameters = {}, task = nil )
  
  if task #take the LaTeXRunner specific settings
    configuration = task.texrunner.programms[programm] 
  else  #take the global settings
    configuration = Programms[programm] 
  end
  if ! configuration
    Rake4LaTeX::Logger.fatal( "No configuration for #{programm.inspect}") if Rake4LaTeX::Logger.fatal?
    return false
  end
  
  cmd = configuration['cmd'].dup
  configuration['parameters'].each{ | parameter |
    cmd << " #{parameter['value']}" if parameter['value']
    if parameter['value_key']
      if parameters[parameter['value_key']]
        cmd << " "
        cmd << "#{parameter['name']}" if parameter['name']
        cmd << " " if parameter['space_separated']
        cmd << "#{parameters[parameter['value_key']]}"
      else
        if ! parameter['optional'] and Rake4LaTeX::Logger.error?
          Rake4LaTeX::Logger.error( "Parameter #{parameter['value_key'].inspect} missing to execute #{programm}") 
        end
      end
    end
  }#configuration['parameters']

  cmd
end
build_rakefile( filename, *options ) click to toggle source

Build a rakefile

Options:

  • :pdf - add rule to create a pdf

  • :dvi - add rule to create a dvi

  • :dependecies - Analyse dependecies and add them

  • :bib: Add bibliography-dependecies (1)

  • :gloss: Add gloss.sty-dependecies

  • :splitindex

  • :all - all options,

Remarks:

(1) The bibTeX-files are searched via kpsewhich. local files get a “./” in front of the name.

end

# File lib/rake4latex/analyse_texfile.rb, line 200
def self.build_rakefile( filename, *options )
  
  options.concat(BUILD_RAKEFILE_OPTIONS) if options.delete(:all )
  ( options - BUILD_RAKEFILE_OPTIONS ).each{|opt|
    Rake4LaTeX::Logger.warn("Undefined option #{opt} in Rake4LaTeX.build_rakefile")
  }
  basename = filename.ext()
  tex_name = filename.ext('tex')
  pdf_name = filename.ext('pdf')
  dvi_name = filename.ext('dvi')
  aux_name = filename.ext('aux')
  texfile = Rake4LaTeX::TeXfile.new(tex_name)
  #
  #Template for a basic rakefile
  #
  template = <<Template
=begin
Rakefile for LaTeX-project #{basename}

Generated by Rake4LaTeX.build_rakefile, #{Date.today}
Options: #{options.inspect}

=end
require 'rake4latex'

#Change default
#~ Rake4LaTeX::DEFAULT_SETTINGS[:texerrors_allowed] = true

#Needed for some actions without a previous TeX-call
task :basefile => '#{tex_name}'

Template

  template << <<Template
#
# Define Dependecies
#
Template

  template << "file '#{pdf_name}' => '#{tex_name}'\n" if options.include?(:pdf)
  template << "file '#{dvi_name}' => '#{tex_name}'\n" if options.include?(:dvi)
  if options.include?(:dependecies) 
    includes = texfile.includes(:uniq, :recursive)
    if ! includes.empty?
      template << <<Template
#{texfile.tree.to_yaml.gsub(/^/, "# ")}
dependecies = [ 
#{includes.map{|f| "  \"#{f}\",\n"}.join}]
Template
      template << "file '#{pdf_name}' => dependecies\n" if options.include?(:pdf)
      template << "file '#{dvi_name}' => dependecies\n" if options.include?(:dvi)
    end
  end #options.include?(:dependecies)

  if options.include?(:bib) and ! texfile.bibliography.empty?
    template << <<Template

=begin
bib-file dependecies
=end
Template
    template << "file '#{basename}.bbl' => #{texfile.bibliography.uniq.inspect}\n"
    template << "file '#{pdf_name}' => #{texfile.bibliography.uniq.inspect}\n" if options.include?(:pdf)
    template << "file '#{dvi_name}' => #{texfile.bibliography.uniq.inspect}\n" if options.include?(:dvi)
  end #options.include?(:bib)
  
  if options.include?(:gloss) and ! texfile.gloss.empty?
    template << <<Template

=begin
bib-file dependecies for gloss-style
=end
Template
    texfile.gloss.each{|glossar, bib|
      template << "# glossar #{glossar}\n"
      template << "file '#{basename}.#{glossar}.bbl' => #{bib.uniq.inspect}\n"
      template << "file '#{basename}.#{glossar}.bbl' => '#{aux_name}'\n"
      
      template << "file '#{pdf_name}' => #{bib.uniq.inspect}\n" if options.include?(:pdf)
      template << "file '#{dvi_name}' => #{bib.uniq.inspect}\n" if options.include?(:dvi)
    }
  end #options.include?(:bib)

  if options.include?(:splitindex) and ! texfile.splitindex.empty?
    template << <<Template

=begin
dependecies for splitindex
=end
Template
    texfile.splitindex.each{|splitindex, indexname|
      template << "# Index #{splitindex} #{indexname}\n"
      template << "file '#{basename}-#{splitindex}.ind' => '#{basename}-#{splitindex}.idx'\n"
      template << "file '#{pdf_name}' => '#{basename}-#{splitindex}.ind'\n" if options.include?(:pdf)
      template << "file '#{dvi_name}' => '#{basename}-#{splitindex}.ind'\n" if options.include?(:dvi)
    }
  end #options.include?(:bib)


  template << <<Template

#Force the compilation
task :touch => '#{tex_name}'

Template

  template << <<Template
=begin
Define the default tasks
=end
#~ task :default => :touch  #Force the first TeX-call
Template

  template << "task :default => '#{pdf_name}' #build the pdf\n" if options.include?(:pdf)
  template << "task :default => '#{dvi_name}' #build the dvi\n" if options.include?(:dvi)

  template << <<Template

=begin
Closing Tasks
=end
task :default => :statistic #Get an overview on errors and warnings
#~ task :default => :log_overview #Show log overview-file
#~ task :default => :log_overview_file #Build a log overview-file
task :default => :clean #delete helpfiles

Template

  template << <<Template
=begin
Make the rakefile self-executable
=end
if $0 == __FILE__
  app = Rake.application
  app[:default].invoke  #start default tasks
end
Template

  template
end
mk_taskdescriptions() click to toggle source

Define all descriptions for tasks.

This defines the descriptions:

rake basefile           # Set the basefile - needed for clean and statistic
rake clean[basename]    # Remove any temporary products
rake clobber            # Remove any generated file
rake log_archive        # Archive all log-files to zip-file
rake log_overview       # Show the log-overview
rake log_overview_file  # Build a log-overview file
rake pdfview            # Show compiled PDF in Reader
rake statistic          # Build a statistic for all TeX project
rake touch              # Touch - reset timestamp

end

# File lib/rake4latex/base.rb, line 133
def self.mk_taskdescriptions
  TASK_DESCRIPTIONS.each{|taskname, descr|
    Rake.application[taskname].comment = descr
  }
end