# pgfplotstable multiple columns same heading name

I have some x y data that I wish to typeset using pgfplotstable, rather than having say 9 rows of 2 columns, I would like to have 3 rows, with 3 sets of xy pairs.

Consider the following:

\documentclass{article}
\usepackage{pgfplotstable,filecontents}

\begin{filecontents}{mydata.dat}
x y x y x y
0 0 3 3 6 6
1 1 4 4 7 7
2 2 5 5 8 8
\end{filecontents}

\begin{document}
\pgfplotstableset{
columns/x/.style={
column name={$X$},
},
columns/y/.style={
column name={$Y$},
},
}
\end{document}


Which produces the following output:

Clearly columns 2 to 6, in this MWE are not being typeset as desired. I am aware that this can be resolved by declaring unique column style for each column as follows:

\pgfplotstableset{
columns/A/.style={
column name={$X$},
},
columns/B/.style={
column name={$Y$},
},
columns/C/.style={
column name={$X$},
},
columns/D/.style={
column name={$Y$},
},
columns/E/.style={
column name={$X$},
},
columns/F/.style={
column name={$Y$},
},
}


Also slightly modifying the input data structure:

\begin{filecontents}{mydata.dat}
A B C D E F
0 0 3 3 6 6
1 1 4 4 7 7
2 2 5 5 8 8
\end{filecontents}


Producing the desired format, with column names [X Y X Y X Y]:

But I am trying to avoid having to effectively re-type the same code over and over. How can I use the same pgfplotstableset column style, for multiple columns in the same table.

• So you want the title row to read X Y X Y X Y, correct?
– Jake
Oct 24 '13 at 19:39
• Yes. Exactly... Oct 24 '13 at 19:39
• @Jake, I have updated the question to reflect this. Oct 24 '13 at 19:42

You can use the every odd column and every even column styles for this (noting that the column numbering starts at zero):

\documentclass{article}
\usepackage{pgfplotstable,filecontents}

\begin{filecontents}{mydata.dat}
x y x y x y
0 0 3 3 6 6
1 1 4 4 7 7
2 2 5 5 8 8
\end{filecontents}

\begin{document}
\pgfplotstableset{
every even column/.style={
column name={$X$}
},
every odd column/.style={
column name={$Y$},

• @ADP: Good point. For rows, there's the every nth row style, but for columns, that's not implemented yet. Might be worth opening a feature request for that.