I am trying to construct a table in which some columns are displayed normally and others are greyed out. I am using booktabs rules throughout the document and need this table to be formatted consistently with the others.
I can easily grey out the content of the relevant columns. However, I'm having trouble greying out the rules while maintaining vertical alignment. I can use \cmidrule with a specific width (e.g. \heavyrulewidth or lightrulewidth to emulate toprule/boittomrule or midrule), but using \arrayrulecolor{} changes the vertical spacing.
How can I understand and solve the problem?
Initially, I thought that Werner's answer at https://tex.stackexchange.com/a/32366/ held the key. However, I do not really understand what is happening and have been unable to adapt it successfully. I tried drawing a regular rule with the \specialrule and then drawing a partial rule over the top in grey, but this did not work out any better than any of my other attempts.
Here are the results of my current experiments. The table on the left should look just like the one on the right, except that the second column should be greyed out. Needless to say, it is not supposed to look like Jacob's ladder.
Code:
\documentclass{article}
\usepackage{booktabs,array}
\usepackage[table]{xcolor}
\begin{document}
\begin{tabular}{c>{\color{gray}\arraybackslash}c}
% \toprule
\cmidrule[\heavyrulewidth]{1-1}%
\arrayrulecolor{gray}%
\cmidrule[\heavyrulewidth]{2-2}%
\arrayrulecolor{black}%
Black Header & Grey Header \\
% \midrule
\cmidrule[\lightrulewidth]{1-1}%
\arrayrulecolor{gray}%
\cmidrule[\lightrulewidth]{2-2}%
\arrayrulecolor{black}%
Black content & Grey content \\
\specialrule{\lightrulewidth}{0pt}{-\lightrulewidth}% ateb Werner: https://tex.stackexchange.com/a/32366/
\arrayrulecolor{gray}%
\cmidrule[\lightrulewidth]{2-2}%
\arrayrulecolor{black}%
Black content & Grey content \\
Black content & Grey content \\
\cmidrule(lr){1-1}
Black content & Grey content \\
\arrayrulecolor{gray}%
\cmidrule(lr){2-2}
\arrayrulecolor{black}%
Black content & Grey content \\
\cmidrule(lr){1-1}%
\arrayrulecolor{gray}%
\cmidrule(lr){2-2}
\arrayrulecolor{black}%
Black content & Grey content \\
% \bottomrule
\cmidrule[\heavyrulewidth]{1-1}%
\arrayrulecolor{gray}%
\cmidrule[\heavyrulewidth]{2-2}%
\arrayrulecolor{black}%
\end{tabular}
\begin{tabular}{cc}
\toprule
Black Header & Grey Header \\
\midrule
Black content & Grey content \\
\cmidrule[\lightrulewidth]{1-2}%
Black content & Grey content \\
Black content & Grey content \\
\cmidrule(lr){1-1}
Black content & Grey content \\
\cmidrule(lr){2-2}
Black content & Grey content \\
\cmidrule(lr){1-1}%
\cmidrule(lr){2-2}
Black content & Grey content \\
\bottomrule
\end{tabular}
\end{document}
Note: For various reasons, it will cause considerable complications if I have to recode the other tables. In particular, the typeset version of those tables needs to remain identical in the PDF to avoid being incorrectly marked as changed. I will be using latexdiff to mark changes, so it would be easiest if their coding stayed the same too, but I could correct for this manually, if necessary.
EDIT
To clarify, the problem is not just the widths of the rules, but also the spacing inserted above and below them in a booktabs table.
I could do this:
\begin{tabular}{c}
\toprule
Black Header \\
\midrule
Black content \\
\cmidrule[\lightrulewidth]{1-1}
Black content \\
Black content \\
\cmidrule(lr){1-1}
Black content \\
\arrayrulecolor{white}\cmidrule(lr){1-1}
Black content \\
\arrayrulecolor{black}
\cmidrule(lr){1-1}
Black content \\
\bottomrule
\end{tabular}%
{\color{gray}%
\begin{tabular}{c}
\toprule
Grey Header \\
\midrule
Grey content \\
\cmidrule[\lightrulewidth]{1-1}
Grey content \\
Grey content \\
\arrayrulecolor{white}\cmidrule(lr){1-1}
Grey content \\
\arrayrulecolor{gray}
\cmidrule(lr){1-1}
Grey content \\
\cmidrule(lr){1-1}
Grey content \\
\bottomrule
\end{tabular}}
\begin{tabular}{c>{\color{gray}\arraybackslash}c}
\toprule
Black Header & Grey Header \\
\midrule
Black content & Grey content \\
\cmidrule[\lightrulewidth]{1-2}%
Black content & Grey content \\
Black content & Grey content \\
\cmidrule(lr){1-1}
Black content & Grey content \\
\cmidrule(lr){2-2}
Black content & Grey content \\
\cmidrule(lr){1-1}%
\cmidrule(lr){2-2}
Black content & Grey content \\
\bottomrule
\end{tabular}
This gives the correct output - or almost the correct output, at any rate. However, it destroys the structure of the table, would not be easy to maintain or adapt and is extremely error prone. So I'd rather not, if I can help it.
I've been trying to decipher the code for colortbl.sty and booktabs.sty in order to try to figure out what exactly adds the space and what, if anything, I might be able to do about it. However, I feel as if I'm wrapping myself in a giant roll of sellotape which has gone wild after the stress of seasonal gift-wrapping.







\tikzmarks inside the table and overlay the column with a semi-transparent white rectangle? – samcarter_is_at_topanswers.xyz Dec 29 '16 at 12:35