1 #ifndef GL_COMPILE_LATEX_HPP
2 #define GL_COMPILE_LATEX_HPP
14 void compileLatex(
const char *filename,
const char *arguments =
"")
16 std::cout <<
"Compiling latex..." << std::endl
17 <<
"If this fails because of permissions within the \"convert\" command, do the following:" << std::endl
18 <<
"In the files /etc/ImageMagick-6/policy.xml && /etc/ImageMagick-7/policy.xml" << std::endl
19 <<
"change the line containing" << std::endl
20 <<
"<policy domain=\"coder\" rights=\"none\" pattern=\"PDF\" />" << std::endl
22 <<
"<policy domain=\"coder\" rights=\"read\" pattern=\"PDF\" />" << std::endl;
24 std::string command =
"lualatex --interaction=nonstopmode ";
26 command += std::string(arguments);
27 command +=
" " + std::string(filename);
29 std::string file = std::string(filename);
30 std::size_t pos = file.find_last_of(
".");
32 std::string filename_without_extension = file.substr(0, pos);
34 std::string command2 =
"convert -density 500 " +
35 filename_without_extension +
".pdf -quality 100 " + filename_without_extension +
".png";
38 command +=
" > " + filename_without_extension +
"_latex_output.txt";
39 system(command.data());
40 system(command2.data());
42 std::cout <<
"Generated " << filename_without_extension <<
".png" << std::endl;
48 #endif // GL_COMPILE_LATEX_HPP
void compileLatex(const char *filename, const char *arguments="")
Invokes lualatex command to compile tex to pdf.
Definition: CompileLatex.hpp:14