Insert commas in a table/array












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!)?










share|improve this question






















  • 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
















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!)?










share|improve this question






















  • 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














0












0








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!)?










share|improve this question













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!)?







tables arrays






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 13 '18 at 8:03









leastaction

203111




203111












  • 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


















  • 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
















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




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




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




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 Answer
1






active

oldest

votes


















1














A rather easy solution would be, to define your own separator, like defsep{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.






share|improve this answer





















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











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464647%2finsert-commas-in-a-table-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














A rather easy solution would be, to define your own separator, like defsep{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.






share|improve this answer





















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
















1














A rather easy solution would be, to define your own separator, like defsep{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.






share|improve this answer





















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














1












1








1






A rather easy solution would be, to define your own separator, like defsep{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.






share|improve this answer












A rather easy solution would be, to define your own separator, like defsep{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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 13 '18 at 8:15









SKL

1265




1265












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


















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
















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




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


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464647%2finsert-commas-in-a-table-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents