\rowcolor と @{} の問題

\rowcolor と @{} の問題

次の例では、プリアンブル内の\rowcolor宣言が考慮されていないことがわかります 。@{}tabular

ここに画像の説明を入力してください

これは正常な動作ですか? 不必要なスペースを埋めるのを避けるための優れた方法はあるでしょうか?

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

\begin{document}

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

\end{document}

答え1

これはあなたの要件を満たすかもしれません

ここに画像の説明を入力してください

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

答え2

パッケージnicematrixとその環境は、{NiceTabular}パッケージの問題を解決しようとしますcolortbl

の出力は次のとおりです{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}

複数のコンパイルが必要です。

上記コードの出力

答え3

以下をお探しですか?

ここに画像の説明を入力してください

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

関連情報