class LTX::Build
Ruby LaTeX builder
Public Class Methods
new(config)
click to toggle source
# File lib/ltx/build.rb, line 10 def initialize(config) @config = config @command = build_command end
Public Instance Methods
call()
click to toggle source
# File lib/ltx/build.rb, line 16 def call t1 = Time.now puts 'Compiling Latex Project...' puts @command.join(' ') FileUtils.mkdir_p @config.compile_dir # FileUtils.cp Dir.glob(File.join(@config.root,("*.bst"))), # @config.compile_dir Kernel.system(*@command) t = Time.now - t1 puts "Finished compiling in #{t} seconds" self end
view()
click to toggle source
# File lib/ltx/build.rb, line 29 def view puts 'Starting PDF Viewer...' puts view_command.join(' ') Kernel.system(*view_command) self end
Private Instance Methods
build_command()
click to toggle source
# File lib/ltx/build.rb, line 39 def build_command case @config.compiler when 'pdflatex' then pdflatex_command when 'latex' then latex_command when 'xelatex' then xelatex_command when 'lualatex' then lualatex_command else raise Error, "unknown compiler: #{compiler}" end end
latex_command()
click to toggle source
# File lib/ltx/build.rb, line 78 def latex_command latexmk_base_command.concat [ '-pdfdvi', '-e', "$latex='latex -synctex=1 -interaction=batchmode %O %S'", File.join(@config.compile_dir, @config.main) ] end
latexmk_base_command()
click to toggle source
# File lib/ltx/build.rb, line 58 def latexmk_base_command [ 'latexmk', '-cd', '-f', "-jobname=#{@config.title}", '-auxdir=' + @config.compile_dir, '-outdir=' + @config.compile_dir ] end
lualatex_command()
click to toggle source
# File lib/ltx/build.rb, line 96 def lualatex_command latexmk_base_command.concat [ '-pdf', '-e', "$pdflatex='lualatex -synctex=1 -interaction=batchmode %O %S'", File.join(@config.compile_dir, @config.main) ] end
pdflatex_command()
click to toggle source
# File lib/ltx/build.rb, line 69 def pdflatex_command latexmk_base_command.concat [ '-pdf', '-e', "$pdflatex='pdflatex -synctex=1 -interaction=batchmode %O %S'", File.join(@config.compile_dir, @config.main) ] end
view_command()
click to toggle source
# File lib/ltx/build.rb, line 50 def view_command [ 'evince', '--fullscreen', File.join(@config.compile_dir, "#{@config.title}.pdf") ] end
xelatex_command()
click to toggle source
# File lib/ltx/build.rb, line 87 def xelatex_command latexmk_base_command.concat [ '-xelatex', '-e', "$pdflatex='xelatex -synctex=1 -interaction=batchmode %O %S'", File.join(@config.compile_dir, @config.main) ] end