printglossary
\cleardoublepage
如果我在文档末尾使用,则不起作用。
如果一切按预期进行后我添加一些文本\cleardoublepage
。我无法向自己解释原因。
如果我使用glossaries-extra
而不是glossaries
我得到这个错误信息,这描述了问题。为什么它取决于后面的文本\cleardoublepage
?:
希望有人可以帮忙。
梅威瑟:(使用 pdflatex 编译两次)——不起作用
\documentclass{scrreprt}
\usepackage{hyperref}
\usepackage[acronym,automake,nopostdot,toc]{glossaries}
%%\usepackage[acronym,automake,nopostdot,toc]{glossaries-extra}
\makeglossaries
\newglossaryentry{A}{type=\acronymtype, name={letter A},description={Long text}}
\begin{document}
First use of \gls{A}.
\newpage
\printglossary[type=\acronymtype]
\cleardoublepage
%some text
\end{document}
梅威瑟:(使用 pdflatex 编译两次)——确实有效
\documentclass{scrreprt}
\usepackage{hyperref}
\usepackage[acronym,automake,nopostdot,toc]{glossaries}
%%\usepackage[acronym,automake,nopostdot,toc]{glossaries-extra}
\makeglossaries
\newglossaryentry{A}{type=\acronymtype, name={letter A},description={Long text}}
\begin{document}
First use of \gls{A}.
\printglossary[type=\acronymtype]
\cleardoublepage
some text
\end{document}
答案1
看来,命令所做的延迟在\write18
文档末尾丢失了。glossaries.sty
\@gls@automake
我最初的想法是添加\immediate
,这可以在这个补丁中完成:
\documentclass{scrreprt}
\usepackage{hyperref}
\usepackage[acronym,automake,nopostdot,toc]{glossaries}
\makeatletter
\renewcommand*{\@gls@automake}[1]{%
\ifglossaryexists{#1}%
{%
\@closegls{#1}%
\ifdefstring{\glsorder}{letter}%
{\def\@gls@order{-l }}%
{\let\@gls@order\@empty}%
\immediate\write18{makeindex \@gls@order
-s \istfilename\space
-t \jobname.\csuse{@glotype@#1@log}
-o \jobname.\csuse{@glotype@#1@in}
\jobname.\csuse{@glotype@#1@out}}%
}%
{%
\GlossariesWarning{Can't make glossary `#1', it doesn't exist}%
}%
}
\makeatother
\makeglossaries
\newglossaryentry{A}{type=\acronymtype, name={letter
A},description={Long text}}
\begin{document}
First use of \gls{A}.
\printglossary[type=\acronymtype]
\cleardoublepage
\end{document}
不幸的是,这意味着\write18
在相关词汇表文件关闭之前强制进行调用,这意味着makeindex
失败:
This is makeindex, version 2.15 [TeX Live 2017] (kpathsea + Thai support).
Scanning style file ./test.ist.............................done (29 attributes redefined, 0 ignored).
Scanning input file test.glo...done (0 entries accepted, 0 rejected).
Nothing written in test.gls.
Transcript written in test.glg.
This is makeindex, version 2.15 [TeX Live 2017] (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.
我能想到的唯一解决办法就是在\null
后面加上\cleardoublepage
:
\documentclass{scrreprt}
\usepackage{hyperref}
\usepackage[acronym,automake,nopostdot,toc]{glossaries}
\makeglossaries
\newglossaryentry{A}{type=\acronymtype, name={letter
A},description={Long text}}
\begin{document}
First use of \gls{A}.
\printglossary[type=\acronymtype]
\cleardoublepage\null
\end{document}
这样会导致文档有三页,但第三页是空白的,但我猜这是您的意图(假设您\cleardoublepage
在文档末尾有)。