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

How can I create an environment that takes items in a way similar to lists?



I'd like the above do something like

header1 & header2 & header3 & header4 \\ \hline
AAA & BBB & & \\ \hline
CCC & CCC & & \\ \hline
share|improve this question

migrated from stackoverflow.com Feb 29 '12 at 16:33

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

Although I'm not entirely clear on your usage, the following is most likely what you're after. The given minimal working example shows your original tabular construction, followed by a myEnv construction. Each \item in within myEnv takes four arguments for the four columns. However, this can also be modified to only take two as in your example:

enter image description here

\usepackage{booktabs}% http://ctan/org/pkg/booktabs
  {\renewcommand{\item}[4]{##1&##2&##3&##4\\}% \item{<one>}{<two>}{<three>}{<four>}
     header1 & header2 & header3 & header 4 \\

header1 & header2 & header3 & header4 \\ \hline
AAA & BBB & & \\ \hline
CCC & CCC & & \\ \hline




I took the liberty of using the booktabs package to produce the second myEnv table, since it produces professional-looking tables (without the use of vertical rules).

The redefinition of \item is local to the environment myEnv, and can therefore still be used in other list environments. Alternatively, you could make your own \item environment (say, \myItem) which would work only inside myEnv.

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.