Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

If I have a minipage

\begin{minipage}{5cm}
content
\end{minipage}

How can I determine its height and save this value as a length?

share|improve this question
    
Welcome to TeX.sx! –  Peter Jansson Mar 3 '13 at 10:30
    
Also see tex.stackexchange.com/questions/3657/… –  Carlos Mar 3 '13 at 12:18
add comment

1 Answer

up vote 8 down vote accepted
\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.

share|improve this answer
    
Thanks, this seems to work. However, if I use a complicated content in the minipage (a large tikz image), I get a ! TeX capacity exceeded, sorry [input stack size=5000] error. –  Carlos Mar 3 '13 at 10:27
    
Yes, both versions fail due to the same error but the standalone minipage works. I use this code in a \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 3 '13 at 10:37
    
the newcommand there will add one extra input stack entry so you could try it without that. On the version that works what is the line in the log (about 8 lines from the end) file that looks like 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 3 '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 3 '13 at 11:03
    
your tikz code used up the entire save stack 5000 out of 5000 that means you are living on borrowed time, one more newcommand or input or a passing butterfly and your document will fail. Possibly you should ask a tikz specific question with an example and ask why it has eaten so much save stack. –  David Carlisle Mar 3 '13 at 11:32
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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