每当我尝试mintinline
在源文件中使用该命令,然后使用 编译该文件时pdflatex
,都会出现错误。下面提供了显示错误的最小示例:
\documentclass{book}
\usepackage{minted}
\begin{document}
\mintinline{vala}{main}
\end{document}
当我运行pdflatex --shell-escape sample.tex
(其中sample.tex
)是我有此代码的文件的名称)时,我得到以下输出:
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014/Arch Linux) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
(./sample.tex
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 79 languages loaded.
(/usr/share/texmf-dist/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/bk10.clo))
(/usr/share/texmf-dist/tex/latex/minted/minted.sty
(/usr/share/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz)) (/usr/share/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/share/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/share/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/share/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/share/texmf-dist/tex/latex/float/float.sty)
(/usr/share/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/share/texmf-dist/tex/latex/tools/calc.sty)
(/usr/share/texmf-dist/tex/latex/ifplatform/ifplatform.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(/usr/share/texmf-dist/tex/generic/oberdiek/catchfile.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/etexcmds.sty)) (./sample.w18)) /usr/bin/pygmentize
(./sample.aux) (/usr/share/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (./sample.pyg)
! Undefined control sequence.
l.4 \mintinline
{vala}{main}
?
我这里遗漏了什么吗?
答案1
该\mintinline
命令由 的开发版本提供minted
,而不是当前 TeX 发行版中的命令。如果要使用它,请手动安装开发版本。
你也可以使用pythontex
:
\documentclass{book}
\usepackage{pythontex}
\begin{document}
Abc \pygment{vala}|main| def
\end{document}
这需要pythontex <filename>
在 LaTeX 运行之后运行(当有新的代码片段时)。