# LaTeX’s tabular, sort of improved

*The tale of my plight attempting to teach an old dog (LaTeX) a new trick ( tabular with a number of columns that is dynamically specified).* #latex #tabular

In mathematics, one of the ways to specify a permutation of a given set (with, say, \(n\) elements), is to use the `tabular`

environment, to set up a \(2\times n\) table, like so:

\[\left(\begin{array}{cccc} 1 & 2 & 3 & 4 \\% 3 & 1 & 4 & 2 \end{array}\right)\]

I wanted a macro that, to get the above output, I would invoke like this: `\perm{3}{1}{4}{2}`

. This is actually not hard at all, *if the number of elements in the set is fixed*. But I wanted a macro that I could invoke with 4 elements (like above), but also with 5, 6, 3, or whatever. That, it turns out, is not at all trivial. The details can be found here [pdf], with the full code given at the end.

**August 30, 2022.**