加载 xcolor 时,带有 KOMA-Script 类的长表标题前出现奇怪的垂直空间

加载 xcolor 时,带有 KOMA-Script 类的长表标题前出现奇怪的垂直空间

当使用其中一个主要的 KOMA-Script 类 — —  scrartcl、,但不是 — — 时,环境中标题的垂直位置会随着加载或卸载包而发生变化scrreprt:如果加载后者,则标题上方会有额外的间距。scrbookscrlttr2longtablexcolor

这是一个最小的工作示例。

\documentclass[a4paper]{scrartcl}% scrartcl, scrreprt, scrbook

\usepackage{xcolor}% comment and uncomment to see the effect
\usepackage{longtable}

\begin{document}
%
\noindent%
\centering%
Blah blah blah blah.
\begin{longtable}{l l l l}
\hline
\caption{Caption} \\
\hline
\endfirsthead
\hline
\endfoot
Cell & Cell & Cell & Cell \\
Cell & Cell & Cell & Cell \\
\end{longtable}
Blah blah blah blah.
%
\end{document}

结果如下图所示。

无论是否加载 xcolor,longtable 中的标题间距

xcolor如果我之后加载longtable或者将标题放在表格底部,也会出现此问题。,如果我加载caption包,额外的空间就会消失,结果在每种情况下都是第一个 — 预期的 — 一个。我只是不需要这个额外的包,只要我可以使用 KOMA-Script 类中的命令和选项获得我想要的东西。最后,无论是否caption加载包,标准类都不会出现这种情况。

(关于我的代码仅需几点说明:我只\hline在标题前插入了 以使情况更清楚,但没有它问题仍然会出现;此外,在最终版本中,我显然会使用\captionabove\captionKOMA-Script 选项captions=tableheading,以及booktabs!)

问题是:如何在不加载软件包的情况下摆脱额外的空间caption

我还有一个次要的问题:为什么环境后的间距longtable比环境前的间距大?默认情况下,在包中,长度\LTpre\LTpost都定义为等于。\bigskipamountlongtable

答案1

无需加载任何额外软件包的解决方法是

\def\capfont{\leavevmode\normalfont\normalcolor}

添加\leavevmode

相关内容