表格末尾的多余一行导致 \hbox 溢出

表格末尾的多余一行导致 \hbox 溢出

我很困惑为什么我不能把“\end{scriptsize}”放在新行上而不会得到以下内容\hbox 溢出错误:

在此处输入图片描述

LaTeX 代码(带有 Overfull 消息)在这里:

\documentclass[10pt, twoside, a4paper]{report}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage[ top=21mm, bottom=21mm, left=16mm, right=10mm]{geometry}
\showboxbreadth=50  % use for logging
\showboxdepth=50    % use for logging
\begin{document}
\sffamily
\begin{scriptsize}
\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
3 & 221°30.0 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}48.4\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
9 & 311°27.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}47.5\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
15 & 41°26.9 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}44.0\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
21 & 131°28.3 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}38.1\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
27 & 221°30.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}51.1\\ 
\end{tabular*}
\end{scriptsize}
\end{document}

如果我将这两个命令放在脚本末尾的一行上(并且生成的 PDF 看起来相同),则不会出现 Overfull 消息:

\end{tabular*}\end{scriptsize}

我在日志文件中看到 Overfull 问题与 $\cdot$ 内容有关;但这个字符非常适合我的要求。

编辑: 我删除了所有其他没有数学字体的表格行。这些不会导致 Overfull 消息。Overfull 消息与包含数学字体的特定行有某种关联。

一个更普遍的问题是 - 程序员在格式化 TeX/LaTeX 代码行时有什么自由?我提到这一点是因为所有 LaTeX 代码都是由 Python 代码自动生成的,我希望生成的 TeX 文件具有一定的可读性。在某些情况下,缩进(TeX/LaTeX)代码对 PDF 输出文件没有影响,但是我认为我可以将上述两个有问题的命令放在单独的行上,以提高可读性(TeX/LaTeX 文件)。

答案1

(经过编辑,纳入了@DavidCarlisle 的有用评论)

在 LaTeX 中,单个换行符通常被视为空格。例如,请考虑以下内容:

\documentclass{article}
\begin{document}
Hello
world
\end{document}

(“Hello” 后面没有空格)将输出“Hello world”(带有空格)。

在段落末尾(用一个\par或两个换行符表示,或(在您的 MWE 中)文档末尾),多余的空间会被 LaTeX 自动通过 取出,这样\unskip一切都会很好地呈现。

就你的情况而言,你有空格:一个来自最后一个 之后的换行符\end{tabular*},另一个来自 之后的换行符\end{scriptsize}。LaTeX 会为您删除其中一个,但不会同时删除两个。也就是说,会保留一个空格,这会使包含表格的行太宽。

如果您想要两个换行符(例如为了便于阅读),通常的方法是将 放在%行尾(实际上是将其注释掉),同时避免多余的空格。因此:

\documentclass[10pt, twoside, a4paper]{report}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage[ top=21mm, bottom=21mm, left=16mm, right=10mm]{geometry}
\showboxbreadth=50  % use for logging
\showboxdepth=50    % use for logging
\begin{document}
\sffamily
\begin{scriptsize}
\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
3 & 221°30.0 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}48.4\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
9 & 311°27.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}47.5\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
15 & 41°26.9 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}44.0\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
21 & 131°28.3 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}38.1\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
27 & 221°30.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}51.1\\ 
\end{tabular*}%
\end{scriptsize}
\end{document}

现在,末尾( 之后)只有一个由换行符创建的空格\end{scriptsize},LaTeX 将为您处理。

答案2

哇!根据 David Carlisle 对我的另一个问题(字体更改导致 \vbox 过满)的回复,此脚本结尾消除了 Overfull \hbox 消息:

\end{tabular*}

\end{scriptsize}
\end{document}

相关内容