我試圖使用從here找到的\ def \ variableName {variable}函數將變量從Python中的子進程傳遞到我的Latex腳本。如果我使用某些詞語作爲變量名稱,腳本不會運行,並且我得到這個'錯誤'(我說'錯誤',因爲它不是一個真正的錯誤,但程序只停留在這裏)。 Latex中的def錯誤
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (MiKTeX 2.9) entering extended mode LaTeX2e <2015/10/01> patch level 2 Babel <3.9n> and hyphenation patterns for 69 languages loaded. *
對於一些原因,這個工程:
subprocess.call('pdflatex "\def\city{'+sys.argv[1][(sys.argv[1].rfind(os.sep))+1:-4]+'} \ \def\collisions{'+str(accidentDistributionList[0])+'} \ \def\collisionsb{'+str(accidentDistributionList[1])+'} \ \input{Summary.tex}"', shell=True)
但這並不:
subprocess.call('pdflatex "\def\city{'+sys.argv[1][(sys.argv[1].rfind(os.sep))+1:-4]+'} \ \def\collisions{'+str(accidentDistributionList[0])+'} \ \def\nearmisses{'+str(accidentDistributionList[1])+'} \ \input{Summary.tex}"', shell=True)
想知道是否有人已經遇到這個問題,或者乳膠會只接受某些詞作爲變量名?