LaTeXML
LaTeXML copied to clipboard
\unvbox does not unbox the box
Couldn't let it sit until after the bank holidays for obvious reasons.
The implementation of the \un*box commands is wrong at https://github.com/brucemiller/LaTeXML/blob/13018504e00ba934bc067357c372b72951227494/lib/LaTeXML/Engine/TeX_Box.pool.ltxml#L586-L591
They should replace the boxes with their contexts, but $stuff->unlist is typically a one element list consisting of the <ltx:block> wrapper. The difference is visible here:
\documentclass{article}
\newbox\mybox
\begin{document}
Vertical box below.
\setbox\mybox=\vbox spread 3cm{This box is 3cm high}\box\mybox
Another vertical box below, or is it?
\setbox\mybox=\vbox spread 3cm{This box should be 3cm high.}\unvbox\mybox
Was it 3cm?
\end{document}
The XML output may look the same (LaTeXML won't save the height), but the @vattach attribute is the visible symptom that the box has not been unwrapped.
A hasty workaround is to call $whatsit->getArg(2) instead of ->unlist, and to stick some kind of newline (\nointerlineskip?). A proper solution should at least involve some error checking (TeX throws an error when the box types are mismatched, e.g. \mybox=\hbox{}\unvbox\mybox) and some thinking about the type of newline required. I haven't checked the TeX book for the details.
(Raw beamer uses a lot of \unvbox and it creates nested blocks like there's no tomorrow. ->getArg(2) flattens the output nicely which suggests I am generally right.)