GeneralProblem redefining newline in tabular environment

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
daroepi
Posts: 4
Joined: Tue Mar 23, 2010 6:37 pm

Problem redefining newline in tabular environment

Post by daroepi »

Problem redefining newline in tabular environment

I'm new to TeX/LaTeX and I have a problem with the following:

Code: Select all

\documentclass{article}

\def\nl{\tabularnewline & x } %\let\\\nl} % uncomment to work
\def\elem#1{\let\\\nl #1}
\def\mgroup#1#2{#1 & x \elem{#2}}

\begin{document}

\begin{tabular}{l|l}
\mgroup{g1}{one\\two\\three\\four}
\end{tabular}

\end{document}
In the code above, I want to simply let \\ (double backslash) equal my custom newline command \nl which inserts a \tabularnewline and & to jump to the second column of the next row.

The problem is that the \\ substitution stops working after the second row unless I uncomment the comment in the above code. My question is, why do I need to do this?

Another thing, if I incorporate the code in the \elem command directly in \mgroup, it will also fail to work. Why is that?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply