TeX - LaTeX Asked on March 24, 2021
I am a LaTeX beginner and facing an issue that I can’t seem to find the answer for… I am creating a table (using booktabs
but my issue also occurs when not using the package), and whenever I remove the space on the edges of the table (with @{}
) and try to colour individual rows at the same time, the space taken by the colour is wider than the table. See the following example:
usepackage{array}
usepackage{colortbl}
usepackage[table,xcdraw]{xcolor}
% [...]
fbox{begin{tabular}{@{}ll@{}}
foo & bar
rowcolor[HTML]{BFBFBF} bar & foo
end{tabular}}
Which results in the following:
Thanks in advance for any help/pointer!
You could use NiceTabular
from the nicematrix
package instead:
documentclass{article}
usepackage[table,xcdraw]{xcolor}
definecolor{mygray}{HTML}{BFBFBF}
usepackage{nicematrix}
begin{document}
fbox{begin{NiceTabular}{@{}ll@{}}[code-before=rowcolor{mygray}{2}]
foo & bar
bar & foo
end{NiceTabular}}
end{document}
Answered by leandriis on March 24, 2021
I suggest setting fboxsep
to $0$ instead, and keeping the spaces at both ends of the table, loading cellspace
for the vertical spacing at the top and bottom of the table:
documentclass{article}
usepackage{array}
usepackage[table,xcdraw]{xcolor}
usepackage{cellspace}
setlength{cellspacetoplimit}{4pt}
setlength{cellspacebottomlimit}{4pt}
% [...]
begin{document}
{setlength{fboxsep}{0pt}
fbox{%
begin{tabular}{Sll}
foo & bar
rowcolor[HTML]{BFBFBF} bar & foo
end{tabular}}
}
end{document}
Answered by Bernard on March 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP