一问一答:revtex4-1 与 colortbl 宏包着色上的兼容问题

发布于 2022-11-14 00:43:03

当我们在 revtex4-1 类中使用 colortbl,着色会出现覆盖不全的情况,例子如下:

\documentclass{revtex4-1}
\usepackage{colortbl}
\begin{document}
\begin{tabular}{ |c|l|l| } \hline
\rowcolor{red} A    & B     & C     \\ \hline
Hello World         & other     & \cellcolor{blue}stuff\\ \hline
\end{tabular}
\end{document}

效果如下:
image.png

查看更多

关注者
0
被浏览
555
1 个回答
LaTeXStudio
LaTeXStudio 2022-11-14
这家伙很懒,什么也没写!

主要因为 revtex 给 tabcolsep 增加了额外的间距,可以通过下面的代码修复:

\documentclass{revtex4-1}
\usepackage{colortbl}

\makeatletter

    \def\CT@@do@color{%
      \global\let\CT@do@color\relax
            \@tempdima\wd\z@
            \advance\@tempdima\@tempdimb
            \advance\@tempdima\@tempdimc
    \advance\@tempdimb\tabcolsep
    \advance\@tempdimc\tabcolsep
    \advance\@tempdima2\tabcolsep
            \kern-\@tempdimb
            \leaders\vrule
    %^^A                     \@height\p@\@depth\p@
                    \hskip\@tempdima\@plus  1fill
            \kern-\@tempdimc
            \hskip-\wd\z@ \@plus -1fill }
    \makeatother
    \begin{document}

    \begin{tabular}{ |c|l|l| } \hline
    \rowcolor{red} A    & B     & C     \\ \hline
    Hello World         & other     & \cellcolor{blue}stuff\\ \hline
    \end{tabular}
    \end{document}

image.png

选自:https://tex.stackexchange.com/questions/102665/revtex4-1-and-colortbl-doesnt-fill-cells

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览