0

I have a table

\pgfplotstableread[col sep=comma]{
1,2,3,4,5,6,7
}\mytable

with columns 0,1,...,6.

Why can't I say \def\List{0,3,5} and then

\pgfplotstabletypeset[
columns={\List}    %    Works not
]{\mytable}

What do I have to do?

enter image description here

\documentclass[a4paper]{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.17,
every head row/.style={after row=\hline},
}

\pgfplotstableread[col sep=comma]{
1,2,3,4,5,6,7
}\mytable
\begin{document}
\section{Main Table}
\pgfplotstabletypeset[]{\mytable}

\section{Works}
\pgfplotstabletypeset[columns={0,3,5}]{\mytable}

\section{List works not}
\def\List{0,3,5}

\pgfplotstabletypeset[
%columns=\List        %   Works not 
%columns={\List}    %    Works not
]{\mytable}
\end{document}

1 Answer 1

2

This is what the /.expanded key is for.

\documentclass[a4paper]{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.17,
every head row/.style={after row=\hline},
}

\pgfplotstableread[col sep=comma]{
1,2,3,4,5,6,7
}\mytable
\begin{document}
\section{Main Table}
\pgfplotstabletypeset[]{\mytable}

\section{Works}
\pgfplotstabletypeset[columns={0,3,5}]{\mytable}

\section{List works not}
\def\List{0,3,5}

\pgfplotstabletypeset[
columns/.expanded=\List        %   Works
]{\mytable}
\end{document}
1
  • TYVM! This helps me a lot!
    – cis
    Commented Oct 29, 2020 at 4:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .