GeneralUnderfull \hbox (badness 10000) during compilation

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Underfull \hbox (badness 10000) during compilation

Post by Cham »

During compilation, I'm getting a few of these comments which I don't understand. Yet, everything compiles fine, and the output PDF appears to be perfect :
Underfull \hbox (badness 10000) in paragraph at lines 28--39
That looks terrible (badness !?) :?:

Here's the 20--39 code lines :

Code: Select all

Some simple text.

\medskip
\medskip

\noindent
\href{email}{name}

\noindent
\textit{City and year}
\\
\\
\\[48pt]
\begin{figure}[H]
	\centering
	\href{http://en.wikipedia.org/wiki/Spherical_cow}{
	\includegraphics[height=6cm]{Figures/vache.png}
	}
	\caption*{}
\end{figure}

Why the badness ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Underfull \hbox (badness 10000) during compilation

Post by Stefan Kottwitz »

That's the cause:

Code: Select all

\\
\\
\\[48pt]
You
  • end a line, but not the paragraph,
  • end a line again without beginning it at all,
  • still nothing at the line, end you end it again, adding 48 pt space. All in the same paragraph.
\\ is the LaTeX command for ending a line, such as within a tabular, an array, a matrix, or a multi-line math environment. It is not for faking a vertical space which a line would take, this would be \vspace{\baselineskip}. Users often make the mistake thinking it could be like a "\skipline". Even more bad, it's all in the same paragraph, since it doesn't end the paragraph, so paragraph-wide settings for line spread and justification apply.

This "Underfull \hbox" error comes because TeX thinks in boxes. And there was a box (line) which wasn't filled with anything.

A proper way would be not inserting space by hand, but to design the document so it would not be necessary. It's often too hard and a user would like to manually tweak the output, but then a \vspace command should be used. An own macro (with \vspace inside) is better than a specific value, for document wide adjustments at such places.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Underfull \hbox (badness 10000) during compilation

Post by Cham »

Hmmm, thanks a lot for the explanation, Stefan.

That page was done a few years ago, when I was starting with LaTeX. :oops:

That picture was just intended as a joke, at the end of that section.

What would you suggest to place a simple cartoon picture, at the end of the foreword ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Underfull \hbox (badness 10000) during compilation

Post by Cham »

I guess this is a proper way of doing this ?

Code: Select all

\noindent
\textit{City and year}

\vfill
\begin{figure}[H]
	\centering
	\href{http://en.wikipedia.org/wiki/Spherical_cow}{
	\includegraphics[height=6cm]{Figures/vache.png}
	}
	\caption*{}
\end{figure}
Is that right ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Underfull \hbox (badness 10000) during compilation

Post by Stefan Kottwitz »

Cham wrote:What would you suggest to place a simple cartoon picture, at the end of the foreword ?
It depends on how it should look like. Simpy \includegraphics, I think. No figure, since it should not float, and for sure there's no caption and no cross-reference to it. If it should be at the right, I would insert a \hfill before. If such a thing would happen several times, I would write a macro for it.

Actually, this is a new and different question and should be in a new topic. I will split it later here. You know, people come here via google looking for a solution for "Underfull \hbox", scroll down to the end with the solution - but read about pictures. No problem with talk here, and one thing brings another one, still we need some sorting.

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Underfull \hbox (badness 10000) during compilation

Post by Stefan Kottwitz »

Cham wrote:Is that right ?
You posted right at then I sent my previous answer, so now to the code. figure, \caption should be removed.

I would change it to

Code: Select all

\noindent
\emph{City and year}

\vfill
{\centering
\href{http://en.wikipedia.org/wiki/Spherical_cow}{%
  \includegraphics[height=6cm]{Figures/vache.png}}
\par}
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Underfull \hbox (badness 10000) during compilation

Post by Cham »

Ok, thanks. Everything's fine now. 8-)
Post Reply