This question may sound similar to what has been asked before, but I tried to do a minimalistic implementation (stealing some code from the verbatim package). Also I don't really know TeX, just basic LaTeX.
Anyway: I have implemented my own variant of subfigures and I use captions on the bottom. That code works well, but if I generate a list of figures, the subfigure captions are emitted before the main caption, like in:
1.2a Blabla
1.2b More blabla
1.2 Another caption
I want to reorder the entries by saving the subfigures' \addcontentsline
until the \addcontentsline
of the main figure was output. So I made some simplistic code that seems to work within one paragraph (lofLines
is the buffer for "list-of-figures lines"):
\newtoks\lofLines% storage
\def\lofLinesEmpty{\lofLines{}}% empty storage
\def\lofLinesAdd#1{\lofLines\expandafter{\the\lofLines#1}}% append to storage
\def\lofLinesOut{\expandafter{\the\lofLines}}% output storage
A short sample document (without the figure stuff) would be:
\documentclass[a4paper,twoside]{report}
\usepackage{german}
\usepackage[latin1]{inputenc}
\usepackage{a4}
% ...
\newtoks\lofLines% storage
\def\lofLinesEmpty{\lofLines{}}% empty storage
\def\lofLinesAdd#1{\lofLines\expandafter{\the\lofLines#1}}% append to storage
\def\lofLinesOut{\expandafter{\the\lofLines}}% output storage
\lofLinesEmpty% initialize
\begin{document}
\lofLinesEmpty%
\lofLinesAdd{aa\\bb}
Some text...
\lofLinesAdd{ccc}
More text
\lofLinesOut
\end{document}
This document outputs the text as:
Some text... More text aa
bbccc
So it works as intended (in my simple view of things), but when I want to save and restore actual \addcontentsline
s within some commands and environments I wrote for managing the figures, they are never written to the .lof
file.
To me it looks as if the contents got lost between commands, environments and floats, because not even simple plain text did survive the patch from subfigure caption to main text...
An example of such a line looks like this:
\lofLinesAdd{\addcontentsline{lof}{figure}{\protect%
\numberline{\thesubfigureX}{\ignorespaces{}#1}}}%
Most likely the problem is my limited understanding of TeX internals.