TeX Live 2015/MacPorts 2015_6 下的 \xdef 和 \fnsymbol 问题

TeX Live 2015/MacPorts 2015_6 下的 \xdef 和 \fnsymbol 问题

我正在使用期刊提供的 cls 文件(我无法修改)撰写论文。他们使用一些棘手的代码在表格下创建表格注释。问题是,这段代码在我的 MacPorts 版本的 TeX Live 下崩溃(而在同事的 Linux 机器上运行良好),并显示以下消息:

! TeX capacity exceeded, sorry [input stack size=5000].
\font@name ->
             \OMS/cmr/m/n/12

我尝试通过增加堆栈大小来修改 texmf.cnf,但这并不能解决问题。

我不太能理解原始代码,但经过一些逆向工程后,我能够编写一个 MWE:

\documentclass[a4paper,12pt]{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[pdftex,unicode]{hyperref}
\makeatletter

\newcounter{mycount}

\newcommand\thecounter{\fnsymbol{mycount}}%
\gdef\MyPrint{}

\def\MyAdd#1#2{%
  \g@addto@macro\MyPrint{
    \refstepcounter{mycount}%
    \xdef\@currentlabel{\thecounter}%
    \label{#1}%
    \thecounter #2
    }%  
}


\begin{document}
\MyAdd{l1}{Hello}
\MyAdd{l2}{World}

My\ref{l1} print\ref{l2}:
\MyPrint
\end{document}

如果我更换

\xdef\@currentlabel{\thecounter}%

\def\@currentlabel{\thecounter}%

一切正常,我甚至得到了正确的结果: 结果

解决这个问题的另一个方法是更换

\newcommand\thecounter{\fnsymbol{mycount}}%

\newcommand\thecounter{\arabic{mycount}}%

(或使用 \roman 或 \Roman)

以下是 pdflatex -version 的完整输出:

pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/MacPorts 2015_6)
kpathsea version 6.2.1
Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.18; using libpng 1.6.18
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with poppler version 0.37.0

这是一个错误还是我的 TeX Live 安装缺少某些东西?

UPD1. \listfiles 的输出:

 *File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size12.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
 fontenc.sty
  t2aenc.def    2005/09/27 v1.0i Cyrillic encoding definition file
  t2acmr.fd    2001/08/11 v1.0a Computer Modern Cyrillic font definitions
inputenc.sty    2015/03/17 v1.2c Input encoding file
    utf8.def    2014/09/29 v1.1m UTF-8 support for inputenc
   t1enc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  ot1enc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  omsenc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  t2aenc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
hyperref.sty    2012/11/06 v6.83m Hypertext links for LaTeX
hobsub-hyperref.sty    2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2012/05/28 v1.13 Construct package bundles (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable calculations with integers (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty    2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2012/04/08 v1.3 Expandable calculations on big integers (HO)
  bitset.sty    2011/01/30 v1.1 Handle bit-vector datatype (HO)
uniquecounter.sty    2011/01/30 v1.2 Provide unlimited unique counter (HO)
letltxmacro.sty    2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
 hopatch.sty    2012/05/28 v1.2 Wrapper for package hooks (HO)
xcolor-patch.sty    2011/01/30 xcolor patch
atveryend.sty    2011/06/30 v1.8 Hooks at the very end of document (HO)
atbegshi.sty    2011/10/05 v1.16 At begin shipout hook (HO)
refcount.sty    2011/10/16 v3.4 Data extraction from label references (HO)
 hycolor.sty    2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 auxhook.sty    2011/03/04 v1.3 Hooks for auxiliary files (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
  pd1enc.def    2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
   puenc.def    2012/11/06 v6.83m Hyperref: PDF Unicode definition (HO)
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
 hpdftex.def    2012/11/06 v6.83m Hyperref driver for pdfTeX
rerunfilecheck.sty    2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
 nameref.sty    2012/10/27 v2.43 Cross-referencing by name of section
gettitlestring.sty    2010/12/03 v1.4 Cleanup title references (HO)
    test.out
    test.out
  omscmr.fd    2014/09/29 v2.5h Standard LaTeX font definitions
 ***********

答案1

LaTeX 团队最近(2015 年初)将该fixltx2e软件包集成到内核中。在少数地方,这可能会引起问题,主要是人们依赖有问题的行为。在这里,该类依赖于扩展安全性\thecounter(或者更确切地说,依赖于代码来制作脚注符号),而它不应该这样做。代码应该是

\def\MyAdd#1#2{%
  \g@addto@macro\MyPrint{
    \refstepcounter{mycount}%
    \protected@xdef\@currentlabel{\thecounter}% Change here
    \label{#1}%
    \thecounter #2
    }%  
}

当然,对于固定类,您无法改变这一点。您可以做的是,通过添加以下代码来撤销内核更改:

\RequirePackage[2014/12/31]{latexrelease}

就在文档的开头( \documentclass)。这将撤消自 2014 年底以来对 LaTeX 的所有更改,因此您可以进行编译。

相关内容