TeX - LaTeX Asked on June 30, 2021
documentclass[11pt]{article}
usepackage[table]{xcolor}
definecolor{lightgray}{gray}{0.9}
begin{document}
begin{table}[ht]
caption{default}
begin{center}
rowcolors{1}{}{lightgray}
begin{tabular}{r|rrrrr}
hline
& 1 & 2 & 3 & 4 & 5
hline
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65
2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51
3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28
4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59
5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30
6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60
7 & 1.28 & -0.46 & 1.33 & -0.66 & -1.80
8 & 0.80 & 0.46 & 1.37 & 1.73 & 1.93
9 & -0.75 & 0.28 & 0.51 & 0.19 & 0.58
10 & -1.64 & -0.12 & -1.17 & -0.10 & -0.04
hline
end{tabular}
end{center}
end{table}
end{document}
I think that what you see is mostly aliasing and/or effect of the viewer antialiasing algorithms. Your code, using okular
, 1600% magnification, color picked:
If the effect annoys you, you can remove all the vertical lines and play with spaces and styles:
documentclass[11pt]{article}
usepackage[table]{xcolor}
definecolor{lightgray}{gray}{0.9}
usepackage{booktabs}
begin{document}
begin{table}[ht]
caption{default}
begin{center}
rowcolors{1}{}{lightgray}
begin{tabular}{>{bfseries}rrrrrr}
toprule
qquad & 1 & 2 & 3 & 4 & 5
midrule
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65
2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51
3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28
4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59
5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30
6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60
7 & 1.28 & -0.46 & 1.33 & -0.66 & -1.80
8 & 0.80 & 0.46 & 1.37 & 1.73 & 1.93
9 & -0.75 & 0.28 & 0.51 & 0.19 & 0.58
10 & -1.64 & -0.12 & -1.17 & -0.10 & -0.04
bottomrule
end{tabular}
end{center}
end{table}
end{document}
Answered by Rmano on June 30, 2021
The package nicematrix
has tools specifically designed to solve that kind of problems.
The environment {NiceTabular}
draws the colored cells, rows and columns before the rules. The resulting PDF is much easier to interpret by the PDF viewers and you won't have the effect you see by using the package colortbl
(which is loaded by the key table
of xcolor
).
documentclass[11pt]{article}
usepackage{xcolor}
definecolor{lightgray}{gray}{0.9}
usepackage{nicematrix}
begin{document}
begin{table}[ht]
caption{default}
begin{center}
begin{NiceTabular}{r|rrrrr}
CodeBefore
rowcolors{1}{}{lightgray}
Body
hline
& 1 & 2 & 3 & 4 & 5
hline
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65
2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51
3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28
4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59
5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30
6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60
7 & 1.28 & -0.46 & 1.33 & -0.66 & -1.80
8 & 0.80 & 0.46 & 1.37 & 1.73 & 1.93
9 & -0.75 & 0.28 & 0.51 & 0.19 & 0.58
10 & -1.64 & -0.12 & -1.17 & -0.10 & -0.04
hline
end{NiceTabular}
end{center}
end{table}
end{document}
You need several compilations (because nicematrix
uses PGF/Tikz nodes).
Answered by F. Pantigny on June 30, 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