15

I have this small .tex file.

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titling}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}


\setlength{\droptitle}{-3.5cm}
\setlength{\parindent}{0cm}
\newcommand{\squad}{\hspace{0.5em}}

\author{vladgovor77771}
\title{Some article}

\begin{document}
\maketitle

\textbf{Task 1} \newline
Task description: \newline

\end{document}

When compiling, it warns about line

\textbf{Task 1} \newline

With the following message:

"Underfull \hbox (badness 10000)".

How do I fix this?

Paul de Vrieze
  • 4,888
  • 1
  • 24
  • 29
  • See: [How to properly code a TeX file, or at least avoid `badness 10000`](https://tex.stackexchange.com/q/51722/187997) for more information. – Rick Smith Sep 28 '20 at 18:56

3 Answers3

10

I had a similar issue, I solved it by removing any \newline or \\ at the and of every sentence that had nothing textual below.

For instance, two examples that causes that problem:

An example. \\
This is well used. \\
This line will cause the error. \\

(I'm a new paragraph) \\
Because there's nothing directly underneath.\\
The last line does NOT require a "newline".

This is a thid paragraph. \\
:D

The same is true for figures or similar

This is a line.
Putting a "newline", as here, before a \begin will cause the error. \\
\begin{figure}[h]
....
\end{figure}
Marco Ottina
  • 399
  • 5
  • 12
5

A quick and nice solution is to use package parskip, and instead of using \newline or \\ for line breaks, simply insert an empty line

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titling}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{parskip} %% <-- added

\setlength{\droptitle}{-3.5cm}
\setlength{\parindent}{0cm}
\newcommand{\squad}{\hspace{0.5em}}

\author{vladgovor77771}
\title{Some article}

\begin{document}
\maketitle

\textbf{Task 1}

Task description:

\end{document}

The warning will be gone.


By the way, to know why it happened, refer to this question on TeX Stack Exchange.

zyy
  • 1,271
  • 15
  • 25
2

Instead of forcing an underfull box with \newline, you could simply leave an empty line to start a new paragraph:

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titling}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}


\setlength{\droptitle}{-3.5cm}
\setlength{\parindent}{0cm}
\newcommand{\squad}{\hspace{0.5em}}

\author{vladgovor77771}
\title{Some article}

\begin{document}
\maketitle

\textbf{Task 1} 

Task description: 

blabla

\end{document}