我用它endfloat
来处理文档末尾的所有表格。我还使用了隐藏文本内标记的选项。但是,endfloat
似乎仍然会在标记所在的位置插入一个空格(实际上在段落之间创建了一个不必要的空格)。发生这种情况的原因是居中标记。删除它们可以解决问题。为什么会发生这种情况?MWE:
\documentclass[english]{article}
\usepackage[nolists,tablesfirst,nomarkers]{endfloat}
\begin{document}
Some text here Some text here Some text here Some text here Some text
here Some text here Some text here Some text here Some text here Some
text here Some text here Some text here Some text here Some text here
Some text here Some text here Some text here Some text here Some text
here Some text here Some text here Some text here Some text here Some
text here Some text here Some text here Some text here Some text here
Some text here
\begin{center}
\begin{table}
\protect\caption{My Table}
\begin{tabular}{|c|c|c|c|c|}
\hline
a & & & & \tabularnewline
\hline
\hline
& b & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
\end{tabular}
\end{table}
\par\end{center}
Some more text here Some more text here Some more text here Some more
text here Some more text here Some more text here Some more text here
Some more text here Some more text here Some more text here Some more
text here Some more text here Some more text here Some more text here
Some more text here Some more text here Some more text here Some more
text here Some more text here Some more text here
\end{document}
答案1
该空间是由center
环境引起的。center
环境被定义为trivlist
(或简称为list
)
\def\center{\trivlist \centering\item\relax}
\def\endcenter{\endtrivlist}
如你所见,它是一个\trivlist
围绕\centering
。的效果\trivlist
是添加 \topsep
等。\partopsep
关于这些东西的定义,请参阅latex.ltx
。总之,center
环境在上方和下方增加了垂直空间,在某些情况下(比如这个)是不必要的。
此外,环境内的表格center
会浮动(放在末尾),但center
环境会保持原位。空白(与center
环境相关)也会保持在原始位置,并且table
会超出center
环境,因此不会居中。
通过使用 来避免这些空格\centering
。
\documentclass[english]{article}
\usepackage[nolists,tablesfirst,nomarkers]{endfloat}
\begin{document}
Some text here Some text here Some text here Some text here Some text
here Some text here Some text here Some text here Some text here Some
text here Some text here Some text here Some text here Some text here
Some text here Some text here Some text here Some text here Some text
here Some text here Some text here Some text here Some text here Some
text here Some text here Some text here Some text here Some text here
Some text here
%\begin{center}
\begin{table}
\caption{My Table} %% no need of \protect use \caption[short title] instead
\centering %%<--- here
\begin{tabular}{|c|c|c|c|c|}
\hline
a & & & & \tabularnewline
\hline
\hline
& b & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
\end{tabular}
\end{table}
%\par\end{center}
Some more text here Some more text here Some more text here Some more
text here Some more text here Some more text here Some more text here
Some more text here Some more text here Some more text here Some more
text here Some more text here Some more text here Some more text here
Some more text here Some more text here Some more text here Some more
text here Some more text here Some more text here
\end{document}