
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}