1

Using the optional argument for \caption it is possible to change the entry placed into a list of figures. The style I use in my thesis always has a "header" or "title" for a figure, i.e. a short part of the caption that I print in bold using textbf. This is in my case always the same as what I put into the optional argument of my captions:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{graphicx}

\begin{document}
\listoffigures
\newpage
\begin{figure}[h!]
\centering
\includegraphics{example-image-a}
\caption[The universe]{\textbf{The Universe}\\Some very long description of this image that should not be in the list of figures...}
\label{fig:universe}
\end{figure}

\end{document}

Now I have The universe both as the entry in the list of figures and as a bold line at the beginning of the caption. Is there any way to achieve this automatically though? It often happens that I accidentally change only one or the other, e.g. ending up with

\caption[Something new]{\textbf{The Universe}\\Some very long description of this image that should not be in the list of figures...}

Where now Something new != The Universe

1 Answer 1

3

Define a new command \captionx

\newcommand{\captionx}[2]{\caption[#1]{\textbf{#1}\\ #2}}

to be used as

\captionx{Something new!}{Some very long description of this image that should not be in the list of figures...}

a

b

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{graphicx}

\newcommand{\captionx}[2]{\caption[#1]{\textbf{#1}\\ #2}} % added <<<<<<<<<<<<<<<<

\begin{document}
    \listoffigures
    \newpage
    \begin{figure}[h!]
        \centering
        \includegraphics{example-image-a}
        \caption[The universe]{\textbf{The Universe}\\Some very long description of this image that should not be in the list of figures...}        
        \label{fig:universe}
    \end{figure}

    \begin{figure}[h!]
       \centering
       \includegraphics{example-image-b}
       \captionx{Something new!}{Some very long description of this image that should not be in the list of figures...} % <<<<<<<<<<<<<<
       \label{fig:new}
    \end{figure}
    
\end{document}
2
  • And here I was digging through the caption package's documentation trying to find a way to solve this with a package option or similar and didn't even think about just making it into a newcommand. Commented Apr 7, 2022 at 14:30
  • Thank you for your help :) Commented Apr 8, 2022 at 8:07

You must log in to answer this question.

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