我有一个最新的 MikTex 发行版。大致如下制作词汇表时遇到问题,我在 test.tex 中有以下代码
\documentclass{article}
\usepackage{shellesc}
\usepackage[acronym,nomain,toc,automake]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short}
\loadglsentries{glosario}
\makeglossaries
\begin{document}
First use: \gls{CCTV}. Next use: \gls{CCTV}.
\printglossary[type=\acronymtype]
\end{document}
和包含 glosario.tex
\newacronym{CCTV}{CCTV}{Closed Circuit Television}
这与 一起使用有效pdflatex -shell-escape test.tex
,但是,当我使用 时lualatex -shell-escape test.tex
,找不到条目。这是输出
This is LuaTeX, Version 1.09.0 (MiKTeX 2.9.6930 64-bit)
system commands enabled.
(./test.tex
LaTeX2e <2018-12-01>
luaotfload | main : initialization completed in 1.454 seconds
("C:/Program Files/MiKTeX 2.9/tex/latex/base/article.cls"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
("C:/Program Files/MiKTeX 2.9/tex/latex/base/size10.clo"))
("C:/Program Files/MiKTeX 2.9/tex/latex/tools/shellesc.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries-extra/glossaries-extra.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/xkeyval/xkeyval.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/xkeyval/xkeyval.tex"
("C:/Program Files/MiKTeX 2.9/tex/generic/xkeyval/xkvutils.tex"
("C:/Program Files/MiKTeX 2.9/tex/generic/xkeyval/keyval.tex"))))
("C:/Program Files/MiKTeX 2.9/tex/latex/etoolbox/etoolbox.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries/base/glossaries.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/base/ifthen.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/mfirstuc/mfirstuc.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/textcase/textcase.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/xfor/xfor.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/datatool/datatool-base.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/amsmath/amsmath.sty"
For additional information on amsmath, use the `?' option.
("C:/Program Files/MiKTeX 2.9/tex/latex/amsmath/amstext.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/amsmath/amsgen.sty"))
("C:/Program Files/MiKTeX 2.9/tex/latex/amsmath/amsbsy.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/amsmath/amsopn.sty"))
("C:/Program Files/MiKTeX 2.9/tex/latex/substr/substr.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/datatool/datatool-fp.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp.sty"
`Fixed Point Package', Version 0.8, April 2, 1995 (C) Michael Mehlich
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/defpattern.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-basic.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-addons.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-snap.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-exp.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-trigo.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-pas.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-random.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-eqn.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-upn.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/fp/fp-eval.sty"))))
("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries/base/glossaries-compatible-3
07.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries/styles/glossary-hypernav.sty
") ("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries/styles/glossary-list.sty"
) ("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries/styles/glossary-long.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/tools/longtable.sty"))
("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries/styles/glossary-super.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/supertabular/supertabular.sty"))
("C:/Program Files/MiKTeX 2.9/tex/latex/glossaries/styles/glossary-tree.sty")))
(./glosario.tex) (./test.aux) (./test.acr)This is makeindex, version 2.15 [MiKTeX 2.9.6930 64-bit] (kpathsea + Thai support).
Scanning style file ./test.ist.............................done (29 attributes redefined, 0 ignored).
Scanning input file test.acn...done (0 entries accepted, 0 rejected).
Nothing written in test.acr.
Transcript written in test.alg.
我是不是遗漏了什么或者这是一个错误?
答案1
在这种情况下,您需要使用automake=immediate
。(2019-01-06 版 4.22 新增功能glossaries
。)这将在开始时\makeglossaries
(在打开词汇表文件之前)使用执行系统命令\immediate
。当文件不存在时,您会在第一次运行 LaTeX 时收到警告。
使用automake=true
(或简称automake
),系统命令在文档末尾执行,但\immediate
在这种情况下不能使用。与索引不同,词汇表可能出现在文档的开头而不是结尾,并且可能存在诸如\gls
最后一页的命令。这些命令执行的索引无法使用\immediate
,因为由于 TeX 的异步输出例程,它可能会导致相关页码出现问题。如果在这种情况下\write18
使用 调用\immediate
,则有可能在词汇表文件完成之前调用系统命令。
答案2
问题是 luatex(和 shellesc 包)\write18
实际上是\immediate\write18
(参见 shellesc 的文档)。这意味着 makeindex 命令被执行前acn 文件已写入并关闭。我认为这是词汇表中的一个错误,应该报告。
您可以像这样修补命令:
\documentclass{article}
\usepackage{shellesc}
\usepackage[acronym,nomain,toc,automake]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short}
\loadglsentries{glosario}
\makeglossaries
\usepackage{etoolbox}
\makeatletter
\patchcmd\@gls@automake{\write18}{\DelayedShellEscape}{}{\fail}
\makeatother
\begin{document}
\First use: \gls{CCTV}. Next use: \gls{CCTV}.
\printglossary[type=\acronymtype]
\end{document}
这也适用于 pdflatex。您不需要 --shell-escape 选项,makeindex 位于安全应用程序列表中。