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
?
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}
revtex inserts some extra tabcolsep
spaces and so add three lines to compensate:
documentclass{revtex4-1}
usepackage{colortbl}
makeatletter
defCT@@do@color{%
globalletCT@do@colorrelax
@tempdimawdz@
advance@tempdima@tempdimb
advance@tempdima@tempdimc
advance@tempdimbtabcolsep
advance@tempdimctabcolsep
advance@tempdima2tabcolsep
kern-@tempdimb
leadersvrule
%^^A @heightp@@depthp@
hskip@tempdima@plus 1fill
kern-@tempdimc
hskip-wdz@ @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).
Answered by F. Pantigny on December 12, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP