`minted`“兼容性”问题

`minted`“兼容性”问题

在我编译了一份新的复杂文档后,minted我认出了其中的以下一行:

for compatibility with earlier versionsfor compatibility with earlier versions

在这一点上,我不想给出 MWE,因为同样的问题也发生在minted.dtx(使用 TL17/pre 及其软件包进行编译)中。这在生成的 pdf 中(另见这里):

铸造兼容性

\listfiles仅针对协议的输出minted.dtx

 *File List*
  ltxdoc.cls    2017/03/13 v2.0v Standard LaTeX documentation class
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
     doc.sty    2016/02/15 v2.1g Standard LaTeX documentation package (FMi)
multicol.sty    2017/04/11 v1.8q multicolumn formatting (FMi)
inputenc.sty    2015/03/17 v1.2c Input encoding file
 fontenc.sty
   t1enc.def    2017/04/05 v2.0i Standard LaTeX file
   t1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
 lmodern.sty    2009/10/30 v1.6 Latin Modern Fonts
 dingbat.sty    2001/04/27 v1.00 Hands and other dingbats
microtype.sty    2016/05/14 v2.6a Micro-typographical refinements (RS)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
microtype-luatex.def    2016/05/14 v2.6a Definitions specific to luatex (RS)
luatexbase.sty    2015/10/04 v1.3 luatexbase interface to LuaTeX 
ctablestack.sty    2015/10/01 v1.0 Catcode table stable support
microtype.cfg    2016/05/14 v2.6a microtype main configuration file (RS)
  xcolor.sty    2016/05/11 v2.12 LaTeX color extensions (UK)
   color.cfg    2016/01/02 v1.6 sample color configuration
  luatex.def    2017/01/12 v0.01h Graphics/Color for luaTeX
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
  svgnam.def    2016/05/11 v2.12 Predefined colors according to SVG 1.1 (UK)
textcomp.sty    2017/04/05 v2.0i Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
  minted.sty    2016/10/31 v2.4.1 Yet another Pygments shim for LaTeX
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
 fvextra.sty    2016/09/02 v1.2.1 fvextra - extensions and patches for fancyvrb
  ifthen.sty    2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
etoolbox.sty    2017/01/02 v2.4 e-TeX tools for LaTeX (JAW)
fancyvrb.sty    2008/02/07
 upquote.sty    2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbati
m
  lineno.sty    2005/11/02 line numbers on paragraphs v4.41
  t1lmtt.fd    2009/10/30 v1.6 Font defs for Latin Modern
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
    calc.sty    2014/10/28 v4.3 Infix arithmetic (KKT,FJ)
shellesc.sty    2016/06/07 v0.02a unified shell escape interface for LaTeX
ifplatform.sty    2010/10/22 v0.4 Testing for the operating system
pdftexcmds.sty    2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO)
   ifpdf.sty    2017/03/15 v3.2 Provides the ifpdf switch
catchfile.sty    2016/05/16 v1.7 Catch the contents of a file (HO)
 xstring.sty    2013/10/13  v1.7c  String manipulations (C Tellechea)
  framed.sty    2011/10/22 v 0.96: framed or shaded text with page breaks
 environ.sty    2014/05/04 v0.3 A new way to define environments
trimspaces.sty    2009/09/17 v1.1 Trim spaces around a token list
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2017/04/14 v1.1b Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
hyperref.sty    2017/03/14 v6.85a Hypertext links for LaTeX
hobsub-hyperref.sty    2016/05/16 v1.14 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2016/05/16 v1.14 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2016/05/16 v1.14 Construct package bundles (HO)
  ifvtex.sty    2016/05/16 v1.6 Detect VTeX and its facilities (HO)
 intcalc.sty    2016/05/16 v1.2 Expandable calculations with integers (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
luatex-loader.sty    2016/05/16 v0.6 Lua module loader (HO)
pdfescape.sty    2016/05/16 v1.14 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2016/05/16 v1.4 Expandable calculations on big integers (HO)
  bitset.sty    2016/05/16 v1.2 Handle bit-vector datatype (HO)
uniquecounter.sty    2016/05/16 v1.3 Provide unlimited unique counter (HO)
letltxmacro.sty    2016/05/16 v1.5 Let assignment for LaTeX macros (HO)
 hopatch.sty    2016/05/16 v1.3 Wrapper for package hooks (HO)
xcolor-patch.sty    2016/05/16 xcolor patch
atveryend.sty    2016/05/16 v1.9 Hooks at the very end of document (HO)
atbegshi.sty    2016/06/09 v1.18 At begin shipout hook (HO)
refcount.sty    2016/05/16 v3.5 Data extraction from label references (HO)
 hycolor.sty    2016/05/16 v1.8 Color options for hyperref/bookmark (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 auxhook.sty    2016/05/16 v1.4 Hooks for auxiliary files (HO)
  pd1enc.def    2017/03/14 v6.85a Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
 hluatex.def    2017/03/14 v6.85a Hyperref driver for luaTeX
rerunfilecheck.sty    2016/05/16 v1.8 Rerun checks for auxiliary files (HO)
  ts1cmr.fd    2014/09/29 v2.5h Standard LaTeX font definitions
  mt-cmr.cfg    2013/05/19 v2.2 microtype config. file: Computer Modern Roman (R
S)
supp-pdf.mkii
epstopdf-base.sty    2016/05/15 v2.6 Base part for package epstopdf
  grfext.sty    2016/05/16 v1.2 Manage graphics extensions (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
 nameref.sty    2016/05/21 v2.44 Cross-referencing by name of section
gettitlestring.sty    2016/05/16 v1.5 Cleanup title references (HO)
  minted.out
  minted.out
  minted.dtx    2016/10/31 v2.4.1 Yet another Pygments shim for LaTeX
  t1lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
  ot1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
  omllmm.fd    2009/10/30 v1.6 Font defs for Latin Modern
 omslmsy.fd    2009/10/30 v1.6 Font defs for Latin Modern
 omxlmex.fd    2009/10/30 v1.6 Font defs for Latin Modern

有趣的是,我在dtx尝试编译的两个文件中都遇到了这个问题,但我无法构建会产生此错误的 MWE。有人知道这个错误是从哪里来的吗?

更新:正如 egreg 指出的那样,这是docpygstyle文件的问题。通过修改我的 pygstyle(vs就我而言),我只能实现这一点

for compatibility with earlier versions

被打印出来了。但是第二个来自哪里呢?

答案1

在此处输入图片描述

如果你本地重置 catcode,%那么 pygments 示例将按预期工作

例如,将第一个铸造的示例minted.dtx

 % \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out}

 % {\catcode`\%=14 \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out}}

在此处输入图片描述

答案2

运行该.dtx文件(通过调用pygmentize)会生成一些.pygstyle文件,这些文件最后包含:

% for compatibility with earlier versions
\def\PYGdefaultZat{@}
\def\PYGdefaultZlb{[}
\def\PYGdefaultZrb{]}
\makeatother

所发生的情况是,%由于我们正在.dtx按照doc约定编译文件,因此它被忽略了。

这些文件的开头应该有类似

\makeatletter
\chardef\PYGsaved@percentcatcode=\catcode`\%
\catcode`\%=14

最后,

\catcode`\%=\PYGsaved@percentcatcode
\makeatother

但这超出了我们的控制范围,因为这应该由pygmentize来完成latex.py

请注意,环境%内的字符minted或加载的文件\inputminted将会消失。

解决这个问题的另一种方法是删除

codes={\catcode`\%=9}

从设置\fvset并在建筑周围添加假防护装置:

% For example:
% \iffalse
%<*fake>
% \fi
\begin{VerbatimOut}[gobble=1]{minted.doc.out}
  \begin{minted}{<language>}
    <code>%
  \end{minted}
\end{VerbatimOut}
{\catcode`\%=14 \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out}}
% \iffalse
%</fake>
% \fi
% will highlight a piece of code in a chosen language.
% The appearance can be customized with a number of options and color schemes.

%(我在代码中添加了只是为了显示它会按预期出现。)

在此处输入图片描述

感谢大卫卡莱尔完成这个魔术的第二部分。

相关内容