\rowcolor e @{} problema

\rowcolor e @{} problema

No próximo exemplo podemos ver que \rowcolornão leva em consideração a declaração @{}nos tabularpreâmbulos.

insira a descrição da imagem aqui

Este é um comportamento normal? Existe alguma maneira elegante de evitar esse espaço preenchido espúrio?

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

\begin{document}

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

\end{document}

Responder1

Isso pode atender às suas necessidades

insira a descrição da imagem aqui

\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}

Responder2

O pacote nicematrixcom seu ambiente {NiceTabular}tenta resolver os problemas do pacote colortbl.

Aqui está a saída de {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}

Você precisa de várias compilações.

Saída do código acima

Responder3

Você está procurando:

insira a descrição da imagem aqui

\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}

informação relacionada