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}
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
    Oct 29 '20 at 4:31

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.