Da pgfplotstable hier selten verwendet: https://tex.stackexchange.com/questions/456576/pgfplotstable-how-to-use-pgfplotstablename-for-pgfplotstablegetelem


Wie kann \pgfplotstablename an der Stelle benutzen

\pgfplotstablegetelem{0}{[index]1}\of\TestTable anstelle von \TestTable?

enter image description here

MWE:

Öffne in Overleaf
\documentclass[border=5pt]{standalone}
\usepackage{pgfplotstable}

\pgfplotstableread[header=false]{
A   B
1   2
0   2
1   0
0   2
0   2
1   0
}\TestTable

\begin{document}

\pgfplotstabletypeset[string type,
every head row/.style={output empty row},% keinen header anzeigen
% works  funny (with speech mark...)
columns/0/.style = {
string replace={0}{\pgfplotstablename\pgfplotsretval},
},
% works not
columns/1/.style = {
string replace={0}{%\pgfplotstablename % \pgfplotsretval
\pgfplotstablegetelem{0}{[index]1}\of\TestTable %<-- use tablename here
\pgfplotsretval
}
},
]{\TestTable}

%Test:  \pgfplotstablegetelem{0}{[index]0}\of\TestTable \pgfplotsretval
%\pgfplotstablegetelem{0}{[index]1}\of\TestTable \pgfplotsretval
\end{document}

gefragt 22 Okt '18, 20:42

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%

bearbeitet 24 Okt '18, 17:14

Geht nicht einfach mit csname oder so? Ich habe es nicht hinbekommen.

(26 Okt '18, 17:17) cis

Aja, das lustige Anführungszeichen wird zum backslash durch \usepackage[T1]{fontenc}; aber beim Problem hilft das auch nicht :(

(26 Okt '18, 17:45) cis

Wenn ich mir mit \show\pgfplotstablename die Definition von \pgfplotstablename ansehe, dann steht im Log

> \pgfplotstablename=macro:
->\TestTable .

Das heißt \pgfplotstablename wird nach einem Expansionschritt zu \TestTable. Nun geht es nur noch darum diesem Expansionsschritt irgendwie zu forcieren. Dies kann man entweder mit \edef or in LuaTeX und ab TeX Live 2019 mit \expanded machen.

Öffne in Overleaf
\expanded{%
  \noexpand\pgfplotstablegetelem{0}{[index]1}\noexpand\of\expandafter\noexpand\pgfplotstablename
}%

Das vorangestellte \noexpand vor jedem Makro verhindert die Expansion. Die Konstruktion \expandafter\noexpand\pgfplotstablename führt dazu, dass TeX zunächst über \noexpand drüber springt und \pgfplotstablename einmalig expandiert. Danach steht dann dort \noexpand\TestTable und alles ist gut.

Öffne in Overleaf
\documentclass[border=5pt]{standalone}
\usepackage{pgfplotstable}

\pgfplotstableread[header=false]{
A   B
1   2
0   2
1   0
0   2
0   2
1   0
}\TestTable

\begin{document}

\pgfplotstabletypeset[string type,
every head row/.style={output empty row},% keinen header anzeigen
% works  funny (with speech mark...)
columns/0/.style = {
  string replace={0}{\pgfplotstablename\pgfplotsretval},
},
% works not
columns/1/.style = {
  string replace={0}{%\pgfplotstablename % \pgfplotsretval
    \expanded{%
      \noexpand\pgfplotstablegetelem{0}{[index]1}\noexpand\of\expandafter\noexpand\pgfplotstablename
    }%
    \pgfplotsretval
  }
},
]{\TestTable}

% Test:  \pgfplotstablegetelem{0}{[index]0}\of\TestTable \pgfplotsretval
% \pgfplotstablegetelem{0}{[index]1}\of\TestTable \pgfplotsretval
\end{document}

alt text

Permanenter link

beantwortet 18 Feb '19, 07:41

Henri's gravatar image

Henri
15.7k133943
Akzeptiert-Rate: 46%

bearbeitet 18 Feb '19, 09:27

Aja, sehr gut. Also bei mir läuft das nur mit LuaLaTeX durch (habe TeXLive2019) - ist das richtig?

(18 Feb '19, 14:34) cis

@cis Bist Du sicher, dass Du TeX Live 2019 hast? Laut Timeline findet der finale Source commit erst in 4 Tagen statt, pretest startet am 1. März, die Release erfolgt am 30. April. Und ja, man braucht dafür \expanded, das es als Primitiv derzeit nur in LuaTeX gibt. Schreibt Henri ja auch ausdrücklich. Also: Ja, Du brauchst LuaLaTeX.

(18 Feb '19, 15:20) saputello

Jetzt, da ich nachgeschaut habe, musste ich feststellen, dass ich nur TeXLive2018 habe. :)

(18 Feb '19, 17:48) cis
Deine Antwort
Vorschau umschalten

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

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×39

gestellte Frage: 22 Okt '18, 20:42

Frage wurde gesehen: 3,785 Mal

zuletzt geändert: 18 Feb '19, 17:48