0

I have a table, of the form

\documentclass[hyper,12pt,A4paper]{article}
\usepackage{latexsym,amsmath,amsfonts,amssymb}
\begin{document}
\begin{align}
\begin{array}{cccc}
    ab=0 & cd=1 & efgh=-1 & pqr=30
\end{array} 
\end{align}
\end{document}

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) – David Carlisle Dec 13 '18 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. – David Carlisle Dec 13 '18 at 9:02
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.

| improve this answer | |
  • it's all math mode so spaces are ignored anyway – David Carlisle Dec 13 '18 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.