我咨询了文档,但我找不到办法。如果我尝试,我的代码就会崩溃。
问题:我可以将行标题放在表格的底部吗?
问题可能我应用的是自定义格式。
梅威瑟:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{pgfplotstable}
\pgfplotstableset{
color cells/.style={
col sep=comma,
string type,
postproc cell content/.code={%
\pgfkeysalso{@cell content=\rule{0cm}{2.4ex}%
\pgfmathtruncatemacro\number{##1}%
\ifnum\number<0
\cellcolor{red!-##1}##1
\else
\cellcolor{green!##1}##1
\fi
}},
columns/x/.style={
column name={},
postproc cell content/.code={}
}
}
}
\begin{document}
\begin{table}\caption{Correlation or something}
\centering
\pgfplotstabletypeset[color cells]{
x,a,b,c,d
a,90,-10.5,0,0
b,0,80,10,-10
c,0,0,-95,5
d,0,10,-5,-85
}
\end{table}
\end{document}
期望输出:
a 90 -10.5 0 0
b 0 80 10 -10
c 0 0 -95 5
d 0 10 -5 -85
a b c d
答案1
要删除,head row
您可以使用output empty row
。every last row
您可以将标题添加到最后一行(此处手动添加),也许有人可以帮助您找到更好的解决方案。但它有效,如果我找到更好的解决方案或有人添加了有用的评论,我会编辑我的答案。
every head row/.style={
output empty row,
},
every last row/.style={
after row={& a & b & c &d\\}
}
结果:
梅威瑟:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{pgfplotstable}
\pgfplotstableset{
color cells/.style={
col sep=comma,
string type,
postproc cell content/.code={%
\pgfkeysalso{@cell content=\rule{0cm}{2.4ex}%
\pgfmathtruncatemacro\number{##1}%
\ifnum\number<0
\cellcolor{red!-##1}##1
\else
\cellcolor{green!##1}##1
\fi
}},
columns/x/.style={
column name={},
postproc cell content/.code={}
},
%%%% added
every head row/.style={
output empty row,
},
every last row/.style={
after row={
& a & b & c &d\\
}
}
%%%%%%%%%%%%5
}
}
\begin{document}
\begin{table}\caption{Correlation or something}
\centering
\pgfplotstabletypeset[color cells]{
x,a,b,c,d
a,90,-10.5,0,0
b,0,80,10,-10
c,0,0,-95,5
d,0,10,-5,-85
}
\end{table}
\end{document}