TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems a very simple question, but I cannot find an answer.

I have a very simple CSV file and I want to make a LaTeX table from it.


-1, 1, -1, 1
2, 4, 6, 8
3, 9, 27, 81

LaTeX file



\pgfplotstabletypeset[col sep=comma]{tiny.csv}


Then I have a table as follows:

 0  1   2   3       <- head row
−1  1  −1   1
 2  4   6   8
 3  9  27  81

I wish the numbers in the head row to begin with 0, not 1. And I don't want to change the file tiny.csv as it will be used by other scripts for experiment. How can I change the head row to '1 2 3 4' from '0 1 2 3'?

share|improve this question
up vote 6 down vote accepted

You can alter the internal PGFPlotstable macro that assigns the numeric column names. Here's a way that introduces a new key first numeric column name=<number> that allows to specify the starting number of the automatic column names. By default it's set to 0 so the normal behaviour isn't changed. If you set first numeric column name=1, the numbering will start with 1:


\pgfplotstableset{first numeric column name/.initial=0}
        \addtocounter{numeric@colname}{\pgfkeysvalueof{/pgfplots/table/first numeric column name}}%


\pgfplotstabletypeset[col sep=comma, first numeric column name=1]{
-1, 1, -1, 1
2, 4, 6, 8
3, 9, 27, 81

share|improve this answer
No wonder I couldn't find that:-) – David Carlisle Mar 19 '13 at 9:27
Isn't adding just 1 to the @cell content more practical with every head row? – percusse Mar 19 '13 at 11:56
@percusse: Depends on what you want to do. That approach wouldn't change the actual column name, so you couldn't refer to the columns using the same numbers. Feel free to add an answer, though. – Jake Mar 19 '13 at 12:10

One option would be to use column name inside the columns style:



\pgfplotstabletypeset[col sep=comma,
columns/0/.style={column name=$1$},
columns/1/.style={column name=$2$},
columns/2/.style={column name=$3$},
columns/3/.style={column name=$4$},


enter image description here

share|improve this answer
Hmm. OK, I can live with this option. Then, I want to generalize this approach so that I can use a for loop. (maybe \foreach?) Is that possible? – Federico Magallanez Mar 19 '13 at 6:19
@FedericoMagallanez see Jake's answer. – Gonzalo Medina Mar 19 '13 at 12:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.