
pgfplotstable
次の例では、ルールを使用してテーブルをタイプセットしようとしていますevery even row
。特定の列に対してルールを無効にする方法はありますか? または、特定の列の行の色を上書きする方法はありますか?
\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}
私が望んでいるのは、「データ」がグレー表示されずに正しく表示されることですmulticolumn
。
編集: 回答に従って MWE を変更しましたが、ご覧のとおり、パッケージに何か問題があります。 これは で をsiunitx
使用しているためですが、修正方法がわかりません。#1
postproc
答え1
どうやら、\rowcolor
良い\multirow
意味で協力し合っていないようです。
debug
私はスイッチを実際に試してpgfplotstable
、これが事実であることを確認しました。解決策としては\cellcolor
、毎背景色のセル。
postproc cell content
以前は適切な指示を挿入していました(そして、そのスタイルにも\cellcolor
組み込んでいましたが、どうやら組み合わせることはできないようです) 。every even row
every even row
postproc cell contents
解決策は次のとおりです。
\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}