The glossaries package uses external files (especially a .gls
file) to build the glossary, e.g. when building the following example. Is there a way to include the content of such a file directly into the TeX file? Then it would not be necessary to use makeglossaries
or to provide the .gls
file, e.g. when submitting the TeX file to a journal.
\documentclass{scrbook}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{eta}{name=\ensuremath{\eta},description={eta}}
\newglossaryentry{psi}{name=\ensuremath{\psi},description={psi}}
\begin{document}
\glsaddall
\printglossary
\end{document}
Directly adding the content of the file to the TeX file gives
! Undefined control sequence.
<argument> \glossarytitle
By the way: There is no need to update references or anything else. I just need the layout and the entries.
Best Answer
\printglossary
doesn't just input the glossary file but performs quite a bit of setup first, which is why you can't simply replace it with\input
.Basically, if you don't want to use an external application, then:
\printunsrtglossary
provided by theglossaries-extra
extension package.\makenoidxglossary
and\printnoidxglossary
(as mentioned by Christian).Example with the first approach:
This only requires a single
latex
call as no sorting is performed and there's no check to determine if the entry has been indexed. I've used thenogroupskip
as there are no logical letter groups in this case.The above method is different to using the
\makenoidxglossaries
and\printnoidxglossary
approach, which requires a second run to determine which entries have been indexed. Thenoidx
method (denoted option 1 in the manual) also tries to sort the entries alphabetically by default and will obtain the sort value from thename
key if thesort
key is omitted, but the maths markup (\ensuremath{\eta}
etc) causes a problem. Example using order of definition (instead of alphabetical ordering):It is actually possible to add letter groups and location lists with
\printunsrtglossary
but it has to be done manually:Both methods require all entries to be defined before the glossary. The second case requires all entries to be defined in the preamble. The first case may allow document definitions but only with the package option
docdefs=restricted
. In general it's best to put all document definitions in the preamble.