为什么
\def\y{0}
\def\x{1}
every row no \y column no \x/.style={
/pgfplots/table/@cell content/.add={\cellcolor{pink}}{}, },
不行?
\documentclass[]{article}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotstableset{string type, col sep=comma, header=false}
\pgfplotstableread[]{
a, b, c, d, e, f
h, i, j, k, l, m
n, o, p, q, r, s
t, u, v, w, x, y
}\mytable
\begin{document}
\section{Works}
\def\N{1}
\pgfplotstabletypeset[
every row no \N/.style={before row={\rowcolor{orange}}},
]{\mytable}
\section{Works not}
\def\y{0}
\def\x{1}
\pgfplotstabletypeset[
% Works
%every row no 0 column no 1/.style={
%/pgfplots/table/@cell content/.add={\cellcolor{pink}}{}, },
% Works not:
every row no \y column no \x/.style={
/pgfplots/table/@cell content/.add={\cellcolor{pink}}{}, },
]{\mytable}
\end{document}
答案1
在键中every row no \y column no \x
,紧随其后的空格字符\y
被忽略,因此键看起来像every row no 0column no 1
并且从未被执行。
为了保留该空间,要么\def\y{0 }
要么 都every row no \y\space column no \x
可以。