Using Hashtag in macro

I had a problem putting the column headers in bold (in a table of course) using pgfplotstable. You can see the problem here I found a way to work arround that. It isn't generic as I wanted it to be, but at least I know there is a way to do it.

The only thing I had to do was to add options to the table when creating it, just like this:

\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 & & \\
}


As you can see it's not the best way to do things, especially when you're new to latex and trying to introduce people to latex, people who've never used latex before. That's the reason why I wanted to create a macro for all those options so that the others should simply add \mymacro(column1name, column2name, ...) to the side of the \pgfplotstabletypeset to make everything easier.

I tried this:

\newcommand\mymacro[3]{    % 3 is just an example, I did \mymacroone .. two ..                    %etc in order to be able to apply the same concept in different situations
columns/#1/.style{column name=\textbf{#1}},
columns/#2/.style{column name=\textbf{#2}},
columns/#3/.style{column name=\textbf{#3}}
}


But this jut generates an error and (can't use # in horizontal mode) doesn't compile. Does anyone know of a better way to do this, or how I can correct the expression to make iot compilable? I tried using {#}, #, {#}, ##, but haven't been able to do it right.

-
Can you turn the snippet of code into a full minimal example? Add also the proposed code that doesn't work. –  egreg Feb 21 '13 at 22:21
@egreg I'll do it tomorrow morning first thing. I left it all at work. –  morcillo Feb 21 '13 at 22:44
@egreg But you can find a full code snippet in the question linked in this question's description. Just click the link on the word "here" in the desciption and you will get a code snippet. –  morcillo Feb 21 '13 at 22:45
I tried to follow the link but if I insert the code in the question I get: Argument of \reserved@a has an extra }. <inserted text> \par l.48 ] { ? –  David Carlisle Feb 21 '13 at 23:02
@DavidCarlisle That is another comoilation error that appears some times. I just can't use \mymacro. It just fails –  morcillo Feb 21 '13 at 23:05

\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},
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=\\,
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={
},
every last column/.style={
},
string type,
}

\newcommand\mymacro[5]{%
[columns/col1/.style={column name=\textbf{#1}},
columns/col2/.style={column name=\textbf{#2}},
columns/col3/.style={column name=\textbf{#3}},
columns/col4/.style={column name=\textbf{#4}},
columns/col5/.style={column name=\textbf{#5}}]}

\begin{document}

\expandafter\pgfplotstabletypeset\mymacro{red}{blue}{green}{yellow}{pink}
{
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 & & \\
}
\end{document}

-
Thank you very much for going through the problem of fixing my mistakes (been in latex only for a month). But I have a question. That only generates a table with col1, col2, and so on, it doesn't allow me to put any column name I want. Or does it? Sorry for any english mistakes –  morcillo Feb 21 '13 at 23:45
@morcillo sorry posted wrong version, try now –  David Carlisle Feb 21 '13 at 23:50
Thank you. You're a genious (not sure if it's spelled this way) –  morcillo Feb 22 '13 at 12:51