AnswerBun.com

revtex4-1 and colortbl doesn't fill cells

TeX - LaTeX Asked by sven on December 12, 2020

The MWE below shows that the cellcolor command doesn’t properly fill a table cell in revtex4-1 where it would do so in a simple article. Can anyone help me get fills that extend to the boundaries of my cells in revtex4-1?

Difference between article and revtex 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}

2 Answers

enter image description here

revtex inserts some extra tabcolsep spaces and so add three lines to compensate:

documentclass{revtex4-1}
usepackage{colortbl}

makeatletter

    [email protected]@[email protected]{%
      [email protected]@colorrelax
            @[email protected]
            [email protected]@tempdimb
            [email protected]@tempdimc
    [email protected]
    [email protected]
    [email protected]
            [email protected]
            leadersvrule
    %^^A                     @[email protected]@[email protected]
                    [email protected]@plus  1fill
            [email protected]
            [email protected] @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}

Correct answer by David Carlisle on December 12, 2020

The problem is still present with the class revtex-4.2.

With the environment {NiceTabular} of nicematrix (similar to {tabular} of array), you have directly the output you want. In fact, the output is better than with the class article because the rules won't seem to vanish in some PDF viewers at some levels of zoom (as in the picture of the OP).

 documentclass{revtex4-2}
 usepackage{nicematrix}
 begin{document}
 begin{NiceTabular}{ |c|l|l| }[colortbl-like] hline
 rowcolor{red} A    & B     & C     \ hline
 Hello World         & other     & cellcolor{blue}stuff\ hline
 end{NiceTabular}
 end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

Answered by F. Pantigny on December 12, 2020

Add your own answers!

Related Questions

Footnotes without numbering and without horizontal rule

1  Asked on November 14, 2020 by mr-gold

 

Text going past page

0  Asked on November 14, 2020 by palestina

       

Input{xxx} : file not found

0  Asked on November 14, 2020 by mattia-galanti

   

curved lower arrow?

2  Asked on November 10, 2020

 

How might one create a nice looking table in Latex?

4  Asked on November 10, 2020 by exploring

 

How to add shading to a node in a graph

1  Asked on November 9, 2020

 

`counterwithin` not work with custom counters

1  Asked on November 9, 2020 by rabbittac

   

Using raisebox to change nested underlining

0  Asked on November 9, 2020 by latexerexetal

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir