我试图在我的文档中创建一个或多或少类似于下图中的表格的表格:
这张桌子应该水平拉伸到\textwidth
. 我的第一次尝试tabular*
看起来像这样:
\documentclass{scrartcl}
\usepackage[table]{xcolor}
\definecolor{tableShade}{gray}{0.9}
\begin{document}
\rowcolors{3}{tableShade}{white} %% start alternating shades from 3rd row
\noindent\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lrrr}
Something & foo & bar & baz \\
Something & foo & bar & baz \\
Something & foo & bar & baz \\
Something & foo & bar & baz \\
Something & foo & bar & baz \\
\end{tabular*}
\end{document}
结果是:
好吧,备用行着色有效,但tabular*
在列之间插入空间以将整个表拉伸到\textwidth
. 浏览我的 LaTeX 伴侣,我发现它tabularx
应该能够做我想做的事。所以我改变了我的代码看起来像这样:
\documentclass{scrartcl}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\definecolor{tableShade}{gray}{0.9}
\begin{document}
\rowcolors{3}{tableShade}{white} %% start alternating shades from 3rd row
\noindent\begin{tabularx}{\textwidth}{Xrrr}
Something & foo & bar & baz \\
Something & foo & bar & baz \\
Something & foo & bar & baz \\
Something & foo & bar & baz \\
Something & foo & bar & baz \\
\end{tabularx}
\end{document}
现在,这看起来更像它。但tabularx
忽略着色的起始行并从第一行开始。
现在我已经没有想法了。有什么建议么?