1

In the next example we can see that \rowcolor does not take into account the declaration @{} in tabular preambles.

enter image description here

Is this a normal behavior? Is there some elegant way to avoid that spurious filled space?

\documentclass{article}
\usepackage{xcolor, colortbl}

\begin{document}

\begin{tabular}{|c|c|c@{}|} \rowcolor{gray!30} text & text & text \end{tabular}

\end{document}

e_moro
  • 888

3 Answers3

5

The package nicematrix with its environment {NiceTabular} tries to solve the problems of the package colortbl.

Here is the output of {NiceTabular}.

\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}

\begin{document} \begin{NiceTabular}{|c|c|c@{}|}[colortbl-like] \Hline \rowcolor{gray!30} text & text & text\ \Hline \end{NiceTabular} \end{document}

You need several compilations.

Output of the above code

F. Pantigny
  • 40,250
4

This might meet your requirement

enter image description here

\documentclass{article}
\usepackage{xcolor, colortbl}

\begin{document}

\begin{tabular}{|c|c|>{\kern-\tabcolsep}c<{\kern-\tabcolsep}|} \rowcolor{gray!30} text & text & text \end{tabular}

\end{document}

js bibra
  • 21,280
2

Do you looking for:

enter image description here

\documentclass{article}
\usepackage[table]{xcolor}

\begin{document} \begin{tabular}{|c|c| >{\columncolor{white}[\tabcolsep][0pt]}c @{}|} \rowcolor{gray!30} text & text & text \end{tabular} \end{document}

Zarko
  • 296,517