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

Is there a way to make something like tabular such that in a loop we get each column in a line and render them in a custom format. Like this

l1c1 & l1c2 & l1c3 \\
l2c1 & l2c2 & l2c3

and render the the elements in a custom format, e.g.

\textbf{l1c1}: l1c2$^{l1c3}$

for all the lines. Expected output:

enter image description here

share|improve this question
up vote 4 down vote accepted

You can do this with the collcell package which allows you to pass the entry of each column to a command for further processing:

enter image description here

Below I have defined two new column types. The H column type is for the header column, and the E column type is for the exponent column. The middle column is just a normal l, but with a @{} to remove the column separation between this column and the subsequent column containing the exponent.


A previous answer of mine customize the “cell environment” in a tabular also shows:

  • How to use the array package, which can definitely accommodate the header column with


    but not sure how to get the superscript column to work.

  • A method which does not require any additional packages, by defining a macro to process each row. But, this requires changing each row of the table.





  \begin{tabular}{H l@{} E}
    l1c1 & l1c2 & l1c3 \\
    l2c1 & l2c2 & l2c3
share|improve this answer
Thanks @peter-grill – anandogc Jul 15 '12 at 10:40

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.