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}
2
  • What is your purpose with these two numbers?
    – user213378
    Aug 16, 2020 at 19:55
  • Good question. The idea is to use these number for highlight rows / cols ( tex.stackexchange.com/questions/557748/… ). I tried to use @Henri Menke solution there without succes.
    – cis
    Aug 17, 2020 at 18:26

1 Answer 1

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}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.