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.

I'd like to build a tabular and next to it a graphics in the same height.
I use the following code (for minimal working purposes, I used \rule) and do not understand, what is going wrong:

\documentclass{minimal}
\begin{document}
    \newsavebox{\testbox}%
    \newlength{\testheight}%
    \savebox{\testbox}{%
            \begin{tabular}{cr}%
                \multicolumn{2}{c}{\underline{\underline{\textsc{Line 1}}}}\\ \\
                Line&2\\%
                Line&3\\%
                Line&4\\%
            \end{tabular}%
        }%
        \settoheight{\testheight}{\usebox{\testbox}}
        \usebox{\testbox}\hfill\rule{3pt}{\the\testheight}\hfill\rule{3pt}{\the\testheight}
\end{document}

As \savebox if fragil, I also played around with the robust commands \mbox and/or \sbox - without success.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

By default tabular is vertically centred so the height is only (roughly) half what you need.

Depending what you want to do you could use

           \begin{tabular}[b]{cr}%

so the table is bottom aligned, or you could extract the height and the depth of the box.

share|improve this answer
    
This was really fast - thanks! –  Bastian Ebeling Aug 9 '12 at 8:53
add comment

May be you can try tabulatht from the Oberdiek-bundle. The tabularht package defines some environments that add a height specification to tabular and array environments.

share|improve this answer
    
Sounds interesting - I'll have a look at it. Thanks. –  Bastian Ebeling Aug 13 '12 at 6:15
add 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.