定义行颜色时,禁忌中存在错误吗?

定义行颜色时,禁忌中存在错误吗?

在下面的代码中,从单元格到底部的垂直间距为负数,而不是定义和和\tabulinesep=5pt时定义的值。\rowcolor{headcolor}\rowfont

\documentclass[]{scrartcl} 
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{tabu}
  \tabulinesep=5pt
\listfiles
\begin{document}
\colorlet{headcolor}{gray!25}
\begin{tabu} to 0.8\textwidth{X[1,L]X[1,L]}
    \hline
    \rowcolor{headcolor}
    \rowfont[l]{\bfseries}%
     head & head \tabularnewline
    \hline
    text which is considerably longer than the width of the column &
    text which is considerably longer than the width of the column \\
    \hline
\end{tabu}
\end{document}

视觉效果如下

在此处输入图片描述

这是 tabu 包的一个错误吗?我联系了 tabu 的作者,但几天都没有得到答复。

答案1

\rowcolor由 定义colortbl。因此,这两个包不兼容。您可以使用以下tabu命令来修复此问题\taburowcolors

\colorlet{headcolor}{gray!25}
\begin{tabu} to 0.8\textwidth{X[1,L]X[1,L]}
    \hline
    \taburowcolors 1{headcolor .. headcolor}
    \rowfont[l]{\bfseries}%
     head & head \tabularnewline
    \taburowcolors 1{white .. white}
    \hline
    text which is considerably longer than the width of the column &
    text which is considerably longer than the width of the column \\
    \hline
\end{tabu}

带有彩色行的禁忌示例

答案2

\rowcolor这很奇怪,但对我有帮助的只是切换和命令的顺序\rowfont,即将\rowcolor命令放在行内容之前。

因此,在您的示例中应该是:

...
\begin{tabu} to 0.8\textwidth{X[1,L]X[1,L]}
    \hline
    \rowfont[l]{\bfseries}\rowcolor{headcolor}%
     head & head \tabularnewline
    \hline
    text which is considerably longer than the width of the column &
    text which is considerably longer than the width of the column \\
    \hline
\end{tabu}
...

此后,tabu工作正常,并且\tabulinesep每行的命令都正确显示。

相关内容