I use same table format for several data files, so I have written a macro named \tableMacro
.
The problem is: I need to include different columns in different tables. I want to parametrize columns={}
property of \pgfplotstabletypeset
.
\documentclass{article}
\usepackage{pgfplotstable}
% #1 name of data file
% #2 name of columns
\newcommand{\tableMacro}[2]{
\pgfplotstableread{#1}\table
\pgfplotstabletypeset[columns={ColA, ColB}]\table % This works, but
%\pgfplotstabletypeset[columns={#2}]\table % I need this line to work
}
\begin{document}
\tableMacro{table.txt}{ColA, ColB} % This works.
\def\colnames{ColA, ColB}
\tableMacro{table.txt}{\colnames} % However, I need this type of parameter passing
% since there are several tables that
% include same set of columns
\end{document}
Contents of table.txt
:
ColA ColB
2 23.2
5 67.8
3 11.4