\ rowcolor และ @ {}

Sep 15 2020

ในตัวอย่างถัดไปเราจะเห็น\rowcolorว่าไม่ได้คำนึงถึงการประกาศ@{}ในtabularคำนำ

นี่เป็นพฤติกรรมปกติหรือไม่? มีวิธีที่หรูหราในการหลีกเลี่ยงพื้นที่ที่เต็มไปด้วยปลอมหรือไม่

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

\begin{document}

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

\end{document}

คำตอบ

2 jsbibra Sep 15 2020 at 15:59

สิ่งนี้อาจตรงตามความต้องการของคุณ

\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

แพคเกจ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}

คุณต้องรวบรวมหลาย ๆ

2 Zarko Sep 15 2020 at 16:43

คุณกำลังมองหา:

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