2

I have a \newcommand*\mycmd[3]{#1 & #2 & #3 \\} that is used in a tabular environment later, like this

\begin{tabular}{ccc}
\mycmd{a}{b}{c}
\mycmd{d}{e}{f}
\end{tabular}

But the double backslash is ignored. I already tried to change the \\ to the real \cr, but it is also ignored, the rowbreak does just not happen.

How do I have to define my command to be able to use \\ or \cr inside it?

Foo Bar
  • 13,247

1 Answers1

3

Always post fully compilable examples: This compiles just as expected

\documentclass[a4paper]{article}
\newcommand*\mycmd[3]{#1 & #2 & #3 \\}
\begin{document}
\begin{tabular}{ccc}
\mycmd{a}{b}{c}
\mycmd{d}{e}{f}
\end{tabular}
\end{document}
daleif
  • 54,450
  • Thanks, The problem was not the \\ or \cr, but in my real world code I need more than 10 parameters and did not realize that only 9 are allowed... I found solutions there: https://tex.stackexchange.com/questions/2132/how-to-define-a-command-that-takes-more-than-9-arguments – Foo Bar Jun 30 '15 at 09:52
  • That is why we always ask you to prepare a full MWE. And that you test that MWE. Safes us all a lot of time – daleif Jun 30 '15 at 09:53