我正在編寫一個C++程序,它必須自動生成一些數據供學生在綜合練習中使用。我已經將這些數據導出到.tex文件,並且還希望C++程序能夠自動編譯這些tex文件。從C++程序編譯LaTeX文件
通常我會做編譯命令行TEX文件如下:
$ latex file.tex
$ latex file.tex
$ dvipdf file.dvi
於是,我在做我的C以下++代碼(目錄和文件名都是字符串):
//Move to the location where I created the files
string mycommand = "cd ";
mycommand += directory;
system(mycommand.c_str());
//Compile latex
mycommand = "latex " + filename + "_main.tex";
system(mycommand.c_str());
system(mycommand.c_str());
//Create .pdf
mycommand = "dvipdf " + filename + "_main.dvi";
system(mycommand.c_str());
然後產生的終端輸出的以下錯誤消息:
sh: latex: command not found
sh: latex: command not found
sh: dvipdf: command not found
我已經在網上搜索,但我沒有找到解決這個問題的方法,但我相信它很可能是非常簡單的。
我工作的OSX和安裝乳膠以下版本:
pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012)
kpathsea version 6.1.0
所有幫助是非常感謝!
夥計,'人2 chdir' ... –
你是什麼意思?我很抱歉,但對於像這樣的事情我很缺乏經驗...... –