16

In my figures I used some acronyms (i.e. embedded in the figures, not readable by LaTeX). I included all the acronyms in a file. LaTeX only printed the acronyms appeared in the text, and ignored other acronyms I included. How to make LaTeX print all the acronyms? Thanks!

Update: In addition, I don't want the pages where the acronyms appear to be shown. Because LaTeX could not read the acronyms in the figures, for those figure-embedded acronyms, there would be no page displayed next to them. It would appear inconsistent: some acronyms with pages next to them and some without. Therefore, I don't want the pages where the acronyms appear to be shown.

11
  • 2
    Use \glsaddall
    – user31729
    Apr 27, 2017 at 19:18
  • Use nonumberlist option to prevent the page list from showing or use \glsadd{label} next to \includegraphics for each acronym shown in the figure to include the page. Apr 27, 2017 at 19:22
  • 1
    Thanks, both! I used \glsaddallunusedand \printglossary[type=\acronymtype, nonumberlist]. Update: At first I used \glsaddall, but it didn' work. I don't know why. But now it seems both \glsaddall and \glsaddallunused could work.
    – fyang
    Apr 27, 2017 at 19:31
  • 3
    I'm voting to close this question as off-topic because this question was solved in the comments.
    – TeXnician
    Apr 27, 2017 at 19:47
  • 2
    @NicolaTalbot Seems your comment comment solved the problem. Would you like to write an answer? Apr 27, 2017 at 20:20

1 Answer 1

14

There are various methods. First is to use nonumberlist (either as a package option or in \printglossary) in combination with \glsaddall (which must be used after all acronyms have been defined).

For example:

\documentclass{article}

\usepackage{graphics}
\usepackage[acronym,nonumberlist]{glossaries}

\makeglossaries

\newacronym{ac1}{ac1}{acronym 1}
\newacronym{ac2}{ac2}{acronym 1}

\glsaddall

\begin{document}
\gls{ac1}.

\begin{figure}
\centering
\includegraphics{example-image}
\caption{A Figure}
\end{figure}

\printglossaries
\end{document}

This omits all page numbers and includes all entries.

The second method doesn't use nonumberlist or \glsaddall but instead uses \glsaddallunused. This command must go at the end of the document:

\documentclass{article}

\usepackage{graphics}
\usepackage[acronym]{glossaries}

\makeglossaries

\newacronym{ac1}{ac1}{acronym 1}
\newacronym{ac2}{ac2}{acronym 1}

\begin{document}
\gls{ac1}.

\begin{figure}
\centering
\includegraphics{example-image}
\caption{A Figure}
\end{figure}

\printglossaries

\glsaddallunused

\end{document}

This displays the page list for ac1 which has been used in the document, but not for ac2.

For the third method, let's suppose ac2 is displayed in the image. Instead of using \glsaddallused, you can index ac2 next to the image. Like this:

\documentclass{article}

\usepackage{graphics}
\usepackage[acronym]{glossaries}

\makeglossaries

\newacronym{ac1}{ac1}{acronym 1}
\newacronym{ac2}{ac2}{acronym 1}

\begin{document}
\gls{ac1}.

\begin{figure}
\centering
\includegraphics{example-image}\glsadd{ac2}
\caption{A Figure}
\end{figure}

\printglossaries

\end{document}

This doesn't display any text next to the image, but it does index ac2, which means that ac2 now appears in the acronym list with the page number on which the image appears.

4
  • This is not working on my side. How do you compile it?
    – guhur
    May 26, 2017 at 12:05
  • 1
    Well it does work with pdflatex > makeglossaries > pdflatex. Thanks
    – guhur
    May 26, 2017 at 12:08
  • 1
    For me it was: pdflatex > makeglossaries > pdflatex > pdflatex
    – winklerrr
    Mar 12, 2020 at 14:07
  • @Nicola Talbot using \glsaddallunused imports GCDGreatest Common Divisor. into my list of acronyms even though I haven't defined it. This must be some kind of bug as GCD is a basic example.. Any idea how to get rid of this? Have you experienced this also?
    – learnPyt
    Aug 15, 2021 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .