1

The following code gives me the following error "Underfull \hbox (badness 10000)"

  \documentclass{article}
  \begin{document}
  text \\ \\
  text
  \end{document}

I found some alternatives, such as \vspace, but I prefer something that is by default and universal. For example, I have to adjust the unit of measure in different preamble. I would like something like this at the end. enter image description here

My reference point is this enter image description here

  • 4
    never use \\ at the end of a paragraph or after another \\ – David Carlisle Oct 16 '23 at 15:43
  • https://tex.stackexchange.com/questions/334246/what-does-the-phrase-underfull-hbox-badness-10000-in-paragraph-actually-mea/334249#334249 – David Carlisle Oct 16 '23 at 15:44
  • do you really want the output shown, with an indented paragraph including a blank line and a non-indented final line? How is the reader supposed to understand where the paragraph ends? – David Carlisle Oct 16 '23 at 15:46
  • If you really want that then text.\\ \mbox{}\\ text. will give that but it will not be understood by most readers, and it will produce a blank line at the top of a page if a page break occurs after the first line. – David Carlisle Oct 16 '23 at 15:48
  • @DavidCarlisle, I just edited the actual output I want. Thanks for your response. – Alessandro Lin Oct 16 '23 at 16:38
  • It looks like a paragraph so just leave a blank line (and no \\ ) but why do you want the second paragraph not indented but the first paragraph indented, that looks really strange? – David Carlisle Oct 16 '23 at 16:39
  • @AlessandroLin Take a few books off your shelf and count how many instances of a paragraph break with a “blank line” you see. Just don't do that and simply leave a blank line in the input file when you want a new paragraph. – egreg Oct 16 '23 at 16:54

2 Answers2

3

You will always get the "Underfull hbox" message if you have \\ \\ in your file. While it's usually preferable to leave a paragraph break (blank line) to end a line, in your case you want a real blank line before the paragraph continues.

An option is available that will avoid this message and produce an actual blank line in the output:

\documentclass{article}
\begin{document}
text \\[1\baselineskip]
text
\end{document}

Note that it's not a good idea to leave a blank space before the \\ . If the broken line just happens to fill the whole output line and the space goes to the next line, you'll get an extra blank line as well as the unwanted "Underfull hbox" message.

Edit:

Testing what happens when a final space would exceed the width of the line, I can't reproduce the problem described above. But using the optional vertical dimension is still the easiest and most reliable way to insert a blank line in a paragraph.

  • Space before \\ is removed by \unskip and it has no relevance. More precisely: \\ is equal to \@normalcr which runs \@xnewline which runs \@gnewline which runs \unskip \relax{\relax\relax}\nobreak\hfil\break. – wipet Oct 16 '23 at 20:03
  • @wipet -- Unfortunately, the default LaTeX conventions don't automatically remove a space before \\ and \unskip would have to be added manually. I find it easier to remember to not put in a space here. Newbies (and I believe this OP is a newbie) aren't familiar with commands that contain @ signs, so I went for the hack that is easiest to remember. – barbara beeton Oct 16 '23 at 20:10
  • @barbarabeeton as wipet showed, \\ does do an \unskip to remove (one) leading space. – David Carlisle Oct 16 '23 at 20:29
  • @DavidCarlisle -- Okay, I've tried to reconstruct that (that was one of the tests I mad the proceedings), but I can't. Still, using the optional [<dimen>] after the \\ is the easiest way to get the desired result. – barbara beeton Oct 16 '23 at 21:10
  • @barbarabeeton agreed, but it is worrying that that is the desired result – David Carlisle Oct 16 '23 at 21:23
  • @DavidCarlisle -- You may not desire it, but I've given up trying to figure out why authors may want to do many things. If the result makes sense in the particular context, I just look for the most dependable and straightforward way to accomplish it. The OP hasn't given enough context here. – barbara beeton Oct 16 '23 at 21:28
0

Let me spell out @David Carlisle's comments with an example.

It seems, that you after something like this:

enter image description here

This is produced by:

\documentclass{article}
\usepackage{lipsum}     % for dummy text
\setlength\parskip{\baselineskip}  % set desired vertical space between paragraphs
\setlength\parindent{0pt} % no indent at start of paragraph

\begin{document} \lipsum[66]

\lipsum[66] \end{document}

If this is not what you after, than consider @egreg comment and set parskip and parindent accordingly to your wish.

Zarko
  • 296,517