即使标记文本关闭,endfloat 也会留下空间

即使标记文本关闭,endfloat 也会留下空间

我用它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}

在此处输入图片描述

相关内容