Insert commas in a table/array
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:
But instead, I would like to put commas between successive entries, to make it look something like this:
(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
add a comment |
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:
But instead, I would like to put commas between successive entries, to make it look something like this:
(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
why do you have an array here these are equations not matrices so thearray
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 isbegin{array}{c@{,}c@{,}c@{,}c}
but I suspect it is the wrong question.
– David Carlisle
Dec 13 '18 at 9:02
add a comment |
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:
But instead, I would like to put commas between successive entries, to make it look something like this:
(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
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:
But instead, I would like to put commas between successive entries, to make it look something like this:
(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
tables arrays
asked Dec 13 '18 at 8:03
leastaction
203111
203111
why do you have an array here these are equations not matrices so thearray
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 isbegin{array}{c@{,}c@{,}c@{,}c}
but I suspect it is the wrong question.
– David Carlisle
Dec 13 '18 at 9:02
add a comment |
why do you have an array here these are equations not matrices so thearray
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 isbegin{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
add a comment |
1 Answer
1
active
oldest
votes
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.
it's all math mode so spaces are ignored anyway
– David Carlisle
Dec 13 '18 at 9:01
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
it's all math mode so spaces are ignored anyway
– David Carlisle
Dec 13 '18 at 9:01
add a comment |
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.
it's all math mode so spaces are ignored anyway
– David Carlisle
Dec 13 '18 at 9:01
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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