36

I'm coding a TeX file and although the .pdf is correctly rendered, I'm using "stone age" tools to code it. As some examples, I use \\ to leave a line space between two paragraphs, or \noindent in every paragraph I start. Basically, I'm just using the basic TeX data I have to code a paper, but I'm sure there are things that can be replaced with much better and appropriate codes, since I get badness 10000. This is the console:

*geometry* detected driver: pdftex
("C:\Archivos de programa\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd")
("C:\Archivos de programa\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd")
Underfull \hbox (badness 10000) in paragraph at lines 10--11
[1{C:/Documents and Settings/All Users/Datos de programa/MiKTeX/2.9/pdftex/conf
ig/pdftex.map}]
Overfull \hbox (10.8009pt too wide) detected at line 49
\OML/cmm/m/it/14.4  [] \OT1/cmr/m/n/14.4 + 1 = [] [] \OML/cmm/m/it/14.4 x \OT1
/cmr/m/n/14.4 + [] [] \OML/cmm/m/it/14.4 x
[2]
Overfull \hbox (26.66542pt too wide) in alignment at lines 80--82
 [][][] []
[3]
Overfull \hbox (23.60692pt too wide) detected at line 90
\OML/cmm/m/it/14.4  [] \OMS/cmsy/m/n/14.4 ><C:/Archivos de programa/MiKTeX 2
.9/fonts/type1/public/amsfonts/symbols/msbm10.pfb>

How could I clean up these errors, which I'm guessing are basic?

1
  • Given log shows that overful boxes occured in math equations. Check your equations and use multline environment from amsmath package to typeset long eqs. amsmath also has many other environments for math materials. Commented Apr 13, 2012 at 6:02

1 Answer 1

61

Never use \\ to add space between paragraphs. This simple code:

\documentclass{article}

\begin{document}

text\\    
text
\end{document}

produces the message

Underfull \hbox (badness 10000) in paragraph at lines 5--6

Besides clogging the console output and the .log file with warnings, using \\\par has real undesired effects when a page break occurs just after using this combination, as can be seeing using the following simple example:

\documentclass{article}
\usepackage{showframe}% just for the example

\begin{document}

\vspace*{44\baselineskip}
test text\\

test text

\end{document}

An image of the top of the second page:

enter image description here

The second page contains a spurious blank line at the beginning and this certainly makes the layout ugly and inconsistent (Thanks to David Carlisle which mentioned this problem).

If you want to suppress indentation and increase the vertical separation between paragraphs, you have, at least, three options:

  1. Set \parindent to 0pt (to suppress indentation) and use \smallskip, \medskip or \bigskip to increase the vertical skip between paragraphs; an example:

    \documentclass{article}
    \usepackage[nopar]{lipsum}
    
    \setlength\parindent{0pt}% globally suppress indentation
    
    \begin{document}
    
    \lipsum[2]\medskip
    
    \lipsum[2]
    
    \end{document}
    

gives

enter image description here

  1. Load the parskip package. For example:

    \documentclass{article}
    \usepackage{parskip}
    \usepackage[nopar]{lipsum}
    
    \begin{document}
    
    \lipsum[2]
    
    \lipsum[2]
    
    \end{document}
    

produces:

enter image description here

  1. Use one of the KOMA-Script document clases and one of the options of the parskip= or halfparskip= family (see the documentation for details). An example:

    \documentclass[parskip=full+]{scrartcl}
    \usepackage[nopar]{lipsum}
    
    \begin{document}
    
    \lipsum[2]
    
    \lipsum[2]
    
    \end{document}
    

produces:

enter image description here

Just to explain why using \\ followed by a blank line (or a \par command) produces the warning:

when TeX ends a paragraph, it inserts something like

\unskip \penalty10000 \hskip\parfillskip

doing \\\par will result in

\\ \unskip \penalty10000 \hskip\parfillskip

The \unskip has no effect since it finds no preceding glue, so \\ is followed by a penalty and a glue which will disappear after the line break; however, TeX was already expecting an extra line but there is nothing to fill it with, so an underfull box results.

6
  • 1
    But does it actually hurt anything? Or does it just make the console output messier? (As opposed to the typeset output.)
    – cfr
    Commented Apr 24, 2014 at 2:47
  • 3
    @cfr I've seen (ugly) 300+ pages documents typeset using ` \\ ` followed by a blank line to leave additional vertical separation between (almost) all paragraphs. I haven't seen any catastrophic consequence of doing this, besides producing ugly results (both because that extra space is bad practice and because in some cases the user forgot to add ` \\ ` introducing inconsistencies in the document). Commented Apr 25, 2014 at 3:27
  • @cfr So, I've never seen any disastrous effect os uding that and I cannot think of any (besides what I mentioned above); however, I'll ask in chat to the TeX gurus to see if they know of any such effect. Commented Apr 25, 2014 at 3:29
  • I guess I'm not sure how to entirely avoid them when creating things like teaching materials (syllabi, handouts, assignments) where they seem hard to avoid. That is, I don't use `\\` followed by a blank line to separate paragraphs but I do sometimes increase the spacing between paragraphs in other ways. In something like an article, it is different. But there seem a lot of things LaTeX doesn't like about course materials and handouts etc.
    – cfr
    Commented Apr 25, 2014 at 3:33
  • 4
    @cfr Today I asked David Carlisle in chat about possible undesired "real" side-effects of ` \\\par` and he mentioned problems with page breaks. I designed this little MWE which shows this real problem: \documentclass{article} \usepackage{showframe} \begin{document} \vspace*{44\baselineskip} test text\\ test text \end{document}. As you can see, the second page has a spurious empty line at the beginning due to the \\ . Commented Apr 28, 2014 at 3:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .