Top Level Namespace

Defined Under Namespace

Modules: Catch_output, RunTeX Classes: Frame_catch_output

Instance Method Summary collapse

Instance Method Details

#start_from_desktopObject

Analyse from ARGV when called from Desktop



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/runtex.rb', line 66

def start_from_desktop( )
  
options = {
  :format => 'pdflualatex',
  :overfull => 100, #report overfull boxes > this value

  :underfull => 9000, #report underfull boxes > this badness

}

optparser = OptionParser.new{ |opts|
  opts.banner = "runtex.rb: Translate a TeX-File.\n    This tool checks, how often the file must be translated to \n    create a document with correct references.\n    Usage:\n        runtex.rb [switches] source[.tex]\n    \n    Known Problems:\n    - Not tested on different systems (PS2PDF will work only on windows)\n    - The errors statistic count some errors twice \n    (or do you want to loose errors)\n    - index.sty is not supported. Use index2.sty instead \n    Detailed informations: http://ruby.lickert.net/runtex\n    \nSwitches:\n    -h <switch> for details of option <switch>\n"

  #~ opts.on('-h', '--help' ){ |selection|

      #~ puts opts.banner()

      #~ STDIN.getc if @@wait

      #~ exit 

  #~ }

  #~ opts.on('-H', '--HELP' ){ |selection|      

      #~ puts opt.help( '--HELP' )

      #~ STDIN.getc if @@wait

      #~ exit

  #~ }

      #~ puts "Option #{option}#{selection} not known\nUse -h for help"


  opts.on('-a', "--action ACTION", '--chain ACTION', %Q|Define the action chain
    A chain defines the steps from source to the target.
    - pdfLaTeX  
    - pdfLuaLaTeX [default]
    - XeLaTeX
    - LaTeX
    - LaTeXPS Call LaTeX and then create a 
        Postscript file (dvips)
    - LaTeXPSPDF  Call LaTeX and then create a PDF 
        via dvips and ghostscript
    -LaTeXPDF Call LaTeX and then create a PDF with dvipdfm
    remark: Each tool may define a "subchain"
      (pdf)LaTeX calls bibtex, makeindex, rail if necessary|.gsub(/^\t/, '')
    ){ |selection|      
      selection = '?' if ! selection.respond_to?( :downcase )
      case selection.downcase 
      when 'latex', 'pdflatex', 'pdflualatex', 'xelatex'
        options[:format] = selection.to_sym
      when 'latexps', 'latexpdf', 'latexpspdf'
        puts "Sorry, not supported yet"
      else
        puts "Action chain #{selection} not valid"
        STDIN.getc if $stdin.tty? 
        exit
      end #case selection

  }

  opts.on('-o', "--overfull OVERFULL",
    "Set the limit, from which overfull boxes are reported"
    ){ |selection|    
      options[:overfull] = selection.to_i   
  }

  opts.on('-u', "--underfull UNDERFULL", "Set the limit, from which underfull boxes are reported"){ |selection|
      options[:underfull] = selection.to_i  
  }
  
  #~ opts.on('-p', "--precompile PRE", %q|The given file(s) are precompiled.

    #~ Conversions of the precompiler:

    #~ - listings.sty:

      #~ \lstinputlisting[fromlabel=<label>,tolabel=<label>]{file} to 

      #~ \lstinputlisting[firstline=<num>,lastline=<num>] {file}

      #~ file must contain tags like "TeXlabel{label}"

  #~ |.gsub(/^\t/, '')){ |selection|

      #~ selection.each{|f|

        #~ Precompile.mix_references!( f )

        #~ }  

  #~ }

  }

  begin
    optparser.parse!
  #~ rescue OptionParser::MissingArgument => err

  #~ rescue OptionParser::InvalidOption => err

  rescue OptionParser::MissingArgument, OptionParser::InvalidOption => err
    puts "Error:\t#{err}"
    #Ausgabe der Schnittstelle

    puts optparser.banner
  end

  
  if ARGV.size == 0
    #Message if called by exe created with rubyscript2exe

    puts "Add file to translate or -h for help" if /app.rb/ =~ $0
  end
  ARGV.each{|arg|
    if arg =~ /\.(tex|dtx)$/
      job = RunTeX::Job_chain.new(arg, options)
    else
      job = RunTeX::Job_chain.new("#{arg}.tex", options)
    end
    job.log.level = Log4r::WARN
    job.start(options[:format])
  }

  if ARGV.empty?
    puts "No TeX-File given" 
    exit
  end
 
  puts "Thanks for using #{File.basename($0)}."
  STDIN.getc if $stdin.tty?

end