# 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?

Tags :

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}


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