在数学导向的文档中,我使用glossaries
将大多数文内数学符号链接到文档前面的词汇表中的含义。使用不同的下标/上标实际上不会改变它们的含义,因此我重复使用该条目(同时也防止词汇表列表变得太长)。不同的符号有不同的默认下标,因此我使用该字段user1
来存储默认值,并使用了稍作修改的解决方案https://tex.stackexchange.com/a/229879/221009。
当我将一个\gls
调用嵌套在另一个调用的可选参数中时\gls
,出现以下编译错误xelatex
:
! TeX capacity exceeded, sorry [semantic nest size=500].
<recently read> {
l.37 $\gls{A}$ and $\gls{A}[x, \gls{B}]
$;
此编译错误是由此 MWE 生成的
\documentclass{article}
\usepackage{hyperref}
\usepackage{glossaries-extra}
\renewcommand{\glossarysection}[2][]{}
\glsnoexpandfields{}
\glspatchtabularx{}
\makeglossaries{}
\newcommand*{\glsarg}{} % default glossary argument
\defglsentryfmt{%
\let\orgglsarg\glsarg%
\ifdefempty\glsinsert%
{\glsfieldfetch{\glslabel}{useri}{\glsarg}}%
{%
\let\glsarg\glsinsert%
\let\glsinsert\relax%
}%
\glsgenentryfmt%
\let\glsarg\orgglsarg%
}
\newglossaryentry{A}{description={Some mathematical symbol}, name={\ensuremath{A_{i}}}, text={\ensuremath{A_{\glsarg}}}, user1={i}}
\newglossaryentry{B}{description={Another mathematical symbol}, name={\ensuremath{B_{i}}}, text={\ensuremath{B_{\glsarg}}}, user1={i}}
\begin{document}
\printglossary
\section{My text}
$\gls{A}$ and $\gls{A}[x, \gls{B}]$;
\end{document}
完整mwe.log
文件:
This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019/Debian) (preloaded format=xelatex 2021.7.14) 14 AUG 2021 13:51
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**mwe
(./mwe.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
)
\c@part=\count163
\c@section=\count164
\c@subsection=\count165
\c@subsubsection=\count166
\c@paragraph=\count167
\c@subparagraph=\count168
\c@figure=\count169
\c@table=\count170
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen134
)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2020/01/14 v7.00d Hypertext links for LaTeX
(/usr/share/texlive/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty
Package: ltxcmds 2019/12/15 v1.24 LaTeX kernel commands for general use (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2019/11/07 v1.0c TeX engine tests
)
(/usr/share/texlive/texmf-dist/tex/latex/pdftexcmds/pdftexcmds.sty
Package: pdftexcmds 2019/11/24 v0.31 Utility functions of pdfTeX for LuaTeX (HO
)
(/usr/share/texlive/texmf-dist/tex/generic/infwarerr/infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode not found.
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
(/usr/share/texlive/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty
Package: kvsetkeys 2019/12/15 v1.18 Key value parser (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty
Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/pdfescape/pdfescape.sty
Package: pdfescape 2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
)
(/usr/share/texlive/texmf-dist/tex/latex/hycolor/hycolor.sty
Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
)
(/usr/share/texlive/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty
Package: letltxmacro 2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
)
(/usr/share/texlive/texmf-dist/tex/latex/auxhook/auxhook.sty
Package: auxhook 2019-12-17 v1.6 Hooks for auxiliary files (HO)
)
(/usr/share/texlive/texmf-dist/tex/latex/kvoptions/kvoptions.sty
Package: kvoptions 2019/11/29 v3.13 Key value format for package options (HO)
)
\@linkdim=\dimen135
\Hy@linkcounter=\count171
\Hy@pagecounter=\count172
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2020/01/14 v7.00d Hyperref: PDFDocEncoding definition (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/intcalc/intcalc.sty
Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/etexcmds/etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
)
\Hy@SavedSpaceFactor=\count173
Package hyperref Info: Hyper figures OFF on input line 4547.
Package hyperref Info: Link nesting OFF on input line 4552.
Package hyperref Info: Hyper index ON on input line 4555.
Package hyperref Info: Plain pages OFF on input line 4562.
Package hyperref Info: Backreferencing OFF on input line 4567.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4800.
\c@Hy@tempcnt=\count174
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip16
Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 5159.
\XeTeXLinkMargin=\dimen136
(/usr/share/texlive/texmf-dist/tex/generic/bitset/bitset.sty
Package: bitset 2019/12/09 v1.3 Handle bit-vector datatype (HO)
(/usr/share/texlive/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty
Package: bigintcalc 2019/12/15 v1.5 Expandable calculations on big integers (HO
)
))
\Fld@menulength=\count175
\Field@Width=\dimen137
\Fld@charsize=\dimen138
Package hyperref Info: Hyper figures OFF on input line 6430.
Package hyperref Info: Link nesting OFF on input line 6435.
Package hyperref Info: Hyper index ON on input line 6438.
Package hyperref Info: backreferencing OFF on input line 6445.
Package hyperref Info: Link coloring OFF on input line 6450.
Package hyperref Info: Link coloring with OCG OFF on input line 6455.
Package hyperref Info: PDF/A mode OFF on input line 6460.
LaTeX Info: Redefining \ref on input line 6500.
LaTeX Info: Redefining \pageref on input line 6504.
(/usr/share/texlive/texmf-dist/tex/generic/atbegshi/atbegshi.sty
Package: atbegshi 2019/12/05 v1.19 At begin shipout hook (HO)
)
\Hy@abspage=\count176
\c@Item=\count177
\c@Hfootnote=\count178
)
Package hyperref Info: Driver (autodetected): hxetex.
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hxetex.def
File: hxetex.def 2020/01/14 v7.00d Hyperref driver for XeTeX
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/puenc.def
File: puenc.def 2020/01/14 v7.00d Hyperref: PDF Unicode definition (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/stringenc/stringenc.sty
Package: stringenc 2019/11/29 v1.12 Convert strings between diff. encodings (HO
)
)
\pdfm@box=\box45
\c@Hy@AnnotLevel=\count179
\HyField@AnnotCount=\count180
\Fld@listcount=\count181
\c@bookmark@seq@number=\count182
(/usr/share/texlive/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
Package: rerunfilecheck 2019/12/05 v1.9 Rerun checks for auxiliary files (HO)
(/usr/share/texlive/texmf-dist/tex/latex/atveryend/atveryend.sty
Package: atveryend 2019-12-11 v1.11 Hooks at the very end of document (HO)
Package atveryend Info: \enddocument detected (standard20110627).
)
(/usr/share/texlive/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty
Package: uniquecounter 2019/12/15 v1.4 Provide unlimited unique counter (HO)
)
Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2
86.
)
\Hy@SectionHShift=\skip49
)
(/usr/share/texlive/texmf-dist/tex/latex/glossaries-extra/glossaries-extra.sty
Package: glossaries-extra 2020/02/13 v1.42 (NLCT)
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex
\XKV@toks=\toks15
\XKV@tempa@toks=\toks16
)
\XKV@depth=\count183
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
(/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2019/09/21 v2.5h e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count184
)
(/usr/share/texlive/texmf-dist/tex/latex/glossaries/base/glossaries.sty
Package: glossaries 2020/02/13 v4.45 (NLCT)
(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty
Package: mfirstuc 2017/11/14 v2.06 (NLCT)
\@glsmfirst=\toks17
\@glsmrest=\toks18
)
(/usr/share/texlive/texmf-dist/tex/latex/textcase/textcase.sty
Package: textcase 2019/09/14 v1.00 Text only upper/lower case changing (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/xfor/xfor.sty
Package: xfor 2009/02/05 v1.05 (NLCT)
)
(/usr/share/texlive/texmf-dist/tex/latex/datatool/datatool-base.sty
Package: datatool-base 2019/09/27 v2.32 (NLCT)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2020/01/20 v2.17e AMS math features
\@mathmargin=\skip50
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks19
\ex@=\dimen139
))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen140
)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2016/03/08 v2.02 operator names
)
\inf@bad=\count185
LaTeX Info: Redefining \frac on input line 227.
\uproot@=\count186
\leftroot@=\count187
LaTeX Info: Redefining \overline on input line 389.
\classnum@=\count188
\DOTSCASE@=\count189
LaTeX Info: Redefining \ldots on input line 486.
LaTeX Info: Redefining \dots on input line 489.
LaTeX Info: Redefining \cdots on input line 610.
\Mathstrutbox@=\box46
\strutbox@=\box47
\big@size=\dimen141
LaTeX Font Info: Redeclaring font encoding OML on input line 733.
LaTeX Font Info: Redeclaring font encoding OMS on input line 734.
\macc@depth=\count190
\c@MaxMatrixCols=\count191
\dotsspace@=\muskip17
\c@parentequation=\count192
\dspbrk@lvl=\count193
\tag@help=\toks20
\row@=\count194
\column@=\count195
\maxfields@=\count196
\andhelp@=\toks21
\eqnshift@=\dimen142
\alignsep@=\dimen143
\tagshift@=\dimen144
\tagwidth@=\dimen145
\totwidth@=\dimen146
\lineht@=\dimen147
\@envbody=\toks22
\multlinegap=\skip51
\multlinetaggap=\skip52
\mathdisplay@stack=\toks23
LaTeX Info: Redefining \[ on input line 2859.
LaTeX Info: Redefining \] on input line 2860.
)
(/usr/share/texlive/texmf-dist/tex/latex/substr/substr.sty
Package: substr 2009/10/20 v1.2 Handle substrings
\c@su@anzahl=\count197
)
(/usr/share/texlive/texmf-dist/tex/latex/datatool/datatool-fp.sty
Package: datatool-fp 2019/09/27 v2.32 (NLCT)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp.sty
Package: fp 1995/04/02
`Fixed Point Package', Version 0.8, April 2, 1995 (C) Michael Mehlich
(/usr/share/texlive/texmf-dist/tex/latex/fp/defpattern.sty
Package: defpattern 1994/10/12
\actioncount=\count198
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-basic.sty
Package: fp-basic 1996/05/13
\FP@xs=\count199
\FP@xia=\count266
\FP@xib=\count267
\FP@xfa=\count268
\FP@xfb=\count269
\FP@rega=\count270
\FP@regb=\count271
\FP@regs=\count272
\FP@times=\count273
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-addons.sty
Package: fp-addons 1995/03/15
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-snap.sty
Package: fp-snap 1995/04/05
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-exp.sty
Package: fp-exp 1995/04/03
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-trigo.sty
Package: fp-trigo 1995/04/14
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-pas.sty
Package: fp-pas 1994/08/29
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-random.sty
Package: fp-random 1995/02/23
\FPseed=\count274
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-eqn.sty
Package: fp-eqn 1995/04/03
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-upn.sty
Package: fp-upn 1996/10/21
)
(/usr/share/texlive/texmf-dist/tex/latex/fp/fp-eval.sty
Package: fp-eval 1995/04/03
)))
\@dtl@toks=\toks24
\@dtl@tmpcount=\count275
\dtl@tmplength=\skip53
\dtl@sortresult=\count276
\@dtl@numgrpsepcount=\count277
\@dtl@datatype=\count278
\dtl@codeA=\count279
\dtl@codeB=\count280
\@dtl@foreach@level=\count281
)
(/usr/share/texlive/texmf-dist/tex/latex/glossaries/base/glossaries-compatible-
307.sty
Package: glossaries-compatible-307 2020/02/13 v4.45 (NLCT)
)
\gls@level=\count282
\@gls@tmpb=\toks25
\gls@tmplen=\skip54
\glskeylisttok=\toks26
\glslabeltok=\toks27
\glsshorttok=\toks28
\glslongtok=\toks29
(/usr/share/texlive/texmf-dist/tex/latex/glossaries/styles/glossary-hypernav.st
y
Package: glossary-hypernav 2020/02/13 v4.45 (NLCT)
) (/usr/share/texlive/texmf-dist/tex/latex/glossaries/styles/glossary-list.sty
Package: glossary-list 2020/02/13 v4.45 (NLCT)
\glslistdottedwidth=\skip55
) (/usr/share/texlive/texmf-dist/tex/latex/glossaries/styles/glossary-long.sty
Package: glossary-long 2020/02/13 v4.45 (NLCT)
(/usr/share/texlive/texmf-dist/tex/latex/tools/longtable.sty
Package: longtable 2020/01/07 v4.13 Multi-page Table package (DPC)
\LTleft=\skip56
\LTright=\skip57
\LTpre=\skip58
\LTpost=\skip59
\LTchunksize=\count283
\LTcapwidth=\dimen148
\LT@head=\box48
\LT@firsthead=\box49
\LT@foot=\box50
\LT@lastfoot=\box51
\LT@cols=\count284
\LT@rows=\count285
\c@LT@tables=\count286
\c@LT@chunks=\count287
\LT@p@ftn=\toks30
)
\glsdescwidth=\skip60
\glspagelistwidth=\skip61
)
(/usr/share/texlive/texmf-dist/tex/latex/glossaries/styles/glossary-super.sty
Package: glossary-super 2020/02/13 v4.45 (NLCT)
(/usr/share/texlive/texmf-dist/tex/latex/supertabular/supertabular.sty
Package: supertabular 2020/02/02 v4.1g the supertabular environment
\c@tracingst=\count288
\ST@wd=\dimen149
\ST@rightskip=\skip62
\ST@leftskip=\skip63
\ST@parfillskip=\skip64
\ST@pageleft=\dimen150
\ST@headht=\dimen151
\ST@tailht=\dimen152
\ST@pagesofar=\dimen153
\ST@pboxht=\dimen154
\ST@lineht=\dimen155
\ST@prevht=\dimen156
\ST@toadd=\dimen157
\ST@dimen=\dimen158
\ST@pbox=\box52
))
(/usr/share/texlive/texmf-dist/tex/latex/glossaries/styles/glossary-tree.sty
Package: glossary-tree 2020/02/13 v4.45 (NLCT)
\glstreeindent=\skip65
))
\glsxtrresourcecount=\count289
\@glsxtrnewgls@inner=\count290
\glsshortpltok=\toks31
\glslongpltok=\toks32
)
\glswrite=\write3
\glo@main@file=\write4
\openout4 = `mwe.glo'.
Package glossaries Info: Writing glossary file mwe.glo on input line 8.
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-xdvipdfmx.def
File: l3backend-xdvipdfmx.def 2020-02-03 L3 backend support: xdvipdfmx
\g__graphics_track_int=\count291
\l__pdf_internal_box=\box53
\g__pdf_backend_object_int=\count292
\g__pdf_backend_annotation_int=\count293
)
(./mwe.aux)
\openout1 = `mwe.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 26.
LaTeX Font Info: Trying to load font information for TS1+cmr on input line 2
6.
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd
File: ts1cmr.fd 2019/12/16 v2.5j Standard LaTeX font definitions
)
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for TU/lmr/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
LaTeX Font Info: Checking defaults for PU/pdf/m/n on input line 26.
LaTeX Font Info: ... okay on input line 26.
\AtBeginShipoutBox=\box54
Package hyperref Info: Link coloring OFF on input line 26.
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
Package: nameref 2019/09/16 v2.46 Cross-referencing by name of section
(/usr/share/texlive/texmf-dist/tex/latex/refcount/refcount.sty
Package: refcount 2019/12/15 v3.6 Data extraction from label references (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty
Package: gettitlestring 2019/12/15 v1.6 Cleanup title references (HO)
)
\c@section@level=\count294
)
LaTeX Info: Redefining \ref on input line 26.
LaTeX Info: Redefining \pageref on input line 26.
LaTeX Info: Redefining \nameref on input line 26.
(./mwe.out) (./mwe.out)
\@outlinefile=\write5
\openout5 = `mwe.out'.
Package hyperref Warning: Rerun to get /PageLabels entry.
No file mwe.gls.
Package glossaries-extra Warning: Glossary `main' is missing on input line 28.
Overfull \hbox (30.99pt too wide) in paragraph at lines 28--28
[]\TU/lmr/m/n/10 Add \TU/lmtt/m/n/10 automake \TU/lmr/m/n/10 to your package op
tion list when you load \TU/lmtt/m/n/10 glossaries-extra.sty\TU/lmr/m/n/10 .
[]
(/usr/share/texlive/texmf-dist/tex/generic/stringenc/se-ascii-print.def
File: se-ascii-print.def 2019/11/29 v1.12 stringenc: Printable ASCII characters
)
! TeX capacity exceeded, sorry [semantic nest size=500].
<recently read> {
l.30 $\gls{A}$ and $\gls{A}[x, \gls{B}]
$;
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
Here is how much of TeX's memory you used:
14056 strings out of 479819
218295 string characters out of 5895846
668191 words of memory out of 5000000
31001 multiletter control sequences out of 15000+600000
533192 words of font info for 32 fonts, out of 8000000 for 9000
1348 hyphenation exceptions out of 8191
1177i,500n,2343p,998b,20874s stack positions out of 30000i,500n,10000p,200000b,80000s
No pages of output.
发生了什么事(我思考某些递归出错了?),以及如何修复它?