0

I would like to dynamically copy the first sentence of my long caption into the short caption for generating the figure list. Whenever I make changes to the long caption, the short caption updates accordingly.

To be more precise, I'd like to some sort of setter-getter mechanism for all the captions of my figures.

\caption[text_A_getter]{text_A_setter. text_B.}

I could save textA to a file but find it difficult to maintain for a large number of figures simultaneously.

1 Answer 1

2

Not sure if this really is the best idea and that practical, but you could use a command and redefine it if needed:

enter image description here

\documentclass{article}
\newcommand{\firstsent}{}
\begin{document}

\listoffigures

\begin{figure}
\renewcommand{\firstsent}{This is the first sentence.}
\caption[\firstsent]{\firstsent{} And here comes the rest of the long caption.}
\end{figure}

\begin{figure}
\renewcommand{\firstsent}{This caption gets a different first sentence.}
\caption[\firstsent]{\firstsent{} Remaining text}
\end{figure}

\end{document}

You must log in to answer this question.

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