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


2 Answers 2


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

This is exactly what \halign TeX primitive does.

\halign{{\bf#\unskip}: &#\unskip&$^{#}$\cr
l1c1 & l1c2 & l1c3 \cr
l2c1 & l2c2 & l2c3 \cr

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .