这是我的代码:
\begin{table}[H]
\begin{tabularx}{\textwidth}{sfmX}
\noalign{\hrule height 1.5pt}
\rowcolor{orange!85} Version & Date & Autore & Description \\
\noalign{\hrule height 1.5pt}
1.1.1 & 2016-01-11 & Person 1 & Action 1 \\
\noalign{\hrule height 0.5pt}
1.1.0 & 2016-01-10 & Person 2 & Action 2 \\
\noalign{\hrule height 1.5pt}
\end{tabularx}
\caption{Diary \label{tab:table_label}}
\end{table}
with:
\newcolumntype{s}{>{\hsize=.22\hsize}X}
\newcolumntype{f}{>{\hsize=.4\hsize}X}
\newcolumntype{m}{>{\hsize=.5\hsize}X}
有没有办法删除超过\noalign{\hrule}
的?
无法找出为什么tabularx不会占用所有空间,或为什么规则占用太多!
答案 0 :(得分:1)
问题实际上是彩色标题行比\hrule
短,因为它们很适合\textwidth
。此外,您对列s
的选择范围太窄。
相反,我建议您暂停使用\hrule
,因为您可以使用booktabs
中已有的结构:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{booktabs,tabularx}
\colorlet{headcol}{orange!85}
\newcommand{\headcol}{\rowcolor{headcol}}
\newcommand{\toprulec}{\arrayrulecolor{black}\specialrule{0.1em}{\abovetopsep}{0pt}%
\arrayrulecolor{headcol}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}}
\newcommand{\midrulec}{\arrayrulecolor{headcol}\specialrule{\aboverulesep}{0pt}{0pt}%
\arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
\arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{l l l X}
\toprulec
\headcol Version & Date & Autore & Description \\
\midrulec
1.1.1 & 2016-01-11 & Person 1 & Action 1 \\
1.1.0 & 2016-01-10 & Person 2 & Action 2 \\
\bottomrule
\end{tabularx}
\end{document}