0

I am typesetting a document with 2 columns of different width. I decided to use two minipages with the corresponding width, but every time a word gets hyphenated LaTeX gives me a warning for a badbox. Does someone knows how to get rid of that warning? It doesn't affect the visual output of the document, because it's right, but is annoying.

Here is a minimal example to get the error.

\documentclass{article}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth}
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}
  • Welcome. A warning is not an error. Two differet things. – Johannes_B Dec 10 '17 at 7:22
0

First of all, these are warnings and not errors. And so, you don't really have to get rid of them. It is ok to have some warnings like these. The reason latex gives these warnings it the really small width of the first minipage, that can not contain beautifully hyphenated words and obligates the program to leave huge gaps between words (if compared with their length).

In your text you mention that in second column you have the same problem (and my answer can not explain such a problem because second column is mush bigger). But if you really copy the text there and paste is some times to extend the paragraph, you will find out that you don't have such warnings there:

\documentclass{article}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth}
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want.   In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}

A solution for such problems, is to reduce the fontsize on the small column so that the length of the words will be smaller and the possibility of ugly gaps will be reduced. The next example (with \small command addition on first column) does not give such warnings and seems much more beautiful:

\documentclass{article}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth} \small
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want.   In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}

PS: You can make small the second column to if you want uniformity between the columns.

  • Yep, I know it is a Warning, but I was so stressed that i misspell. Anyway, thanks for the advise. – PillFall Dec 10 '17 at 15:21
  • Welcome... Some browsers doesn't even make it clear what is an error and what a warning... It is not such a mistake that you have to apologize for this... I just had to mention when answering... You are welcome... hope you will solve your problem – koleygr Dec 10 '17 at 15:24
1

The problem is not that words are hyphenated but that the hyphenation is not enough to avoid underfull boxes because the line width is too small.

An underfull box means that there is not enough content for a line resulting in too large spaces between the words.

If you use LaTeX (in contrast to XeLaTeX or LuaLaTeX) you can use the microtype package to improve spacing. As far as I know it manipulates the spaces between the single characters of each word.

\documentclass{article}

\usepackage{microtype}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth}
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}

enter image description here


While \usepackage[T1]{fontenc} has the positive effect of allowing hyphenation of words containing umlaute and copying umlaute from the resulting pdf, it also has negative effects:

  • font quality (it's somewhat pixelated and not as well readable)
  • ligatures can not be copied from resulting pdf
  • does not work with microtype

All of these negative effects can be neutralized with loading the lmodern package.

  • Ok, thanks for the advice, I keep it in mind – PillFall Dec 10 '17 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.