TeX displays such warnings when the badness is above a threshold contained in the parameters \hbadness
and \vbadness
. You're interested in the first one:
\documentclass{article}
\usepackage{lipsum}
\newsavebox{\mybox}
\begin{document}
\sbox{\mybox}{\hbadness=10000 \parbox{2cm}{\lipsum[1]}}
\end{document}
Since the badness can never be above 10000, this effectively suppresses all Underfull \hbox
messages. There might still be Overfull \hbox
messages, which are suppressed by adding \hfuzz=\maxdimen
inside the \parbox
.
If the constructed box is used only for measuring it, these actions can be justified. Since the change to the parameters happens in a group, the values will automatically be restored at the end.
{\raggedright\lipsum[1]}
instead.\usebox
? The effect is the same with\raggedright
.\raggedright
I get not underfull messages. Can you tell us why would you want to save this material if you are not going to issue a\usebox
.\hbadness=10000
before\sbox
to avoid the warnings...