lib/cossincalc/triangle/formatter/latex.rb in cossincalc-1.0.5 vs lib/cossincalc/triangle/formatter/latex.rb in cossincalc-1.0.6

- old
+ new

@@ -29,11 +29,11 @@ # Saves the generated LaTeX to a TeX file and then converts it using pdflatex. # The filename should be provided without the .pdf extension. def save_pdf(filename) save_tex(filename) - `pdflatex -output-directory \"#{File.dirname(filename)}\" \"#{filename}.tex\"` + Dir.chdir(File.dirname(filename)) { `pdflatex "#{filename}.tex"` } end # Returns the content of the LaTeX document. def document_content(image_filename = nil) variable_table + "\\\\[0.2 cm]\n\n" + equations + "\n\n" + drawing(image_filename) @@ -95,10 +95,10 @@ # Saves the associated drawing and returns the embedding LaTeX code. # If no filename is given no image will be saved (can be used in testing). def drawing(filename = nil) CosSinCalc::Triangle::Drawing.new(f).save_png(filename) if filename - "\\begin{center}\n\\includegraphics[scale=0.4]{#{filename || 'placeholder'}}\n\\end{center}" + "\\begin{center}\n\\includegraphics[scale=0.4]{#{filename ? File.basename(filename) : 'placeholder'}}\n\\end{center}" end # Wraps the given LaTeX content into a LaTeX document ready to write to filesystem. def document(content) <<-EOT