# Can I disable underfull \hbox messages for a specific line?

The line \sbox{\mybox}{\parbox{2cm}{\lipsum[1]}} causes some of the above messages (59):

\documentclass{article}

\usepackage{lipsum}

\newsavebox{\mybox}

\begin{document}

\sbox{\mybox}{\parbox{2cm}{\lipsum[1]}}

\end{document}


Do I need to fix them? If not: is it possible disable these messages for that line?

• I don't think you should suppress them - it is valuable information. Perhaps your box contents should be {\raggedright\lipsum[1]} instead. – Andrew Swann Nov 12 '13 at 13:58
• @AndrewSwann Why is it useful if I don't have a \usebox? The effect is the same with \raggedright. – masu Nov 12 '13 at 14:00
• With \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. – Andrew Swann Nov 12 '13 at 14:03
• I don't know what you are trying to do, but you can use \hbadness=10000 before \sbox to avoid the warnings... – karlkoeller Nov 12 '13 at 14:09
• @AndrewSwann I wanted to use the height for calculations, as egreg said it in his answer – masu Nov 12 '13 at 17:16

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}


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.
• May I bother with another question? I don't think that opening a new question is the right way. Are there pitfalls in using \hbadness=10000 inside \resizebox? Can I lose anything useful there? I don't really see the point of an underfull \hbox message inside a resizebox. – masu Nov 12 '13 at 19:31
• @masu If you want to use the box, then messages are useful. If you only want to test whether it fits, then they are only distracting; but for the final setting I'd leave the normal value of \hbadness so as to know whether the typesetting is good or not. – egreg Nov 12 '13 at 20:20
• I use the resizebox without a savebox. But I couldn't figure out how can a warning be useful inside resizebox. Or is it the error of resizebox itself even if \hbadness=10000 is specified inside it? – masu Nov 12 '13 at 20:23