我正在创建一个表格,下面产生了我想要的间距。
\documentclass{article}
\usepackage{tabularx}
%%% \usepackage[table]{xcolor}
\begin{document}
%%% \rowcolors{2}{gray!25}{white}
\begin{tabularx}{\textwidth}{lr}
TextTextTextTextTextTextTextText & TextTextTextTextTextText \\
\multicolumn{2}{l}{TextTextTextTextTextTextTextTextTextText \hfill Text}
\end{tabularx}
\end{document}
不幸的是,当我取消注释两行注释以获得我想要的颜色时,间距会发生变化。这是怎么回事?有什么解决办法吗?
^ 表格来自 MWE
^ 表格中的行未注释
答案1
colortbl
如果不完全按照其文档中代码所暗示的那样,如果您使用拉伸胶,则colortbl
需要确保它总计0fill
以平衡为添加彩色面板而进行的内部拉伸。
\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\begin{document}
\rowcolors{2}{gray!25}{white}
\begin{center}
\begin{tabularx}{\textwidth}{l>{\raggedleft\arraybackslash}X}
TextTextTextTextTextTextTextText & TextTextTextTextTextText \\
\multicolumn{2}{l}{TextTextTextTextTextTextTextTextTextText \hfill
Text\hspace{\stretch{-1}}\mbox{}}
\end{tabularx}
\end{center}
\end{document}