我想给这些空列上色,但我找不到办法。我尝试过定义自己的列类型,但是插入它会破坏空列的正常外观。
这是我的最小工作示例:
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{center}
\begin{tabular}{||l c||}
\hline
\rowcolor{black!10}
Column 1 & Column 2 \\ [0.7ex]
\hline\hline
\rowcolor{green!20}
Entry 1 & Entry 2 \\
\hline
\rowcolor{green!25}
Entry 3 & Entry 4 \\
\hline
\end{tabular}
\end{center}
\end{document}
我想将外面的柱子涂成黑色。
谢谢!
解决方案:对于黑色着色,粗边框就足够了。对于其他颜色,请参阅我的彩色表格解决方案。
答案1
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{center}
\begin{tabular}{!{\vrule width 5pt}l c!{\vrule width 5pt}}
\hline
\rowcolor{black!10}
Column 1 & Column 2 \\ [0.7ex]
\hline\hline
\rowcolor{green!20}
Entry 1 & Entry 2 \\
\hline
\rowcolor{green!25}
Entry 3 & Entry 4 \\
\hline
\end{tabular}
\end{center}
\end{document}
答案2
如果我很清楚你想要什么的话,这里有一个解决方案:
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{center}
\setlength{\extrarowheight}{2pt}
\begin{tabular}{!{\vrule width \dimexpr\doublerulesep+2\arrayrulewidth\relax}l c!{\vrule width \dimexpr\doublerulesep+2arrayrulewidth\relax}}
\hline
\rowcolor{black!10}
Column 1 & Column 2 \\ [0.7ex]
\hline\hline
\rowcolor{green!20}
Entry 1 & Entry 2 \\
\hline
\rowcolor{green!25}
Entry 3 & Entry 4 \\
\hline
\end{tabular}
\end{center}
\end{document}
变体:
\begin{center}
\setlength{\extrarowheight}{2pt}\begin{tabular}{{@{\vrule width \dimexpr\doublerulesep+2\arrayrulewidth\relax}c@{\vrule width \dimexpr\doublerulesep+2\arrayrulewidth\relax}}}
\begin{tabular}{!{}l c!{}}
\hline
\rowcolor{black!10}
Column 1 & Column 2 \\ [0.7ex]
\hline\hline
\rowcolor{green!20}
Entry 1 & Entry 2 \\
\hline
\rowcolor{green!25}
Entry 3 & Entry 4 \\
\hline
\end{tabular}
\end{tabular}
\end{center}
答案3
好的,根据@Skillmon的提示,我查看了该包并找到了对彩色表格包,解决了这个问题:
\doublerulesepcolor{black}
\begin{tabular}{||l c||}
\doublerulesepcolor{white}
\hline
\rowcolor{black!10}
Column 1 & Column 2 \\ [0.7ex]
\hline\hline
\rowcolor{green!20}
Entry 1 & Entry 2 \\
\hline
\rowcolor{green!25}
Entry 3 & Entry 4 \\
\hline
\end{tabular}
你可以从中获得很多乐趣:
\setlength\arrayrulewidth{2pt}\arrayrulecolor{blue}
\setlength\doublerulesep{2pt}\doublerulesepcolor{yellow}
\begin{tabular}{||l c||}
\hline
\rowcolor{black!10}
Column 1 & Column 2 \\ [0.7ex]
\hline\hline
\rowcolor{green!20}
Entry 1 & Entry 2 \\
\hline
\rowcolor{green!25}
Entry 3 & Entry 4 \\
\hline
\end{tabular}
进一步参考:关联