1

I'm trying to get pgfplotstable to show the header of the columns in my csv file as well. It seems like this should be the default behaviour, and I can't seem to find anyone else having this problem. Here is the MWE:

\documentclass{article}
\usepackage{pgfplotstable}

% The input .csv file.
\begin{filecontents*}{TestPGFPlotsTable.csv}
A,B,C,D
1,5,9,13
2,6,10,14
3,7,11,15
4,8,12,16
\end{filecontents*}

% To add a line above and below the header and table. 
% Using hline instead of booktabs to make MWE
\pgfplotstableset{ 
 every head row/.style={before row=\hline,after row=\hline},
 every last row/.style={after row=\hline}
}

\begin{document}

    % Where is the header??
    \begin{tikzpicture}
        \pgfplotstableset{
          col sep=comma,
        }
        \pgfplotstabletypeset[]{TestPGFPlotsTable.csv}

    \end{tikzpicture}

\end{document}

And here is what the result looks like:

TableWithoutHeader

And the result I want to get.

TableWithHeader

1
  • Short answer is don't use pgfplotstabletypeset in the tikzpicture environment Commented Dec 15, 2019 at 20:29

1 Answer 1

1

Is there a reason why the \pgfplotstabletypeset is within a tikzpicture environment?

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{caption}

% The input .csv file.
\begin{filecontents*}{TestPGFPlotsTable.csv}
A,B,C,D
1,5,9,13
2,6,10,14
3,7,11,15
4,8,12,16
\end{filecontents*}

% To add a line above and below the header and table. 
% Using hline instead of booktabs to make MWE
\pgfplotstableset{
 every head row/.style={before row=\hline,after row=\hline},
 every last row/.style={after row=\hline},
}

\begin{document}

\pgfplotstableset{  
    col sep=comma
    }
\pgfplotstabletypeset{TestPGFPlotsTable.csv}

\begin{center}
\pgfplotstabletypeset{TestPGFPlotsTable.csv}
\end{center}

\begin{table}[htb]
    \centering
    \caption{My caption}
    \pgfplotstabletypeset{TestPGFPlotsTable.csv}
\end{table}
\end{document}

enter image description here

2
  • Thanks! That was very silly. Commented Dec 15, 2019 at 20:27
  • @FortuneCookie You're welcome! Not silly at all :):):)
    – CarLaTeX
    Commented Dec 15, 2019 at 20:31

You must log in to answer this question.

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