Repeating preamble in LaTeX tabular

Here's a solution that works by modifying the internals of the array package.

\documentclass{article}
\usepackage{array}
\makeatletter
\newcommand*\repeatall{%
        \def\@arstrut{&\unhbox\@arstrutbox}%
}
\newcommand*\repeatnone{%
        \def\@arstrut{\unhbox\@arstrutbox}%
}
\makeatother
\begin{document}
\repeatall
\begin{tabular}{l}
a&b&c\\
d&e&f\\
\end{tabular}
\end{document}

Maybe it'd be better to make that into an environment instead of switches.

\newenvironment{repeattabular}{%
        \repeatall
        \tabular
}{%
        \endtabular
}

Tags:

Tables