I'm writing my thesis using figures drawn with tikzDevice
, which I include with the following function:
\newcommand{\includetikz}[4]{
\begin{figure}[!h]
\centering
\begin{adjustbox}{width=\textwidth}
\input{#1#2.tikz}%
\end{adjustbox}
\caption{#3}
\label{#4}
\end{figure}
}
I now want to get short versions for the list of figures, which would simply be the first sentence of the whole caption.
I could rewrite the function using an additional argument in the function above:
\newcommand\slcaption[2]{\caption[#1]{#1. #2}}
However this would be a lot of adjustment given the number of figures. Is there a simple option to just split the argument 3 at the first dot inside the function?
I imagine something like (in pseudocode):
\caption[ str_split(#3, '.')[1] ]{#3}
Best Answer
Here I use
listofitems
to parse the caption at the first occurrence of a dot.
and provide that as the optional argument to\caption
.Without any packages: