I wanted to use a glossary for the first time. I choose to go with the glossaries
package and imported it with:
\usepackage[toc, acronym]{glossaries}
and later used the
\makeglossaries
command and wanted to print the acronyms short after the table of contents with:
\printglossary[type=acronymtype]
Therefore I created a file with all acronyms in it right before the print statement.
Then nothing was shown, in the glossary. So I went on, and used some entries in the document (text and headlines of sections).
My file structure is a main file with one included LaTeX document for every chapter. So I included the file the the acronyms in the main file and wanted to use them in the included LaTeX documents. The acronyms were imported before the LaTeX files.
But now I get the error message:
Glossary entry: '...' has not been defined
What I have checked: names of the files are correct.
Tested to include the acronym list also to in the files for the chapters.
Did a short web search. Does anyone have an idea where such an error might come from?
Update:
I found the error, why the document did not compile. I used \include
instead of \input
for importing the acronym file. Here is a minimal example:
main file:
% This file is public domain
% If you want to use arara, you need the following directives:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{book}
\usepackage[toc, acronym]{glossaries}
\makeglossaries
\newglossaryentry{apple}{name={apple},description={a fruit}}
\begin{document}
\input{acronyms.tex}
\author{my Name}
\title{Glossary Test}
\maketitle
\newpage
\tableofcontents
\newpage
\printglossary[type=\acronymtype]
\chapter{\acrlong{xml}}
\Gls{apple} or \gls{apple} or \glspl{apple}.
\end{document}
The imported file has following lines:
\newacronym{autosar}{AUTOSAR}{AUTomotive Open System ARchitecture}
\newacronym{xml}{XML}{Extensible Markup Language}
The problem that is left over is, that neither the used nor the unused acronyms are showing up in a glossary.
Attempts to solve the problem:
-
I normaly use
xelatex
as processor, but a change topdflatex
did not change anything. -
Also defining the acronmys in the main file did not change anything.
I hope, that is description may help to solve the problem.
Best Answer
First move
\input{acronyms}
to the preamble and delete the.glsdefs
file.If the document is called, say,
myDoc.tex
then the complete document can be built with¹:or
This shows the list of acronyms containing just the
xml
entry, because theautosar
entry hasn't been indexed in the document.The location list includes page 3 (after a rebuild) because
\acrlong{xml}
is in the table of contents (which is on page 3). To avoid that, use the optional argument of\chapter
with one of the non-indexing commands:Now only page 5 appears in the location list:
If you want the unused entries to also appear in the list (without an associated page number) add
\glsaddallunused
at the end of the document.Unfortunately, in this case
xml
has been indexed but it hasn't been marked as used (\gls
both indexes and marks an entry as used, but\acrlong
only indexes), soxml
's location list goes wrong (in this case it disappears, but in other cases you can end up with a spurious comma):If you add
\gls{xml}
anywhere in the document (before\glsaddallunused
), the problem will go away, otherwise you need to explicitly mark it as used:The default
main
glossary (containingapple
) doesn't appear in the document because\printglossary
has only been used withtype=\acronymtype
.I've added another entry
pear
but haven't used it in the document, but\glsaddallunused
automatically adds it, so the glossary looks like:You can limit
\glsaddallunused
to a particular sub-set of lists with the optional argument, which should be a comma-separated list of labels identifying the required glossaries:Here's an alternative method using the
glossaries-extra
extension package. This internally loadsglossaries
and automatically implements thetoc
andnopostdot
options. (Usepostdot
ornopostdot=false
to make the post-description full stop reappear.) The extension package also provides some commands specifically for use in chapter/section arguments, such as\glsfmtshort
and\glsfmtlong
.Outside of section headings, the short form is obtained with
\glsxtrshort
(not\acrshort
), the long form is obtained with\glsxtrlong
(not\acrlong
) and the full form (without reference to the first use) is obtained with\glsxtrfull
(not\acrfull
).If you don't want long (short) then change the abbreviation style to whatever form you will use most. For example, if you only want the short form except in the chapter heading then use the
short
style. This way you can use\gls
to ensure that the entry is marked as used:For a full list of available abbreviation styles, see sample-abbr-styles.pdf.
If you want all defined entries listed, without page numbers, in the order of definition, then you can omit
\makeglossaries
and\glsaddallunused
and replace\printglossary
with\printunsrtglossary
. (This option is only available withglossaries-extra
):The document build is now simplified to:
or
¹The very first instance requires a rerun of the above because the page numbers will be off due to the missing list of acronyms on the first run. This isn't a problem if the list is at the end of the document or if the page numbering is reset after the list. For example, if you use
\frontmatter
and\mainmatter
: