Xpost: https://tex.stackexchange.com/questions/559044/pgfplotstable-how-to-use-the-read-out-row-column-value-for-styles


Ich möchte eine Zeile (Spalte) highlighten, sofern sie speziellen Inhalt enthält, z.B. 'x'.

Ich habe
every nth row={\rememberrow}{before row=\rowcolor{orange}}, % WORKS NOT!
aus der Lösung versucht.

Code, hier editierbar zum Übersetzen:
\xdef\remembercol{\pgfplotstablecol}%
\xdef\rememberrow{\pgfplotstablerow}%
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

expandiert korrekt nach pgfplotstabletypeset, aber nicht währenddessen.

Wie kann man das lösen?

Code, hier editierbar zum Übersetzen:
\documentclass[]{article}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotstableset{string type, col sep=comma, header=false}
\pgfplotstableread[]{
a, b, c
d, e, f
g, x, i
j, k, l
}\mytable
\def\literalx{x}
\begin{document}
\pgfplotstabletypeset[
postproc cell content/.code={%
\def\temp{#1}%
\ifx\temp\literalx
\xdef\remembercol{\pgfplotstablecol}%
\xdef\rememberrow{\pgfplotstablerow}%
\fi
},
%every nth row={\rememberrow}{before row=\rowcolor{orange}}, % WORKS NOT!
]{\mytable}
\textbf{Works:} x is in row no.~\rememberrow\ and column no.~\remembercol.
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

gefragt 18 Aug '20, 15:49

cis's gravatar image

cis
9.5k95460491
Akzeptiert-Rate: 29%


Mit savebox und newcommand:

PS: Falls es jmd. einfacher lösen kann, gerne.

alt text

Code, hier editierbar zum Übersetzen:
\documentclass[]{article}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotstableset{string type, col sep=comma, header=false}
\pgfplotstableread[]{
a, b, c
d, e, f
g, x, i
j, k, l
}\mytable
\colorlet{CellColor}{red}
\colorlet{RowColor}{orange}
\colorlet{ColColor}{pink}
\def\literalx{x}
%\def\remembercol{-1}
%\def\rememberrow{-1}
\begin{document}
\pgfplotstableset{ myhighlights/.style={} }
\newcommand\MyTable{%
\pgfplotstabletypeset[myhighlights,
postproc cell content/.code={%
\def\temp{##1}% <--- ! '##', not '#'
\ifx\temp\literalx
\xdef\remembercol{\pgfplotstablecol}%
\xdef\rememberrow{\pgfplotstablerow}%
% Highlight Cell:
\pgfkeysalso{ @cell content/.add={\cellcolor{CellColor}}{} }%
\fi
},
]{\mytable}%
}
\newsavebox{\Mybox}
\savebox{\Mybox}{\MyTable}
\section{Raw Table}
\usebox{\Mybox}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Permanenter link

beantwortet 18 Aug '20, 17:20

cis's gravatar image

cis
9.5k95460491
Akzeptiert-Rate: 29%

bearbeitet 18 Aug '20, 17:28

Deine Antwort
[Vorschau ausblenden]

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Frage-Themen:

×39
×7

gestellte Frage: 18 Aug '20, 15:49

Frage wurde gesehen: 4,374 Mal

zuletzt geändert: 18 Aug '20, 17:28

Willkommen, erstes Mal hier? Schau mal unter FAQ!

×