3

Four years ago, David Carlisle sketched in this answer a way to mitigate problems with the pdf rendering of lines in cloloured tables. My question: Is there now an available LaTeX package implementing that approach?

Alternatively, is there another LaTeX package mitigating the base problem (unreliable pdf rendering of lines in tables containing gray cells, rows, or columns)?

The following options are excluded:

  • Changing the table layout (there is an external format template we should follow)
  • Changing to another Macro package like ConTeXt (it is a highly collaborative document of considerable length with many authors and writers)
3
  • 3
    You could check the package nicematrix...
    – Rmano
    Sep 27 at 10:10
  • 6
    nicematrix or tabularray Sep 27 at 10:17
  • 2
    or simply don't use rules with coloured panels (they never look nice even when they work) see for example the booktabs package guidelines on when to use vertical rules: "Never, ever use vertical rules." Sep 27 at 11:41
8

Tabularray package fixed this missing border problem in version 2021N for short tables, and in version 2021P for long tables.

\documentclass{article}

\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}

\begin{tblr}{colspec={|l|c|r|},rowspec={|Q[cyan7]|Q[azure7]|Q[blue7]|}}
 Alpha   & Beta  & Gamma  \\
 Epsilon & Zeta  & Eta    \\
 Iota    & Kappa & Lambda \\
\end{tblr}

\end{document} 

enter image description here

2
  • Accepted because it works almost out of the box, only \cline from older table markup is not really usable. Sep 30 at 10:04
  • If you want to use \cline, you need remove | from rowspec.
    – L.J.R.
    Sep 30 at 13:37
9

With {NiceTabular} of nicematrix, the rules are drawn by Tikz after the construction of the array (however, this requires several compilations).

The rules won't seem to disappear, even when they are near a colored panel.

\documentclass{article}
\usepackage{nicematrix}
\begin{document}

\begin{center}
\begin{NiceTabularX}{\textwidth}{>{\columncolor[gray]{0.95}}lX}[hvlines,colortbl-like]
    Titre                & Some text here         \\
    Date de modification & \today                 \\
    Responsable          & Some name              \\
    E-mail               & Sorry for the french   \\
    Sujet                & Lorem Ipsum            \\
    Version du document  & 2.0                    \\
\end{NiceTabularX}
\end{center}

\end{document}

Output of the first code

1
  • An interesting package "from future". For the tables, the newest version not only of this package but also of the experimental LaTeX3 packages are required. Sep 30 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.