3

A relatively new to PGFPlotsTables but find it very useful for formatting large tables and pulling in external data in LaTeX. However, I'm running into the following issue. When I want to color the header row of a table, the horizontal (black) lines seem to be over-ridden by the fill color.

Here is the LaTeX code

usepackage{pgfplots}
\usepackage{pgfplotstable} 
\usepackage{colortbl}

 \definecolor{myyellow1}{RGB}{255, 255, 219}

\begin{table}[h]

\centering

\pgfplotstabletypeset[
col sep=&,      % specify the column separation character
row sep=\\, % specify the row separation character
columns/E/.style={string type},     % specify the type of data in the designated column
column type = c,    % centering everything in each column
every head row/.style={before row=\hhline{-----}, after row=\hhline{-----}},    % style the first row
every last row/.style={after row=\hline},   % style the last row
every first column/.style={column type/.add={|}{|}},
type/.add={|}{|}}, then column B would have double vertical lines
columns/C/.style = {column type/.add={|}{|}}, 
every last column/.style={column type/.add={|}{|}},
every head row/.style={before row={\rowcolor{myyellow1}}}
]
{
A & B & C & D & E \\
1 & 10 & 0.1 & 1000 & 2011-01-01 \\
2 & 20 & 0.2 & 2000 & 2012-02-02 \\
3 & 30 & 0.3 & 3000 & 2013-03-03 \\
4 & 40 & 0.4 & 4000 & 2014-04-04 \\
5 & 50 & 0.5 & 5000 & 2015-05-05 \\
}
\caption{This is an example of a table using PGFPlotsTable.  I used inline    data for this one.}
\label{fig:sample_table_1}
\end{table}

This produces a table which looks like:

Table output from code above

I have heard that using \hhline command can help here, but have not been able to get it to work (I am using \hhline in the sample code to define the header row).

thanks!

4

Your problem isn't really caused by the row colour. The problem is that you do every head row/.style=.. twice. The stylename/.style syntax will override whatever previous definition that style had. Add the lines and rowcolour at the same time.

enter image description here

\documentclass{article}

\usepackage{pgfplotstable} 
\usepackage{colortbl}

 \definecolor{myyellow1}{RGB}{255, 255, 219}
\begin{document}
\begin{table}[h]

\centering

\pgfplotstabletypeset[
col sep=&,      % specify the column separation character
row sep=\\, % specify the row separation character
columns/E/.style={string type},     % specify the type of data in the designated column
column type = c,    % centering everything in each column
every last row/.style={after row=\hline},   % style the last row
every first column/.style={column type/.add={|}{|}},
type/.add={|}{|}, then column B would have double vertical lines
columns/C/.style = {column type/.add={|}{|}}, 
every last column/.style={column type/.add={|}{|}},
every head row/.style={before row={\hline\rowcolor{myyellow1}},after row=\hline}
]
{
A & B & C & D & E \\
1 & 10 & 0.1 & 1000 & 2011-01-01 \\
2 & 20 & 0.2 & 2000 & 2012-02-02 \\
3 & 30 & 0.3 & 3000 & 2013-03-03 \\
4 & 40 & 0.4 & 4000 & 2014-04-04 \\
5 & 50 & 0.5 & 5000 & 2015-05-05 \\
}
\caption{This is an example of a table using PGFPlotsTable.  I used inline    data for this one.}
\label{fig:sample_table_1}
\end{table}
\end{document}
  • Torbjørn T. - thank you so much. Clearly I have a lot to learn about PGFPlots and syntax. That seemed to work. – G. Khanna Jun 28 '16 at 23:52

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.