TransWikia.com

pgfkeys / pgfplotstable: How to get (and save) row- and column-number of a cell with special content

TeX - LaTeX Asked on December 17, 2020

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}

One Answer

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

defliteralx{x}

begin{document}
pgfplotstabletypeset[
postproc cell content/.code={%
  deftemp{#1}%
  ifxtempliteralx
    xdefremembercol{pgfplotstablecol}%
    xdefrememberrow{pgfplotstablerow}%
  fi
}]{mytable}

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

Correct answer by Henri Menke on December 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP