要隐藏带有“-1”的单元格,我使用一种方法
every column/.code={
\ifnum\pgfplotstablecol>0
\pgfkeysalso{postproc cell content/.style={
@cell content={
\fpcompareTF{##1<0}{}{\pgfmathprintnumber[]{##1}}%
}
}}\fi},
到目前为止一切正常。
但如果我将其设置为样式
\pgfplotstableset{
HideMinusOne/.style={...seen above...}
}
这不起作用。
我该怎么办?
顺便说一句:仅与 pgfmath 进行比较不是在某些情况下有效,因为有时会有非常大的数字(“Dim. too large”)
\documentclass[a4paper, landscape=false]{article}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.16}
\usepackage{xfp}
\ExplSyntaxOn
\NewExpandableDocumentCommand{\fpcompareTF}{mmm}
{
\fp_compare:nTF { #1 } { #2 } { #3 }
}
\ExplSyntaxOff
\begin{document}
\section{works}
\pgfplotstabletypeset[
columns/0/.style={string type}, header=false,
col sep=comma,
%HideMinusOne,
every column/.code={
\ifnum\pgfplotstablecol>0
\pgfkeysalso{postproc cell content/.style={
@cell content={
\fpcompareTF{##1<0}{}{\pgfmathprintnumber[]{##1}}%
}
}}\fi},
]{
a, 2, 3, -1, 5, 6,-1
b, 2, -1, 4, 5, 6, -1
c, -1, -1, -1, 5, 6, 1
}
\section{works not}
% Hide '-1' Style =================
\pgfplotstableset{
HideMinusOne/.style={
every column/.code={
\ifnum\pgfplotstablecol>0
\pgfkeysalso{postproc cell content/.style={
@cell content={
\fpcompareTF{##1<0}{}{\pgfmathprintnumber[]{##1}}%
}
}}\fi},
}
}
\pgfplotstabletypeset[
columns/0/.style={string type}, header=false,
col sep=comma,
% HideMinusOne, % <-------------------------- !!!!
]{
a, 2, 3, -1, 5, 6,-1
b, 2, -1, 4, 5, 6, -1
c, -1, -1, -1, 5, 6, 1
}
\end{document}