glossaries uses
Code: Select all
\AtEndDocument{\@gls@doautomake}
Code: Select all
\newcommand*{\@gls@automake}[1]{%
\ifglossaryexists{#1}
{%
\@closegls{#1}%
\ifdefstring{\glsorder}{letter}%
{\def\@gls@order{-l }}%
{\let\@gls@order\@empty}%
\edef\@gls@dothiswrite{\noexpand\write18{makeindex \@gls@order
-s \istfilename\space
-t \jobname.\csuse{@glotype@#1@log}
-o \jobname.\csuse{@glotype@#1@in}
\jobname.\csuse{@glotype@#1@out}}%
}%
\@gls@dothiswrite
}%
{%
\GlossariesWarning{Can't make glossary `#1', it doesn't exist}%
}%
}
But \write is delayed until the next shipout. If TeX has nothing to shipout any more, the \write is never done and so the makeindex execution(s) are missing.
This happen, if someone has a \newpage or \clearpage at the very end of the document. Such \clearpage are sometimes the result of a \include or of the usage of a package. Because of this it would be better not to use \write18 but \immediate\write18 and much better to use \ShellEscape of package shellesc (because this works with luatex too). But to do so, it must be after the final \clearpage. Best solution for this would be to replace \AtEndDocument by \BeforeClosingMainAux or \AfterClosingMainAux (package scrlfile) or \AfterLastShipout (package atveryend).
MWE with the issue:
Code: Select all
\documentclass{article}
\usepackage[acronym,automake]{glossaries} % make a separate list of acronyms
\makeglossaries
\longnewglossaryentry{par}{name={par}}%
{%
A long description with a paragraph break.
This is the next paragraph.
}
\newglossaryentry{sample}{name={sample},
description={a sample entry}}
\setacronymstyle{long-short}
\newacronym[\glsshortpluralkey=cas,\glslongpluralkey=contrived
acronyms]{aca}{aca}{a contrived acronym}
\begin{document}
A \gls{sample} entry and \gls{aca}. Second use: \gls{aca}.
Plurals: \glspl{sample}. Reset acronym\glsreset{aca}.
First use: \glspl{aca}. Second use: \glspl{aca}.
\glsresetall
First letter upper case: \Gls{sample}. First use: \Gls{aca}.
Subsequent use: \Gls{aca}.
\glsresetall
Plurals: \Glspl{sample}. First use: \Glspl{aca}. Next: \Glspl{aca}.
If you want paragraph breaks in the description use
\verb|\longnewglossaryentry|, as with entry \gls{par}.
Title case a particular field:
\glslink{sample}{\glsentrytitlecase{sample}{desc}}.
\printglossaries
\clearpage
\end{document}
Code: Select all
\documentclass{article}
\usepackage[acronym,automake]{glossaries} % make a separate list of acronyms
\makeglossaries
\usepackage{scrlfile}
\usepackage{shellesc}
\makeatletter
% Deactivation of the \AtEndDocument{\@gls@doautomake}.
\let\orig@gls@doautomake\@gls@doautomake
\let\@gls@doautomake\relax
% Acitivation of \@gls@doautomake at the very end.
\BeforeClosingMainAux{\orig@gls@doautomake}% Do it after the last \clearpage.
% immediate actions
\renewcommand*{\@gls@automake}[1]{%
\ifglossaryexists{#1}
{%
\immediate\@closegls{#1}% CHANGED
\ifdefstring{\glsorder}{letter}%
{\def\@gls@order{-l }}%
{\let\@gls@order\@empty}%
\edef\@gls@dothiswrite{\noexpand\ShellEscape% CHANGED
{makeindex \@gls@order
-s \istfilename\space
-t \jobname.\csuse{@glotype@#1@log}
-o \jobname.\csuse{@glotype@#1@in}
\jobname.\csuse{@glotype@#1@out}}%
}%
\@gls@dothiswrite% CHANGED
}%
{%
\GlossariesWarning{Can't make glossary `#1', it doesn't exist}%
}%
}
\makeatother
\longnewglossaryentry{par}{name={par}}%
{%
A long description with a paragraph break.
This is the next paragraph.
}
\newglossaryentry{sample}{name={sample},
description={a sample entry}}
\setacronymstyle{long-short}
\newacronym[\glsshortpluralkey=cas,\glslongpluralkey=contrived
acronyms]{aca}{aca}{a contrived acronym}
\begin{document}
A \gls{sample} entry and \gls{aca}. Second use: \gls{aca}.
Plurals: \glspl{sample}. Reset acronym\glsreset{aca}.
First use: \glspl{aca}. Second use: \glspl{aca}.
\glsresetall
First letter upper case: \Gls{sample}. First use: \Gls{aca}.
Subsequent use: \Gls{aca}.
\glsresetall
Plurals: \Glspl{sample}. First use: \Glspl{aca}. Next: \Glspl{aca}.
If you want paragraph breaks in the description use
\verb|\longnewglossaryentry|, as with entry \gls{par}.
Title case a particular field:
\glslink{sample}{\glsentrytitlecase{sample}{desc}}.
\printglossaries
\clearpage
\end{document}