How to get the height of lrbox

by Luman75   Last Updated May 22, 2020 22:23 PM

I need to know the height of lrbox before I will be using it in my code. For some reason, my code is getting me odd non-correct value.

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

\newsavebox{\jhbin}
\begin{lrbox}{\jhbin}
  \par\begin{tabular}{c}
    Jim Hef{}feron\\
    Many lines is\\ comming.
  \end{tabular}
\end{lrbox}    

\newlength{\heightofhw}
\settoheight{\heightofhw}{\hbox{\jhbin}}
Wrong Height = \the\heightofhw  

\usebox{\jhbin}

\end{document}

Any idea how to get it right?

enter image description here

Tags : boxes height


Answers 1


Why do you put the box in a \hbox?

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

\newsavebox{\jhbin}
\begin{lrbox}{\jhbin}
  \par\begin{tabular}{c}
    Jim Hef{}feron\\
    Many lines is\\ comming.
  \end{tabular}
\end{lrbox}    
\newlength{\heightofhw}
\heightofhw=\ht\jhbin
Height = \the\heightofhw  

\usebox{\jhbin}

\end{document}

enter image description here

Schrödinger's cat
Schrödinger's cat
May 22, 2020 22:16 PM

Related Questions


How can we change the height of a header box

Updated July 20, 2015 13:10 PM

Table cell overflow

Updated June 09, 2017 12:23 PM

How to know the height of the footnotes?

Updated February 27, 2019 01:23 AM