我有一份文件很多需要写入文件的列表,我希望生成的列表文件位于文档主目录的子目录中。例如,如果我的主文档是project/main.tex
,我希望所有列表都进入目录project/generated
。
我似乎无法使用 tcolorbox 和 minted 来实现这一点。MWE:
\documentclass{article}
% \usepackage[outputdir=mweout]{minted}
\usepackage{tcolorbox}
\tcbuselibrary{minted,raster,skins,xparse}
\NewTCBListing{mylisting}{ O{} }{
listing only,
#1,
}
\begin{document}
\begin{mylisting}[listing file=mweout/listing]
\LaTeX is fun.
\end{mylisting}
\end{document}
使用 lualatex 和 MacTeX 2017,我得到:
$ mkdir mweout
$ lualatex --shell-escape mwe.tex 2>&1 </dev/null
This is LuaTeX, Version 1.0.4 (TeX Live 2017)
system commands enabled.
(./mwe.tex
LaTeX2e <2017-04-15>
[... snipping a bunch of files being loaded, I think...]
Library (tcolorbox): 'tcbminted.code.tex' version '4.10'
[... more snipping...]
/Users/dale/.vpy/default/bin/pygmentize
No file mwe.aux.
[... more snipping...]
(./_minted-mwe/default-pyg-prefix.pygstyle) (./_minted-mwe/default.pygstyle)Traceback (most recent call last):
File "<string>", line 1, in <module>
OSError: [Errno 2] No such file or directory: 'mwe.pyg'
Error: cannot read infile: [Errno 2] No such file or directory: 'mwe.pyg'
! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.
See the minted package documentation for explanation.
Type H <return> for immediate help.
...
l.18 \end{mylisting}
?
! Emergency stop.
...
l.18 \end{mylisting}
442 words of node memory still in use:
2 hlist, 1 rule, 3 dir, 7 attribute, 59 glue_spec, 7 attribute_list, 2 temp,
2 write, 1 pdf_colorstack nodes
avail lists: 2:20,3:4,4:2,7:2,8:1,9:2
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on mwe.log.
当然,如果你去掉mweout
,它就可以工作了。取消注释也没有用,我得到了类似的错误。listing file
\usepackage[outputdir=mweout]{minted}
我怎样才能将 tcblisting 输出中的列表放到子目录中并由 minted 格式化?
答案1
如果您查看mweout
目录,您将找到文件listing.tex
。它是您的列表临时保存的文件LaTeX
。.tex
扩展名是自动添加的。但是,minted 尝试在没有任何扩展名的情况下进行查找,mweout/listing
结果失败了。要使它正常工作,只需将任何扩展名添加到选项中listing file
。例如,以下代码可以正常工作:
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{minted,raster,skins,xparse}
\NewTCBListing{mylisting}{ O{} }{
listing only,
#1,
}
\begin{document}
\begin{mylisting}[listing file=mweout/listing.tex]
\LaTeX is fun.
\end{mylisting}
\end{document}