TeX Live 2016:minted 不適用於 LuaLaTeX(2016 年 6 月修正了錯誤)

TeX Live 2016:minted 不適用於 LuaLaTeX(2016 年 6 月修正了錯誤)

我已經安裝了今天發布的 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 (或任何其他套件)中的錯誤?

更新:minted2.2 版(2016-06-08)中,包會shellesc自動載入包,正如 @David Carlisle 和 @egreg 在評論中提到的;因此,如果您安裝了此版本,該問題就不會再出現。

答案1

\write18在 LuaTeX 0.90 下,需要更新幾個使用的軟體包以相容於 LuaLaTeX;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}

相關內容