3

My adviser thinks that it is very important in scientific papers that people can understand tables / figures only by looking at them and their captions, without reading much around them. So abbreviations (introduced by \gls{bla}) should get spelled out the first time they appear in a caption - for any caption again.

Is that possible to get automatically?

MWE

document.tex

\documentclass[a4paper,9pt]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{glossaries}
\loadglsentries[main]{glossary}
\makeglossaries

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quam elit,
vestibulum nec facilisis at, condimentum id enim. Sed iaculis lacinia quam, vel
accumsan eros tempor in. Integer ipsum metus, accumsan sit amet commodo a,
egestas vitae sem. \Gls{SLP} Mauris ut orci ut dolor viverra convallis nec a
erat. Aenean consequat elit vel eros fermentum vestibulum id at ipsum. In vitae
orci mauris, et rhoncus odio. Pellentesque habitant morbi tristique senectus et
netus et malesuada fames ac turpis egestas.

\begin{figure}[h]
    \centering
    \includegraphics*[width=\linewidth, keepaspectratio]{YourImage.jpg} 
    \caption{adsfasdf \gls{SLP} adsfasdf.}
\end{figure}

Fusce libero nulla, euismod vel suscipit nec, elementum vel massa. Mauris ut
sapien sed neque dignissim sodales. Proin accumsan, lectus non gravida dapibus,
lorem leo tincidunt odio, in semper ligula libero bibendum lorem. Pellentesque
venenatis massa a neque porttitor congue. Maecenas ornare lacus ac orci mattis
a placerat sapien euismod. In sed eros enim, non interdum nisi. Curabitur quis
magna et tortor interdum pharetra. Donec sit amet turpis neque, quis congue
leo. Proin sit amet placerat dolor.
\end{document}

glossary.tex

%Term definitions
\newacronym{CUDA}{CUDA}{Compute Unified Device Architecture}
\newacronym{SLP}{SLP}{supervised layer-wise pretraining}

Compile it like this

DOKUMENT = document
make:
    pdflatex -shell-escape $(DOKUMENT).tex -interaction=batchmode -output-format=pdf # aux-files for makeindex / makeglossaries
    makeglossaries $(DOKUMENT)
    pdflatex -shell-escape $(DOKUMENT).tex -interaction=batchmode -output-format=pdf # include glossary

1 Answer 1

5

You can simply use \acrfull and its variants (\Acrfull, \ACRfull, etc.) instead of \gls and its variants (\Gls, \GLS, etc.) inside your captions.

This will always give the full format for your acronyms.

MWE

\documentclass[a4paper,9pt]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[demo]{graphicx}
\usepackage{glossaries}
\newacronym{CUDA}{CUDA}{Compute Unified Device Architecture}
\newacronym{SLP}{SLP}{supervised layer-wise pretraining}
\makeglossaries

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quam elit,
vestibulum nec facilisis at, condimentum id enim. Sed iaculis lacinia quam, vel
accumsan eros tempor in. Integer ipsum metus, accumsan sit amet commodo a,
egestas vitae sem. \Gls{SLP} Mauris ut orci ut dolor viverra convallis nec a
erat. Aenean consequat elit vel eros fermentum vestibulum id at ipsum. In vitae
orci mauris, et rhoncus odio. Pellentesque habitant morbi tristique senectus et
netus et malesuada fames ac turpis egestas.

\begin{figure}[h]
    \centering
    \includegraphics*[width=\linewidth, keepaspectratio]{YourImage.jpg}
    \caption{adsfasdf \acrfull{SLP} adsfasdf.}
\end{figure}

Fusce libero nulla, euismod vel suscipit nec, elementum vel massa. Mauris ut
sapien sed neque dignissim sodales. Proin accumsan, lectus non gravida dapibus,
lorem leo tincidunt odio, in semper ligula libero bibendum lorem. Pellentesque
venenatis massa a neque porttitor congue. Maecenas ornare lacus ac orci mattis
a placerat sapien euismod. In sed eros enim, non interdum nisi. Curabitur quis
magna et tortor interdum pharetra. Donec sit amet turpis neque, quis congue
leo. Proin sit amet placerat dolor.

\printglossaries
\end{document} 

Output (caption)

enter image description here

Otherwise, if you want to keep your \gls-like commands as they are, you can locally reset the first use flag inside every \caption.

To achieve that, Insert the following lines in your preamble

\let\oldcaption\caption
\renewcommand*\caption[2][]{%
\oldcaption[#1]{\glslocalresetall#2}%
}

MWE (the output is the same as above)

\documentclass[a4paper,9pt]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[demo]{graphicx}
\usepackage{glossaries}
\newacronym{CUDA}{CUDA}{Compute Unified Device Architecture}
\newacronym{SLP}{SLP}{supervised layer-wise pretraining}
\makeglossaries

\let\oldcaption\caption
\renewcommand*\caption[2][]{%
\oldcaption[#1]{\glslocalresetall#2}%
}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quam elit,
vestibulum nec facilisis at, condimentum id enim. Sed iaculis lacinia quam, vel
accumsan eros tempor in. Integer ipsum metus, accumsan sit amet commodo a,
egestas vitae sem. \Gls{SLP} Mauris ut orci ut dolor viverra convallis nec a
erat. Aenean consequat elit vel eros fermentum vestibulum id at ipsum. In vitae
orci mauris, et rhoncus odio. Pellentesque habitant morbi tristique senectus et
netus et malesuada fames ac turpis egestas.

\begin{figure}[h]
    \centering
    \includegraphics*[width=\linewidth, keepaspectratio]{YourImage.jpg}
    \caption{adsfasdf \gls{SLP} adsfasdf.}
\end{figure}

Fusce libero nulla, euismod vel suscipit nec, elementum vel massa. Mauris ut
sapien sed neque dignissim sodales. Proin accumsan, lectus non gravida dapibus,
lorem leo tincidunt odio, in semper ligula libero bibendum lorem. Pellentesque
venenatis massa a neque porttitor congue. Maecenas ornare lacus ac orci mattis
a placerat sapien euismod. In sed eros enim, non interdum nisi. Curabitur quis
magna et tortor interdum pharetra. Donec sit amet turpis neque, quis congue
leo. Proin sit amet placerat dolor.

\printglossaries
\end{document} 
2
  • What is the difference between \Acrfull, \ACRfull, etc.? Jan 30, 2015 at 12:47
  • 1
    @moose The same as \Gls, \GLS, etc. The former capitalises the first letter, the latter the whole entry. Jan 30, 2015 at 12:52

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.