Dear Latex Community,
due to the help of Ulrike in my question How to get long captions across pages I can now finally use extra long captions for my theses. Thanks again :-)
I am looking for an easy way to repeat the suggested lines of code without copy/past it over the whole document multiple times. That is how the code looks like if I do it once manually:
\begin{figure}[H]
\includegraphics{largeImage}
\end{figure}
\bigskip
\setbox0\vbox{\makeatletter
\let\caption@rule\relax
\captionof{figure}[short caption]{\kant[1-4]}
\global\skip1\lastskip\unskip
\global\setbox1\lastbox
}
\unvbox0
\setbox0\hbox{\unhbox1\unskip\unskip\unpenalty
\global\setbox1\lastbox}
\unvbox1
\vskip\skip1
Instead I tried to create my own command like \longcaptions wo wrap this from above like this:
\newcommand{\longcaption}[1]{
\bigskip
\setbox0\vbox{\makeatletter
\let\caption@rule\relax
\captionof{figure}[short caption]{#1}
\global\skip1\lastskip\unskip
\global\setbox1\lastbox
}
\unvbox0
\setbox0\hbox{\unhbox1\unskip\unskip\unpenalty
\global\setbox1\lastbox}
\unvbox1
\vskip\skip1
}
and use it like this now:
\begin{figure}[H]
\includegraphics{largeImage}
\end{figure}
\longcaption{long long text}
unfortunately that results in no caption but simply writes under the image:
rule@[short caption]long long text
So, there is no error during compilation but instead I just see the line above in the text under the image. Do you have an Idea what I am doing wrong here? I think I miss here to escape some signs. Searching the web does not give my proper answer on how to use \newcommand for more complex commands like that one above, maybe it is even impossible to wrap it up like this. If yes, does anyone know an alternative?
kind regards,
Stephan
\makeatletter
and\makeatother
. – egreg Nov 26 '17 at 14:44