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

  • Short answer is don't use pgfplotstabletypeset in the tikzpicture environment – FortuneCookie Dec 15 '19 at 20:29
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

| improve this answer | |
  • Thanks! That was very silly. – FortuneCookie Dec 15 '19 at 20:27
  • @FortuneCookie You're welcome! Not silly at all :):):) – CarLaTeX Dec 15 '19 at 20: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.