我已经安装了今天发布的 TeX Live 2016(感谢开发人员)。
现在我有以下 MWE:
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}{ruby}
class Foo
def init
pi = Math::PI
@var = "Pi is approx. #{pi}"
end
end
\end{minted}
\end{document}
运行时,pdflatex --shell-escape test.tex
它会遍历文件并按预期生成 PDF。使用 执行相同操作lualatex --shell-escape test.tex
会失败,并显示
This is LuaTeX, Version 0.95.0 (TeX Live 2016)
system commands enabled.
(./test.tex
LaTeX2e <2016/03/31>
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(/opt/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/opt/texlive/2016/texmf-dist/tex/latex/base/size10.clo))
(/opt/texlive/2016/texmf-dist/tex/latex/minted/minted.sty
(/opt/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(/opt/texlive/2016/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz)) (/opt/texlive/2016/texmf-dist/tex/latex/float/float.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/base/ifthen.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/tools/calc.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/ifplatform/ifplatform.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/luatex-loader.sty
(/opt/texlive/2016/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua)))
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/catchfile.sty)
uname -s > "test.w18"
! Package catchfile Error: File `test.w18' not found.
See the catchfile package documentation for explanation.
Type H <return> for immediate help.
...
l.93 \CatchFileDef\@tempa{\ip@file}{}
?
如上所述,这是新安装的 TeX Live 2016;我还检查了安装的 Pygmentize 版本,即 2.1.3(通过 pip 安装)。使用 TeX Live 2015 进行测试,但上述代码在 pdflatex 和 lualatex 上均能正常运行。
有人可以提示我如何修复此问题吗,或者这是 lualatex 或 minted(或任何其他包)中的错误,需要报告吗?
更新:使用minted
版本 2.2(2016-06-08),该包会shellesc
自动加载,正如@David Carlisle 和@egreg 在评论中提到的那样;因此,如果您安装了此版本,问题就不会再出现。
答案1
为了与 LuaTeX 0.90 下的 LuaLaTeX 兼容,几个使用的包\write18
需要更新;minted
其中包括。
但是,该shellesc
软件包提供了必要的解决方法:
\documentclass{article}
\usepackage{shellesc}
\usepackage{minted}
\begin{document}
\begin{minted}{ruby}
class Foo
def init
pi = Math::PI
@var = "Pi is approx. #{pi}"
end
end
\end{minted}
\end{document}
(感谢 ArTourter 对此的提及)。
这里有一组补丁,可以用 替换所有\immediate\write18
,这是\ShellEsc
一种更安全的方法,无需依赖于 的重新定义\write
。
这些补丁根本不需要 LuaLaTeX,因此代码适用于所有引擎。
\documentclass{article}
\usepackage{shellesc,xpatch}
\usepackage{minted}
\makeatletter
\xpatchcmd{\DeleteFile}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\DeleteFile}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\ProvideDirectory}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\TestAppExists}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\TestAppExists}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@checkstyle}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@checkstyle}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@checkstyle}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@checkstyle}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@pygmentize}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@pygmentize}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@pygmentize}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@pygmentize}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd{\minted@pygmentize}
{\immediate\write18}
{\ShellEscape}
{}{}
\makeatother
\begin{document}
\begin{minted}{ruby}
class Foo
def init
pi = Math::PI
@var = "Pi is approx. #{pi}"
end
end
\end{minted}
\end{document}
注意:我无法检查 Windows 上的补丁,因此在这种情况下它们可能不完整。
如果使用以下方法,则可以获得更短的代码regexpatch
:
\documentclass{article}
\usepackage{shellesc,regexpatch}
\usepackage{minted}
\makeatletter
\xpatchcmd*{\DeleteFile}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd*{\ProvideDirectory}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd*{\TestAppExists}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd*{\minted@checkstyle}
{\immediate\write18}
{\ShellEscape}
{}{}
\xpatchcmd*{\minted@pygmentize}
{\immediate\write18}
{\ShellEscape}
{}{}
\makeatother
\begin{document}
\begin{minted}{ruby}
class Foo
def init
pi = Math::PI
@var = "Pi is approx. #{pi}"
end
end
\end{minted}
\end{document}