
No exemplo a seguir, estou tentando compor uma tabela usando pgfplotstable
uma every even row
regra. Existe uma maneira de desativá-lo para algumas colunas? Ou, alternativamente, existe uma maneira de substituir a cor das linhas de algumas colunas?
\documentclass{article}
\usepackage{colortbl}
\usepackage{listings}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\pgfplotstabletypeset[
columns/Z/.style={
column name={},
assign cell content/.code={
\ifnum\pgfplotstablerow=0
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\multirow{4}{*}{##1}}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
},
},
postproc cell content/.code={
\ifodd\pgfplotstablerow\relax
\else
% ah - an even row number.
\ifnum\pgfplotstablecol>0
% ah - introduce a cell color:
\pgfkeysalso{@cell content={\cellcolor[gray]{0.9}#1}}%
\fi
\fi
},
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
debug,
columns/a/.style={column name={A},
column type={S[scientific-notation=engineering, round-precision=2, round-mode=places, table-format=2.2e1]}, string type,
},
row sep=\\, col sep=&]{% here: inline data in tabular format:
Z & a & b \\
data & 1.43 & 2 \\
& 3.23 & 4 \\
& 51231.2 & 6 \\
& 0.007 & 8 \\
}
\end{document}
O que eu gostaria é que os "dados" fossem exibidos corretamente, sem cinza no arquivo multicolumn
.
EDIT: mudei meu MWE de acordo com a resposta, como você pode ver, algo está errado com o siunitx
pacote agora. Isso ocorre por causa do uso #1
no postproc
, mas não sei como consertar isso.
Responder1
Aparentemente, \rowcolor
e \multirow
não funcionam juntos no bom sentido.
Experimentei mudar debug
para pgfplotstable
verificar se esse é realmente o caso. Uma solução parece usar \cellcolor
paratodocélula com cor de fundo.
Eu costumava postproc cell content
inserir as \cellcolor
instruções apropriadas (e incorporei every even row
nesse estilo também - aparentemente, every even row
e postproc cell contents
não podem ser combinadas).
Aqui está a solução:
\documentclass{article}
\usepackage{colortbl}
\usepackage{listings}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\thispagestyle{empty}
\pgfplotstabletypeset[
columns/Z/.style={
column name={},
assign cell content/.code={
\ifnum\pgfplotstablerow=0
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\multirow{4}{*}{##1}}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
},
},
postproc cell content/.code={
\ifodd\pgfplotstablerow\relax
\else
% ah - an even row number.
\ifnum\pgfplotstablecol>0
% ah - introduce a cell color:
\pgfkeysalso{@cell content={\cellcolor[gray]{0.9}#1}}%
\fi
\fi
},
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
debug,
row sep=\\, col sep=&]{% here: inline data in tabular format:
Z & a & b \\
data & 1 & 2 \\
& 3 & 4 \\
& 5 & 6 \\
& 7 & 8 \\
}
\begin {tabular}{ccc}%
\toprule &a&b\\\midrule %
\rowcolor [gray]{0.9}\multirow {4}{*}{data}&\pgfutilensuremath {1}&\pgfutilensuremath {2}\\%
&\pgfutilensuremath {3}&\pgfutilensuremath {4}\\%
&\cellcolor [gray]{0.9}\pgfutilensuremath {5}&\cellcolor [gray]{0.9}\pgfutilensuremath {6}\\%
&\pgfutilensuremath {7}&\pgfutilensuremath {8}\\\bottomrule %
\end {tabular}%
\end{document}