# [XeTeX] Automate table creation

Susan Dittmar Susan.Dittmar at gmx.de
Thu Mar 1 20:35:26 CET 2012

Here another basis on which you might be able to auto-generate your tables,
once you adopt it to your needs. Strategy: First create a command that
contains the whole table, then afterwards call that command to actually
output the table.

\documentclass{article}
\usepackage{pgffor}
\usepackage{etoolbox}
\begin{document}

\newcommand{\TABLE}{\begin{tabular}{cccc}}
% add lines using a loop (you can use nested loops if need be; use
% \noexpand to protect commands that should not yet be expanded):
\foreach \n in {a,b,c}{\xappto{\TABLE}{\n & \noexpand\\n & \noexpand\'\n & \noexpand\"\n \noexpand\\}}
\xappto{\TABLE}{\noexpand\end{tabular}}
% execute the tabular:
\TABLE

\end{document}

I hope that helps,

Susan

PS: Idea taken from http://tex.stackexchange.com/questions/15517/generating-tables-with-for-command

`