TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider a simple table in the document:

\begin{tabular}{ l c r }
  1 & 2 & 3 \\
  4 & 5 & 6 \\
  7 & 8 & 9 \\

How we can define this table within the documentclass as users only put the values of each cell. I mean how to set variables in the documentclass, as we have, for example, for sections:

\section*{Section Header}
Section body

How to define the table as users can fill the variable in the documents as something like:

row1: cell1, cell2, cell3
share|improve this question
Are all the tables supposed to be like that? And where's the advantage in inputting the table in that way? – egreg Apr 17 '12 at 7:58
Yes, consider that all tables have the same number of columns. The advantage is designing the table with additional packages like tikz the end user does not mess with a long list of codes; just put what he has. I think this is the main purpose of documentsclasses in general (to keep users from mess of codes). – All Apr 17 '12 at 8:03
@Ali To some extent, but the tablular environment is part of the standard LaTeX kernel. As such, any LaTeX user should be okay with tablular. All you will do with your idea is break things! – Joseph Wright Apr 17 '12 at 8:07
@JosephWright But sometimes the tabular is mixed with less known packages for better design. In any case, there is no downside (if there's no advantage) for pulling the table codes into documentsclass to keep the main document tidy. – All Apr 17 '12 at 8:10
up vote 3 down vote accepted

Define this environment

   \bfseries #1 & \bfseries #2 & \bfseries #3 \\

and then tell users to input their tables as

1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\

There's no point in using a non standard syntax for tables, as this hinders code reusability.

But I see no point in providing such shortcuts either.

share|improve this answer

There are several ways to achieve what you want using \newcommand and \newenvironment However, we must remember that both of these commands can accept at most 9 arguments.

So, borrowing the idea from Yiannis in

Definitive guide to trivlists

we have the following code







You might also like to look at

How to separate table content and table style

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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