8

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.

  • 2
    Use \glsaddall – user31729 Apr 27 '17 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. – Nicola Talbot Apr 27 '17 at 19:22
  • 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 '17 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 '17 at 19:47
  • 2
    @NicolaTalbot Seems your comment comment solved the problem. Would you like to write an answer? – user36296 Apr 27 '17 at 20:20
7

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.

  • This is not working on my side. How do you compile it? – guhur May 26 '17 at 12:05
  • Well it does work with pdflatex > makeglossaries > pdflatex. Thanks – guhur May 26 '17 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.