Module: Indoctrinatr::Tools::PdfGenerator
- Included in:
- Transactions::TemplatePackDefaultValuesCompiler, Transactions::TemplatePackDocumentation, Transactions::TemplatePackFieldnamesCreator
- Defined in:
- lib/indoctrinatr/tools/pdf_generator.rb
Instance Method Summary collapse
-
#latex_cleanup(working_directory) ⇒ Object
Cleans up LaTeX helper files in a specific directory.
-
#make_pdf(tex_file, output_dir = nil, cleanup: true) ⇒ Object
Compiles a PDF from a tex file with XeLaTeX.
Instance Method Details
#latex_cleanup(working_directory) ⇒ Object
Cleans up LaTeX helper files in a specific directory
25 26 27 28 29 30 31 32 33 |
# File 'lib/indoctrinatr/tools/pdf_generator.rb', line 25 def latex_cleanup(working_directory) # latexmk -c apparently cannot cleanup a specified subdirectory. So we have to change the working directory, # run the cleanup command in it and then change back to the directory that we were in. http://tex.stackexchange.com/q/301366/17834 current_dir = Dir.getwd Dir.chdir working_directory.to_s if working_directory latexmk_successful = system 'latexmk -c' Dir.chdir current_dir # should be the same as ../../.. # Dir.chdir '../../..' latexmk_successful end |
#make_pdf(tex_file, output_dir = nil, cleanup: true) ⇒ Object
Compiles a PDF from a tex file with XeLaTeX
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/indoctrinatr/tools/pdf_generator.rb', line 8 def make_pdf(tex_file, output_dir = nil, cleanup: true) args = ['-xelatex', '-shell-escape', '-interaction=batchmode', # more silent output "-output-directory=#{output_dir}", # without this xelatex tries to use the current working directory tex_file.to_s] if output_dir.nil? args.delete_at 3 # Remove argument if no output dir is wished for. This probably could be done better. end latexmk_successful = system('latexmk', *args) # latexmk instead of running 2.times latex_cleanup output_dir if latexmk_successful && cleanup latexmk_successful end |