4

The question is as asked. My intended use case for this would be to have something like minipage, but whose height can be set using glue, rather than only a dimen.

When the page is pretty easy to split up, I can just use \textheight to divide things, but sometimes there's extra text on the page, and what I really want to instruct TeX to do is just how to use the remaining space on the page, aside from the stuff I've already typed. I figure the way to do this is to put glue between boxes where content would've gone, and once the glue's been set, replace the glue with a box of the same dimensions.

5

Not directly but using etex you can measure where the glue went and make a box of the same size on the next run:

enter image description here

\documentclass{article}

\makeatletter
\def\zz#1{\pdfsavepos\write\@auxout{\gdef\string#1{\the\pdflastypos}}}
\makeatother

\begin{document}

\section{ZZZZ}

zzzz
\[z=z\]
zzz

\noindent\zz{\zzA}\begin{picture}(0,0)
\put(0,0){%
\fbox{\begin{minipage}[t]%
[\dimexpr\ifx\zzA\undefined\textheight\else
 \zzA sp - \zzB sp -2\fboxrule-2\fboxsep\fi\relax]%
{\dimexpr\textwidth-2\fboxrule-2\fboxsep\relax}
zzz zzz
\end{minipage}}}
\end{picture}
\vspace{\fill}

zz\zz{\zzB} zzzz 
\begin{itemize}
\item zzzz
\end{itemize}
\end{document}
  • I think I saw an answer like this somewhere else, and I kinda didn't like it. Is there a way to do this without two passes, and without writing the dimension to an output file? Like, perhaps I could save a box in a box register, set it's glue while it's still in the register, and then programatically manipulate the contents of the box later? – Beelzebielsk Dec 15 '18 at 9:50
  • @Beelzebielsk basically, no.:-) – David Carlisle Dec 15 '18 at 9:50
  • Well... shucks. I'm gonna hold out hope, though. Maybe another answer will come through. Who knows. I'm not sure how familiar you are with LuaTeX, but if you are, would it expose some functionality that could help me create a command to do this? – Beelzebielsk Dec 15 '18 at 9:52
  • @Beelzebielsk ah now luatex that's a rather different beast. In luatex you could hook in to the output routine and add the box into the middle of the box being shipped out rather than write the coordinates and add it next time. (although doing \(pdf)savepos version as here is likely to be easier.) – David Carlisle Dec 15 '18 at 9:55
  • In the arguments to your minipage, what is sp? Is that a unit of some kind? – Beelzebielsk Dec 15 '18 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.