Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to create a table using the pgfplotstable package. I've managed to get 95% of the formatting I want using the following:

\usepackage{pgfplotstable}
\usepackage{booktabs}

% global settings
\pgfplotstableset{
after row={\hline},
every head row/.style={
before row={
\rowcolor{lightgray}
\noalign{\hrule height \tableborder}
},
after row={
\hline
},
},
every last row/.style={
after row=\noalign{\hrule height \tableborder}
},
col sep = &,
row sep=\\,
% column type/.add={}{\vrule width \tableborder},
every col no 1/.style={ column type/.add={|}{} },
every col no 2/.style={ column type/.add={|}{} },
every col no 3/.style={ column type/.add={|}{} },
every col no 4/.style={ column type/.add={|}{} },
every col no 5/.style={ column type/.add={|}{} },
every first column/.style={
column type/.add={!{\vrule width \tableborder}}{}
},
every last column/.style={
column type/.add={}{!{\vrule width \tableborder}}
},
string type,
}

Even though there are many every col no, which I don't like, it still works almost perfectly. The only thing I'm missing is to put the header's text in bold. If I try to force it to bold in the actual table it doesn't compile, and I'm not able to change the content of the row to bold. So with this code I ask 2 questions:

1 - Hown can I get the header's text to be bold?

2 - Does anyone know of a better way to do what the every col no commands do, but in a more general way?

EDIT: Here is the complete code now (It was missing a def). And bellow the initial config is the code to generate the table.

\usepackage{pgfplotstable}
\usepackage{booktabs}
\def\tableborder{1.5pt}

% global settings
\pgfplotstableset{
after row={\hline},
every head row/.style={
before row={
\rowcolor{lightgray}
\noalign{\hrule height \tableborder}
},
after row={
\hline
},
},
every last row/.style={
after row=\noalign{\hrule height \tableborder}
},
col sep = &,
row sep=\\,
% column type/.add={}{\vrule width \tableborder},
every col no 1/.style={ column type/.add={|}{} },
every col no 2/.style={ column type/.add={|}{} },
every col no 3/.style={ column type/.add={|}{} },
every col no 4/.style={ column type/.add={|}{} },
every col no 5/.style={ column type/.add={|}{} },
every first column/.style={
column type/.add={!{\vrule width \tableborder}}{}
},
every last column/.style={
column type/.add={}{!{\vrule width \tableborder}}
},
string type,
}

With this the table is generated. Note that this is only a portion of the actual document and the table is a fake.

\pgfplotstabletypeset{
person & singEnglish & singGaeilge & pluralEnglish & pluralGaeilge\\
1st & at me & agam & at us & againn\\
2st & at you & agat & at you & agaibh\\
3st & at him & aige & at them & acu\\
& at her & aici & &\\
}

Here is the result. I want the text in the header to be bold, and the column lines to go all the way on all columns enter image description here

EDIT NÂș2:

Ok now here is a sample of a compilable code (stand alone), but now it is refusing to paint the header row. Please help.

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\usepackage{pgfplotstable}
\usepackage{booktabs}
\def\tableborder{1.5pt}

% global settings
\pgfplotstableset{
    after row={\hline},
    every head row/.style={
        before row={
        \noalign{\hrule height 1.5pt}
        },
        after row={
            \hline
        },  
    },
    every last row/.style={
        after row=\noalign{\hrule height 1.5pt}
    },
    col sep = &,
    row sep=\\,
    % column type/.add={}{\vrule width \tableborder},
    every col no 1/.style={ column type/.add={|}{} },
    every col no 2/.style={ column type/.add={|}{} },
    every col no 3/.style={ column type/.add={|}{} },
    every col no 4/.style={ column type/.add={|}{} },
    every col no 5/.style={ column type/.add={|}{} },
    every first column/.style={
        column type/.add={!{\vrule width 1.5pt}}{}
    },
    every last column/.style={
        column type/.add={}{!{\vrule width 1.5pt}}
    },
    string type,
}

\begin{document}
\pgfplotstabletypeset{
1 & 2 & 4 \\
3 & 4 & 9 \\
}
\end{document}
share|improve this question
2  
Can you edit your question to show a complete compilable example rather than a code fragment? See minimal working example (MWE). – Alan Munn Feb 20 at 17:55
@AlanMunn I'm trying to do that. But I'm doing so many changes in the document that it doesn't compile anymore. – morcillo Feb 20 at 18:13
@AlanMunn And I have no idea anymore where things are going to hell. – morcillo Feb 20 at 18:13
So start small, and work your way up. This way you can more easily identify where things have gone wrong. If you get to a point where you have a small change that causes an error, you can post that document and then people can help you. There's not much incentive for people here to do that if you won't yourself. – Alan Munn Feb 20 at 18:32
1  
@morcillo: It's best if you make a complete minimal example document, starting from \documentclass. It doesn't compile for me if I put it into a document, there seem to be some packages missing. – Jake Feb 20 at 19:15
show 4 more comments

1 Answer

Ok this isn't a good solution, I really don't like it since it's really speciffic and the intention was to make things easier for the user, but anyway, here it is:

\pgfplotstabletypeset
[columns/col1/.style{column name=\textbf{col1}},
columns/col2/.style{column name=\textbf{col2}},
columns/col3/.style{column name=\textbf{col3}},
columns/col4/.style{column name=\textbf{col4}},
columns/col5/.style{column name=\textbf{col5}}
]{
col1 & col2 & col3 & col4 & col5 \\
1st & at me & agam & at us & againn \\
2st & at you & agat & at you & agaibh \\
3st & at him & aige & at them & acu \\
& at her & aici & & \\
}
share|improve this answer

Your Answer

 
discard

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.