I defined a new command \sectiontest{<text part>} to measure the height of a particular part of text in relation to the \textheight. If the height of the test part transcends half the textheight, it inserts a \newcolumn command to shift the following text to the next column, since it is used in a multicol* environment of an otherwise singlecolumned document. So far, it works fine with blindtext or even some other simple commands.
But now I tried to insert \listoffigures as argument to \sectiontest{} and it doesn't work.
Either the height of the listoffigures seems to be measured correctly, but the list itself isn't printed:
Or, if i put an expandafter in front (\sectiontest\expandafter{\listoffigures}), the list itself is printed, but the measuring mechanism isn't working, since there is no \newcolumn inserted, as it should be the case, if the measured section transcends half the \textheight:
I guess it has to do with the nested structure of my own commands, since there is a \testheight command – which does the actual measuring – inside the \sectiontest command. And they aren't expanded in the right way if a command like \listoffigures that needs more than one compilation run is used as argument.
I also tried a expl3 solution (which I generally would prefer) to get it right using \exp_args:Nc/x/... in combination with \cs_new:Nn/... together with \listoffigures commands, but had no success.
Expansion still is the most obscure part of Latex syntax to me – be it expl3 (which is a little bit clearer to me) or source2e.
Maybe someone else has a clue, how to get it working. This would be great.
Here is my MWE, with a whole bunch of test pictures to get a long lof ;)
\documentclass[%
]{article}
\usepackage[T1]{fontenc}
\usepackage{noto}
\ExplSyntaxOn
% tests if the height of the text part tested is bigger or smaller than textheight
\NewDocumentCommand{\columntest}{}{%
\int_compare:nNnTF {\int_to_arabic:n {\metaheight}} < {\int_to_arabic:n {\textheight/2}} {} {\newcolumn}
}
\NewDocumentCommand{\sectiontest}{m}{%
\testheight{#1}\par
\columntest
}
\ExplSyntaxOff
% command for measuring the height of a text part. The text part is the argument of the command
\newlength{\metaheight}
\newcommand{\testheight}[1]{%
\settoheight{\metaheight}{%
\parbox[b]{\linewidth}{\noindent#1}}%
#1\par%
}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage{multicol}
\usepackage[showframe]{geometry}
\setlength\parindent{0pt}
\begin{document}
\clearpage
\begin{multicols}{2}
\sectiontest\expandafter{\listoffigures}
\blindtext[3]
\end{multicols}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\begin{figure}
\includegraphics[width=.1\linewidth]{example-image}
\caption{Ziel ist es, innerafrikanische Beziehungen und Vernetzungen der letzten 6.000 Jahre}
\end{figure}
\end{document}
Edit
Maybe my approach to measure the height of a text part like \listoffigures or anything similar is completely wrong. Thus, I'm also open for completely different ideas how to accomplish my goals.



