vấn đề \ rowcolor và @ {}

Sep 15 2020

Trong ví dụ tiếp theo, chúng ta có thể thấy điều \rowcolorđó không tính đến khai báo @{}trong phần tabularmở đầu.

Đây có phải là một hành vi bình thường? Có một số cách thanh lịch để tránh không gian đầy giả tạo đó không?

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

\begin{document}

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

\end{document}

Trả lời

2 jsbibra Sep 15 2020 at 15:59

Điều này có thể đáp ứng yêu cầu của bạn

\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}
4 F.Pantigny Sep 15 2020 at 16:40

Gói nicematrixvới môi trường của nó {NiceTabular}cố gắng giải quyết các vấn đề của gói colortbl.

Đây là đầu ra của {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}

Bạn cần nhiều bản tổng hợp.

2 Zarko Sep 15 2020 at 16:43

Bạn có tìm kiếm:

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