Take the 2-minute tour ×
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'm trying to define a \newcommand that has a tabular in it, but I get an:

! You can't use `macro parameter character #' in restricted horizontal mode.

Here's an example:

\newcommand{\Mytest}{1}{
\begin{tabular}{c}
    #1 \\\hline
\end{tabular}
}

Any way around this?

share|improve this question

closed as too localized by Martin Scharrer Aug 16 '11 at 15:23

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
I'm not able to reproduce your error. Could please provide a full minimal working example (MWE). –  N.N. Aug 16 '11 at 15:14
add comment

1 Answer 1

up vote 4 down vote accepted

Arguments of a command should be enclosed in [] and not {}.

\newcommand{\Mytest}[1]{%
\begin{tabular}{c}
    #1 \\\hline
\end{tabular}%
}
share|improve this answer
    
Argh, I am an idiot. Thanks! –  ynimous Aug 16 '11 at 15:17
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.