如何修复“Underfull \hbox (badness 10000)”警告?

15

我有一个小的.tex文件。

\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}

编译时,它会警告该行:

\textbf{Task 1} \newline

以下是信息:

"Underfull \hbox (badness 10000)".

我该如何修复这个问题?


1
请参阅以下链接以获取更多信息:如何正确编写TeX文件,或至少避免“badness 10000” - Rick Smith
3个回答

12

我曾经遇到过类似的问题,我通过删除每个句子末尾没有文本内容的任何\newline\\来解决它。

例如,两个导致该问题的例子:

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

对于图片或类似内容也是如此。

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

5
一个快速且简便的解决方案是使用 parskip 软件包,不要使用 \newline\\ 进行换行,只需插入一个空行即可。
\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}

警告将会消失。


顺便提一下,要了解为什么会出现这种情况,请参考 TeX Stack Exchange 上的 这个问题


3

不要使用\newline来强制产生一个未满行的盒子,你可以通过留出一行空白来开始一个新段落:

\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}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接