I have a table, of the form

    ab=0 & cd=1 & efgh=-1 & pqr=30

but of course, with many many more rows and columns. The output of this looks like this:

enter image description here

But instead, I would like to put commas between successive entries, to make it look something like this:

enter image description here

(with no comma after the last entry in a particular row). Of course, this is trivial to do by hand if there are only a few entries in the table. But I have about 50 such tables and each has a dimension of 5x5 or more. These tables were generated as output from some Mathematica code which is even harder to retrospectively modify.

So my question is: is there a way to modify the \begin{array}{cccc}...\end{array} to something which is schematically like \begin{array}{c,c,c,c}...\end{array} (which in this form is wrong -- I know!)?

  • why do you have an array here these are equations not matrices so the array layer is not needed (and makes it harder to get good output) Commented Dec 13, 2018 at 9:00
  • 1
    the answer to the question as asked is \begin{array}{c@{,}c@{,}c@{,}c} but I suspect it is the wrong question. Commented Dec 13, 2018 at 9:02

1 Answer 1


A rather easy solution would be, to define your own separator, like \def\sep{\unskip, &} and using this in your tables instead of the & sign (the \unskip removes the spaces before the ,). With this, you could just going once through all your tables and replace the & sign with your defined command.

  • it's all math mode so spaces are ignored anyway Commented Dec 13, 2018 at 9:01

You must log in to answer this question.

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