0

I have a cell with special content, say 'x'.
I could find 'x' with string replace.
But how can I get and save the row- and the column-number of that cell? With \pgfplotstablerow and \pgfplotstablecol?

enter image description here

\documentclass[]{article}
\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

\begin{document} \pgfplotstabletypeset[ string replace={x}{x %\pgfkeysgetvalue{\pgfplotstablerow}{\rowno} % works not %\pgfkeysgetvalue{\pgfplotstablecol}{\colno} % not that easy } ]{\mytable}

x is in row no. ? and column no. ? \end{document}

cis
  • 8,073
  • 1
  • 16
  • 45
  • What is your purpose with these two numbers? –  Aug 16 '20 at 19:55
  • Good question. The idea is to use these number for highlight rows / cols ( https://tex.stackexchange.com/questions/557748/pgfplotstable-how-to-highlight-row-and-column-of-a-cell-with-special-content ). I tried to use @Henri Menke solution there without succes. – cis Aug 17 '20 at 18:26

1 Answers1

2

This is pretty close to a duplicate of this question of yours on TeXwelt, even though you never accepted my answer:

pgfplotstable: Auf 'column name' mit 'pgfkeysgetvalue' zugreifen

https://texwelt.de/fragen/23473

At least in my answer I showed the principle of how this could be done in general, so it comes as no surprise that I will again use postproc cell content to access the cell content to perform the comparison.

\documentclass[]{article}
\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 }]{\mytable}

x is in row no.~\rememberrow\ and column no.~\remembercol. \end{document}

Henri Menke
  • 109,596
  • Ok thx, that works fine here. I tried to solve https://tex.stackexchange.com/questions/557748/pgfplotstable-how-to-highlight-row-and-column-of-a-cell-with-special-content with that. I think this should be possible. Could you have a look on it? – cis Aug 17 '20 at 12:56