解决方案使用一个 tex 文件生成多个 PDF与 TeXLive 2015 兼容,但现在在 TeXLive 2016 中出现问题,至少在 OS X El Capitan 上是这样。
最小示例:
\documentclass{article}
\ifx\conditionmacro\undefined
\immediate\write18{%
lualatex --synctex=1 -interaction=nonstopmode -shell-escape --jobname="\jobname"
"\gdef\string\conditionmacro{1}\string\input\space\jobname"
}%
\expandafter\stop
\fi
\begin{document}
asdf
\end{document}
TeXLive 2015 的结果:
Running `LaTeX' on `mini' with ``lualatex --jobname=mini -file-line-error -shell-escape --synctex=1 -interaction=nonstopmode "\input" mini.tex''
This is LuaTeX, Version beta-0.80.0 (TeX Live 2015) (rev 5238)
\write18 enabled.
LaTeX2e <2016/03/31>
Babel <3.9q> and hyphenation patterns for 1 language(s) loaded.
(./mini.tex (/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/size10.clo))This is LuaTeX, Version beta-0.80.0 (TeX Live 2015) (rev 5238)
\write18 enabled.
LaTeX2e <2016/03/31>
Babel <3.9q> and hyphenation patterns for 1 language(s) loaded.
(./mini.tex (/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/size10.clo))
No file mini.aux.
[1{/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./mini.aux))
264 words of node memory still in use:
2 hlist, 1 vlist, 1 rule, 2 glue, 40 glue_spec, 1 write nodes
avail lists: 2:12,3:3,4:22,6:11,7:1,9:6
<</usr/local/texlive/2015/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on mini.pdf (1 page, 10762 bytes).
SyncTeX written on mini.synctex.gz.Transcript written on mini.log.
)
262 words of node memory still in use:
2 hlist, 1 vlist, 1 rule, 2 glue, 39 glue_spec, 2 write nodes
avail lists: 2:12,3:1,6:3,9:1
No pages of output.
Transcript written on mini.log.
TeX Output finished at Mon Jun 13 14:32:07
TeXLive 2016 成绩:
Running `LaTeX' on `mini' with ``lualatex --jobname=mini -file-line-error -shell-escape --synctex=1 -interaction=nonstopmode "\input" mini.tex''
This is LuaTeX, Version 0.95.0 (TeX Live 2016)
system commands enabled.
LaTeX2e <2016/03/31>
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(./mini.tex (/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size10.clo))
lualatex --synctex=1 -interaction=nonstopmode -shell-escape --jobname="mini" "\gdef \conditionmacro{1}\input mini"
)
347 words of node memory still in use:
2 hlist, 1 vlist, 1 rule, 6 glue, 40 glue_spec, 2 write nodes
avail lists: 2:12,3:1,4:1,5:2,7:1,9:1
warning (pdf backend): no pages of output.
Transcript written on mini.log.
TeX Output finished at Mon Jun 13 14:20:51
有什么提示关于如何在 TeXLive 2016 中运行它吗?
答案1
\write18
不再意味着在 luatex 中执行系统命令。
添加
\usepackage{shellesc}
重新启用它。
该软件包还将允许更清晰的语法
\ShellEscape{...}
代替
\write18{...}
或者由于您正在专门为 luatex 编写代码,因此您可以避免使用shellesc
并使用
\directlua{os.execute("\luaescapestring{...}")}
它可以在旧的或新的 luatex 中工作。