If I have a minipage
\begin{minipage}{5cm}
content
\end{minipage}
How can I determine its height and save this value as a length?
If I have a minipage
\begin{minipage}{5cm}
content
\end{minipage}
How can I determine its height and save this value as a length?
\newlength\foo
\settoheight\foo{\begin{minipage.....
If you also want to typeset the minipage you may want to save it in a box and instead say
\settoheight\foo{\usebox\mybox}
rather than typesetting it twice once just for measuring purposes.
! TeX capacity exceeded, sorry [input stack size=5000] error.
– Carlos
Mar 03 '13 at 10:27
\newcommand environment, so I have something like \newsavebox{\sb}\newcommand{\cmd}[1]{ \savebox{\b}{...minipage{#1}...}\settoheight{\foo}{\usebox{\sb}}\print{\usebox{\sb}} }.
– Carlos
Mar 03 '13 at 10:37
63i,9n,74p,723b,1727s stack positions out of 5000i,500n,10000p,200000b,50000s in particular what is the first number before i I suspect that you only just made it:-)
– David Carlisle
Mar 03 '13 at 10:55
5000i,10n,75p,552b,1292s stack positions out of 5000i,500n,10000p,200000b,50000s. Please excuse me blowing up this rather simple question, but there seems to be a problem with the whole \savebox formalism when I use it in a tikz node. Probably my problem is related to that.
– Carlos
Mar 03 '13 at 11:03
[b] option. Otherwise, the height comes out wrong.
– linguisticturn
Dec 02 '22 at 16:35
We can also directly use savebox. Note that if you're using this in a command you need to define the box outside of the command. MWE to follow:
\newbox\hintbox
\newcommand*{\cvcomment}[2][.25em]{
\sbox\hintbox{
\begin{minipage}{\hintscolumnwidth - \separatorcolumnwidth}
\raggedleft\hintstyle{#2}
\end{minipage}
}
\usebox\hintbox
\vspace{-1.7\ht\hintbox}
}
For context, I use this in modern-cv to leave a comment in the left column (the dates column), and that's where \hintscolumnwidth, \hintstyle, etc. come from.
In the above, I've defined the box hintbox outside of the command. I typeset a minipage inside hintbox, and display it using usebox. The whole point is that since I have it in a box, I can now measure its height \ht\hintbox and scale it appropriately to bring up content that comes after the use of the command such that the box doesn't take vertical space.