Use comma instead of & in table












7















I am new in LaTeX. In tabular, we generally use & for partition. I want to create a .sty for tabular environment. Replace & with comma delimiter, in this case comma should be work as & like in tabular command.



In .tex file, input is a,b,c and output should look like |a|b|c|










share|improve this question









New contributor




limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 5





    I strongly recommend not to do that, because it is extremely complicated. Firstly you have to understand the definition of tabular in latex.ltx. That is a real problem.

    – JouleV
    yesterday






  • 4





    I do not which use you would do of this convention, but how would you fiddle with cells that should contain commas? If it is for special types of tabulars, you might want to take a look at the csvsimple package, or the more powerful datatool.

    – Bernard
    23 hours ago






  • 1





    @Bernard Can't you say the same about the default syntax: how would you fiddle with cells that should contain &s? Ultimately it depends on the nature of the data whether commas or ampersands are more common in the cells. (I'm not recommending trying to achieve the OP's goal in LaTeX -- my preference would be to run a preprocessor on the comma-separated data to produce valid LaTeX syntax -- just pointing out that the LaTeX syntax just happens to be what Knuth/Lamport decided to adopt for their use-cases, and isn't objectively better for all applications.)

    – ShreevatsaR
    20 hours ago











  • You have to escape the ampersand to print it (&)whereas for the comma you can't . Also, using a comma is certainly mor commen (for instance if a cell contains a list, or the decimal comma for numeric values – not all countries use a dot for that.

    – Bernard
    20 hours ago






  • 1





    @Bernard There is no intrinsic difference between & and ,` except that the former happens to have an appropriate definition in LaTeX by default, and the latter doesn't (and would have to be redefined after finding a new name for what is currently ,). And yes, commas may indeed be more common in many/most "typical" applications, but we don't know what's more common in the OP's application. Question is whether to bend the tool for the sake of our task or vice-versa… IMO the only reason for preferring & here is because LaTeX is more suited for it, not anything intrinsic to the syntax.

    – ShreevatsaR
    16 hours ago
















7















I am new in LaTeX. In tabular, we generally use & for partition. I want to create a .sty for tabular environment. Replace & with comma delimiter, in this case comma should be work as & like in tabular command.



In .tex file, input is a,b,c and output should look like |a|b|c|










share|improve this question









New contributor




limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 5





    I strongly recommend not to do that, because it is extremely complicated. Firstly you have to understand the definition of tabular in latex.ltx. That is a real problem.

    – JouleV
    yesterday






  • 4





    I do not which use you would do of this convention, but how would you fiddle with cells that should contain commas? If it is for special types of tabulars, you might want to take a look at the csvsimple package, or the more powerful datatool.

    – Bernard
    23 hours ago






  • 1





    @Bernard Can't you say the same about the default syntax: how would you fiddle with cells that should contain &s? Ultimately it depends on the nature of the data whether commas or ampersands are more common in the cells. (I'm not recommending trying to achieve the OP's goal in LaTeX -- my preference would be to run a preprocessor on the comma-separated data to produce valid LaTeX syntax -- just pointing out that the LaTeX syntax just happens to be what Knuth/Lamport decided to adopt for their use-cases, and isn't objectively better for all applications.)

    – ShreevatsaR
    20 hours ago











  • You have to escape the ampersand to print it (&)whereas for the comma you can't . Also, using a comma is certainly mor commen (for instance if a cell contains a list, or the decimal comma for numeric values – not all countries use a dot for that.

    – Bernard
    20 hours ago






  • 1





    @Bernard There is no intrinsic difference between & and ,` except that the former happens to have an appropriate definition in LaTeX by default, and the latter doesn't (and would have to be redefined after finding a new name for what is currently ,). And yes, commas may indeed be more common in many/most "typical" applications, but we don't know what's more common in the OP's application. Question is whether to bend the tool for the sake of our task or vice-versa… IMO the only reason for preferring & here is because LaTeX is more suited for it, not anything intrinsic to the syntax.

    – ShreevatsaR
    16 hours ago














7












7








7


0






I am new in LaTeX. In tabular, we generally use & for partition. I want to create a .sty for tabular environment. Replace & with comma delimiter, in this case comma should be work as & like in tabular command.



In .tex file, input is a,b,c and output should look like |a|b|c|










share|improve this question









New contributor




limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am new in LaTeX. In tabular, we generally use & for partition. I want to create a .sty for tabular environment. Replace & with comma delimiter, in this case comma should be work as & like in tabular command.



In .tex file, input is a,b,c and output should look like |a|b|c|







tables tex-core






share|improve this question









New contributor




limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









JouleV

4,80611039




4,80611039






New contributor




limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









limlianlimlian

411




411




New contributor




limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






limlian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 5





    I strongly recommend not to do that, because it is extremely complicated. Firstly you have to understand the definition of tabular in latex.ltx. That is a real problem.

    – JouleV
    yesterday






  • 4





    I do not which use you would do of this convention, but how would you fiddle with cells that should contain commas? If it is for special types of tabulars, you might want to take a look at the csvsimple package, or the more powerful datatool.

    – Bernard
    23 hours ago






  • 1





    @Bernard Can't you say the same about the default syntax: how would you fiddle with cells that should contain &s? Ultimately it depends on the nature of the data whether commas or ampersands are more common in the cells. (I'm not recommending trying to achieve the OP's goal in LaTeX -- my preference would be to run a preprocessor on the comma-separated data to produce valid LaTeX syntax -- just pointing out that the LaTeX syntax just happens to be what Knuth/Lamport decided to adopt for their use-cases, and isn't objectively better for all applications.)

    – ShreevatsaR
    20 hours ago











  • You have to escape the ampersand to print it (&)whereas for the comma you can't . Also, using a comma is certainly mor commen (for instance if a cell contains a list, or the decimal comma for numeric values – not all countries use a dot for that.

    – Bernard
    20 hours ago






  • 1





    @Bernard There is no intrinsic difference between & and ,` except that the former happens to have an appropriate definition in LaTeX by default, and the latter doesn't (and would have to be redefined after finding a new name for what is currently ,). And yes, commas may indeed be more common in many/most "typical" applications, but we don't know what's more common in the OP's application. Question is whether to bend the tool for the sake of our task or vice-versa… IMO the only reason for preferring & here is because LaTeX is more suited for it, not anything intrinsic to the syntax.

    – ShreevatsaR
    16 hours ago














  • 5





    I strongly recommend not to do that, because it is extremely complicated. Firstly you have to understand the definition of tabular in latex.ltx. That is a real problem.

    – JouleV
    yesterday






  • 4





    I do not which use you would do of this convention, but how would you fiddle with cells that should contain commas? If it is for special types of tabulars, you might want to take a look at the csvsimple package, or the more powerful datatool.

    – Bernard
    23 hours ago






  • 1





    @Bernard Can't you say the same about the default syntax: how would you fiddle with cells that should contain &s? Ultimately it depends on the nature of the data whether commas or ampersands are more common in the cells. (I'm not recommending trying to achieve the OP's goal in LaTeX -- my preference would be to run a preprocessor on the comma-separated data to produce valid LaTeX syntax -- just pointing out that the LaTeX syntax just happens to be what Knuth/Lamport decided to adopt for their use-cases, and isn't objectively better for all applications.)

    – ShreevatsaR
    20 hours ago











  • You have to escape the ampersand to print it (&)whereas for the comma you can't . Also, using a comma is certainly mor commen (for instance if a cell contains a list, or the decimal comma for numeric values – not all countries use a dot for that.

    – Bernard
    20 hours ago






  • 1





    @Bernard There is no intrinsic difference between & and ,` except that the former happens to have an appropriate definition in LaTeX by default, and the latter doesn't (and would have to be redefined after finding a new name for what is currently ,). And yes, commas may indeed be more common in many/most "typical" applications, but we don't know what's more common in the OP's application. Question is whether to bend the tool for the sake of our task or vice-versa… IMO the only reason for preferring & here is because LaTeX is more suited for it, not anything intrinsic to the syntax.

    – ShreevatsaR
    16 hours ago








5




5





I strongly recommend not to do that, because it is extremely complicated. Firstly you have to understand the definition of tabular in latex.ltx. That is a real problem.

– JouleV
yesterday





I strongly recommend not to do that, because it is extremely complicated. Firstly you have to understand the definition of tabular in latex.ltx. That is a real problem.

– JouleV
yesterday




4




4





I do not which use you would do of this convention, but how would you fiddle with cells that should contain commas? If it is for special types of tabulars, you might want to take a look at the csvsimple package, or the more powerful datatool.

– Bernard
23 hours ago





I do not which use you would do of this convention, but how would you fiddle with cells that should contain commas? If it is for special types of tabulars, you might want to take a look at the csvsimple package, or the more powerful datatool.

– Bernard
23 hours ago




1




1





@Bernard Can't you say the same about the default syntax: how would you fiddle with cells that should contain &s? Ultimately it depends on the nature of the data whether commas or ampersands are more common in the cells. (I'm not recommending trying to achieve the OP's goal in LaTeX -- my preference would be to run a preprocessor on the comma-separated data to produce valid LaTeX syntax -- just pointing out that the LaTeX syntax just happens to be what Knuth/Lamport decided to adopt for their use-cases, and isn't objectively better for all applications.)

– ShreevatsaR
20 hours ago





@Bernard Can't you say the same about the default syntax: how would you fiddle with cells that should contain &s? Ultimately it depends on the nature of the data whether commas or ampersands are more common in the cells. (I'm not recommending trying to achieve the OP's goal in LaTeX -- my preference would be to run a preprocessor on the comma-separated data to produce valid LaTeX syntax -- just pointing out that the LaTeX syntax just happens to be what Knuth/Lamport decided to adopt for their use-cases, and isn't objectively better for all applications.)

– ShreevatsaR
20 hours ago













You have to escape the ampersand to print it (&)whereas for the comma you can't . Also, using a comma is certainly mor commen (for instance if a cell contains a list, or the decimal comma for numeric values – not all countries use a dot for that.

– Bernard
20 hours ago





You have to escape the ampersand to print it (&)whereas for the comma you can't . Also, using a comma is certainly mor commen (for instance if a cell contains a list, or the decimal comma for numeric values – not all countries use a dot for that.

– Bernard
20 hours ago




1




1





@Bernard There is no intrinsic difference between & and ,` except that the former happens to have an appropriate definition in LaTeX by default, and the latter doesn't (and would have to be redefined after finding a new name for what is currently ,). And yes, commas may indeed be more common in many/most "typical" applications, but we don't know what's more common in the OP's application. Question is whether to bend the tool for the sake of our task or vice-versa… IMO the only reason for preferring & here is because LaTeX is more suited for it, not anything intrinsic to the syntax.

– ShreevatsaR
16 hours ago





@Bernard There is no intrinsic difference between & and ,` except that the former happens to have an appropriate definition in LaTeX by default, and the latter doesn't (and would have to be redefined after finding a new name for what is currently ,). And yes, commas may indeed be more common in many/most "typical" applications, but we don't know what's more common in the OP's application. Question is whether to bend the tool for the sake of our task or vice-versa… IMO the only reason for preferring & here is because LaTeX is more suited for it, not anything intrinsic to the syntax.

– ShreevatsaR
16 hours ago










3 Answers
3






active

oldest

votes


















12














Proof of concept. Use at your own risk!



The basic approach is to change catcode of the character you want to use as “alignment tab”. Here's a mytabular environment which does that:



documentclass{article}

usepackage{xparse}

ExplSyntaxOn
NewDocumentEnvironment {mytabular} { O{,} }
{
char_set_catcode_other:N &
char_set_catcode_alignment:n {`#1}
begin{tabular}
}
{
end{tabular}
}
ExplSyntaxOff

begin{document}
pagestyle{empty}

begin{mytabular}{l|r}
a , b & c \
c , d \
end{mytabular}

begin{mytabular}[@]{l|r}
a @ b \
c @ d, & e \
end{mytabular}

end{document}



enter image description here




The optional argument lets you choose which character is used as alignment tab. No verification whatsoever is done to see if the character you passed is valid. If you don't pass a character, a comma is used. The & behaves as a normal character.



However, as other already warned you, this is not the best idea. Packages that rely on & being an alignment tab will break.






share|improve this answer


























  • Thank you so much for your reply.

    – limlian
    7 hours ago











  • @limlian TeX doesn't allow you more than 9 parameters. You'd have to find another way around to use 12. But in your example you used only 6 parameter (non consecutive). But I think that 12 is far from user friendly and I would suggest another approach, if you specified your use case. However, try the code I proposed with begin{mytabular}{|c|c|c|} a, b, c \ x, y, z \ end{mytabular}. It seem to do as you want.

    – Phelype Oleinik
    2 hours ago











  • @limlian Please, add to your question, not to comments to an answer. But I believe that a new question, with better specification of your problem is what you should do.

    – egreg
    2 hours ago



















10














As Bernard suggested, why don't use csvsimple?



If you have commas in your cells, just put the contents within curly brackets.



If you have & in your cells, just write &.



documentclass{article}
usepackage{filecontents}
usepackage{csvsimple}

begin{document}

begin{filecontents*}{mydata.csv}
a,b,c
end{filecontents*}
csvreader[
tabular=|c|c|c|,
nohead
]{mydata.csv}% filename
{}{csvcoli & csvcolii & csvcoliii}

vspace{3ex}
and if you have commas or & in your cells:
vspace{3ex}

begin{filecontents*}{mydata.csv}
a,b,c
{c, d},{e, f, g},{h, i, j, k}
l & m,{n & o, p},q & r & s & t
end{filecontents*}
csvreader[
tabular=|c|c|c|,
nohead
]{mydata.csv}% filename
{}{csvcoli & csvcolii & csvcoliii}

end{document}


enter image description here






share|improve this answer

































    8














    You can use the spalign package (documentation here), which includes spaligntabular that acts exactly like tabular, except it uses both space and comma as the align character & and semicolon as the the end-of-row control
    sequence \:



    documentclass[12pt]{report}
    usepackage{spalign}

    begin{document}

    spaligntabular{lcr}{a b c; aa bb cc}

    spaligntabular{|c|c|c}{a,b,c}

    end{document}


    It produces this:



    spaligntabular example



    and



    spaligntabular example 2



    The spalign package also includes similar commands, such as spalignmat for a matrix and spalignarray for a generic array.



    There are options to use different characters instead of or in addition to space, comma, and semicolon (see the documentation).



    By the way, if you need to include a comma, space, or semicolon in your table, just enclose it in braces {}.






    share|improve this answer





















    • 2





      I didn't know this package, I think it does exactly what the OP wants, +1!

      – CarLaTeX
      8 hours ago











    • Absolutely I agree with @CarLaTeX :-) Very good.

      – Sebastiano
      2 hours ago











    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
    });


    }
    });






    limlian is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477714%2fuse-comma-instead-of-in-table%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    12














    Proof of concept. Use at your own risk!



    The basic approach is to change catcode of the character you want to use as “alignment tab”. Here's a mytabular environment which does that:



    documentclass{article}

    usepackage{xparse}

    ExplSyntaxOn
    NewDocumentEnvironment {mytabular} { O{,} }
    {
    char_set_catcode_other:N &
    char_set_catcode_alignment:n {`#1}
    begin{tabular}
    }
    {
    end{tabular}
    }
    ExplSyntaxOff

    begin{document}
    pagestyle{empty}

    begin{mytabular}{l|r}
    a , b & c \
    c , d \
    end{mytabular}

    begin{mytabular}[@]{l|r}
    a @ b \
    c @ d, & e \
    end{mytabular}

    end{document}



    enter image description here




    The optional argument lets you choose which character is used as alignment tab. No verification whatsoever is done to see if the character you passed is valid. If you don't pass a character, a comma is used. The & behaves as a normal character.



    However, as other already warned you, this is not the best idea. Packages that rely on & being an alignment tab will break.






    share|improve this answer


























    • Thank you so much for your reply.

      – limlian
      7 hours ago











    • @limlian TeX doesn't allow you more than 9 parameters. You'd have to find another way around to use 12. But in your example you used only 6 parameter (non consecutive). But I think that 12 is far from user friendly and I would suggest another approach, if you specified your use case. However, try the code I proposed with begin{mytabular}{|c|c|c|} a, b, c \ x, y, z \ end{mytabular}. It seem to do as you want.

      – Phelype Oleinik
      2 hours ago











    • @limlian Please, add to your question, not to comments to an answer. But I believe that a new question, with better specification of your problem is what you should do.

      – egreg
      2 hours ago
















    12














    Proof of concept. Use at your own risk!



    The basic approach is to change catcode of the character you want to use as “alignment tab”. Here's a mytabular environment which does that:



    documentclass{article}

    usepackage{xparse}

    ExplSyntaxOn
    NewDocumentEnvironment {mytabular} { O{,} }
    {
    char_set_catcode_other:N &
    char_set_catcode_alignment:n {`#1}
    begin{tabular}
    }
    {
    end{tabular}
    }
    ExplSyntaxOff

    begin{document}
    pagestyle{empty}

    begin{mytabular}{l|r}
    a , b & c \
    c , d \
    end{mytabular}

    begin{mytabular}[@]{l|r}
    a @ b \
    c @ d, & e \
    end{mytabular}

    end{document}



    enter image description here




    The optional argument lets you choose which character is used as alignment tab. No verification whatsoever is done to see if the character you passed is valid. If you don't pass a character, a comma is used. The & behaves as a normal character.



    However, as other already warned you, this is not the best idea. Packages that rely on & being an alignment tab will break.






    share|improve this answer


























    • Thank you so much for your reply.

      – limlian
      7 hours ago











    • @limlian TeX doesn't allow you more than 9 parameters. You'd have to find another way around to use 12. But in your example you used only 6 parameter (non consecutive). But I think that 12 is far from user friendly and I would suggest another approach, if you specified your use case. However, try the code I proposed with begin{mytabular}{|c|c|c|} a, b, c \ x, y, z \ end{mytabular}. It seem to do as you want.

      – Phelype Oleinik
      2 hours ago











    • @limlian Please, add to your question, not to comments to an answer. But I believe that a new question, with better specification of your problem is what you should do.

      – egreg
      2 hours ago














    12












    12








    12







    Proof of concept. Use at your own risk!



    The basic approach is to change catcode of the character you want to use as “alignment tab”. Here's a mytabular environment which does that:



    documentclass{article}

    usepackage{xparse}

    ExplSyntaxOn
    NewDocumentEnvironment {mytabular} { O{,} }
    {
    char_set_catcode_other:N &
    char_set_catcode_alignment:n {`#1}
    begin{tabular}
    }
    {
    end{tabular}
    }
    ExplSyntaxOff

    begin{document}
    pagestyle{empty}

    begin{mytabular}{l|r}
    a , b & c \
    c , d \
    end{mytabular}

    begin{mytabular}[@]{l|r}
    a @ b \
    c @ d, & e \
    end{mytabular}

    end{document}



    enter image description here




    The optional argument lets you choose which character is used as alignment tab. No verification whatsoever is done to see if the character you passed is valid. If you don't pass a character, a comma is used. The & behaves as a normal character.



    However, as other already warned you, this is not the best idea. Packages that rely on & being an alignment tab will break.






    share|improve this answer















    Proof of concept. Use at your own risk!



    The basic approach is to change catcode of the character you want to use as “alignment tab”. Here's a mytabular environment which does that:



    documentclass{article}

    usepackage{xparse}

    ExplSyntaxOn
    NewDocumentEnvironment {mytabular} { O{,} }
    {
    char_set_catcode_other:N &
    char_set_catcode_alignment:n {`#1}
    begin{tabular}
    }
    {
    end{tabular}
    }
    ExplSyntaxOff

    begin{document}
    pagestyle{empty}

    begin{mytabular}{l|r}
    a , b & c \
    c , d \
    end{mytabular}

    begin{mytabular}[@]{l|r}
    a @ b \
    c @ d, & e \
    end{mytabular}

    end{document}



    enter image description here




    The optional argument lets you choose which character is used as alignment tab. No verification whatsoever is done to see if the character you passed is valid. If you don't pass a character, a comma is used. The & behaves as a normal character.



    However, as other already warned you, this is not the best idea. Packages that rely on & being an alignment tab will break.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 2 hours ago

























    answered 23 hours ago









    Phelype OleinikPhelype Oleinik

    23.8k54587




    23.8k54587













    • Thank you so much for your reply.

      – limlian
      7 hours ago











    • @limlian TeX doesn't allow you more than 9 parameters. You'd have to find another way around to use 12. But in your example you used only 6 parameter (non consecutive). But I think that 12 is far from user friendly and I would suggest another approach, if you specified your use case. However, try the code I proposed with begin{mytabular}{|c|c|c|} a, b, c \ x, y, z \ end{mytabular}. It seem to do as you want.

      – Phelype Oleinik
      2 hours ago











    • @limlian Please, add to your question, not to comments to an answer. But I believe that a new question, with better specification of your problem is what you should do.

      – egreg
      2 hours ago



















    • Thank you so much for your reply.

      – limlian
      7 hours ago











    • @limlian TeX doesn't allow you more than 9 parameters. You'd have to find another way around to use 12. But in your example you used only 6 parameter (non consecutive). But I think that 12 is far from user friendly and I would suggest another approach, if you specified your use case. However, try the code I proposed with begin{mytabular}{|c|c|c|} a, b, c \ x, y, z \ end{mytabular}. It seem to do as you want.

      – Phelype Oleinik
      2 hours ago











    • @limlian Please, add to your question, not to comments to an answer. But I believe that a new question, with better specification of your problem is what you should do.

      – egreg
      2 hours ago

















    Thank you so much for your reply.

    – limlian
    7 hours ago





    Thank you so much for your reply.

    – limlian
    7 hours ago













    @limlian TeX doesn't allow you more than 9 parameters. You'd have to find another way around to use 12. But in your example you used only 6 parameter (non consecutive). But I think that 12 is far from user friendly and I would suggest another approach, if you specified your use case. However, try the code I proposed with begin{mytabular}{|c|c|c|} a, b, c \ x, y, z \ end{mytabular}. It seem to do as you want.

    – Phelype Oleinik
    2 hours ago





    @limlian TeX doesn't allow you more than 9 parameters. You'd have to find another way around to use 12. But in your example you used only 6 parameter (non consecutive). But I think that 12 is far from user friendly and I would suggest another approach, if you specified your use case. However, try the code I proposed with begin{mytabular}{|c|c|c|} a, b, c \ x, y, z \ end{mytabular}. It seem to do as you want.

    – Phelype Oleinik
    2 hours ago













    @limlian Please, add to your question, not to comments to an answer. But I believe that a new question, with better specification of your problem is what you should do.

    – egreg
    2 hours ago





    @limlian Please, add to your question, not to comments to an answer. But I believe that a new question, with better specification of your problem is what you should do.

    – egreg
    2 hours ago











    10














    As Bernard suggested, why don't use csvsimple?



    If you have commas in your cells, just put the contents within curly brackets.



    If you have & in your cells, just write &.



    documentclass{article}
    usepackage{filecontents}
    usepackage{csvsimple}

    begin{document}

    begin{filecontents*}{mydata.csv}
    a,b,c
    end{filecontents*}
    csvreader[
    tabular=|c|c|c|,
    nohead
    ]{mydata.csv}% filename
    {}{csvcoli & csvcolii & csvcoliii}

    vspace{3ex}
    and if you have commas or & in your cells:
    vspace{3ex}

    begin{filecontents*}{mydata.csv}
    a,b,c
    {c, d},{e, f, g},{h, i, j, k}
    l & m,{n & o, p},q & r & s & t
    end{filecontents*}
    csvreader[
    tabular=|c|c|c|,
    nohead
    ]{mydata.csv}% filename
    {}{csvcoli & csvcolii & csvcoliii}

    end{document}


    enter image description here






    share|improve this answer






























      10














      As Bernard suggested, why don't use csvsimple?



      If you have commas in your cells, just put the contents within curly brackets.



      If you have & in your cells, just write &.



      documentclass{article}
      usepackage{filecontents}
      usepackage{csvsimple}

      begin{document}

      begin{filecontents*}{mydata.csv}
      a,b,c
      end{filecontents*}
      csvreader[
      tabular=|c|c|c|,
      nohead
      ]{mydata.csv}% filename
      {}{csvcoli & csvcolii & csvcoliii}

      vspace{3ex}
      and if you have commas or & in your cells:
      vspace{3ex}

      begin{filecontents*}{mydata.csv}
      a,b,c
      {c, d},{e, f, g},{h, i, j, k}
      l & m,{n & o, p},q & r & s & t
      end{filecontents*}
      csvreader[
      tabular=|c|c|c|,
      nohead
      ]{mydata.csv}% filename
      {}{csvcoli & csvcolii & csvcoliii}

      end{document}


      enter image description here






      share|improve this answer




























        10












        10








        10







        As Bernard suggested, why don't use csvsimple?



        If you have commas in your cells, just put the contents within curly brackets.



        If you have & in your cells, just write &.



        documentclass{article}
        usepackage{filecontents}
        usepackage{csvsimple}

        begin{document}

        begin{filecontents*}{mydata.csv}
        a,b,c
        end{filecontents*}
        csvreader[
        tabular=|c|c|c|,
        nohead
        ]{mydata.csv}% filename
        {}{csvcoli & csvcolii & csvcoliii}

        vspace{3ex}
        and if you have commas or & in your cells:
        vspace{3ex}

        begin{filecontents*}{mydata.csv}
        a,b,c
        {c, d},{e, f, g},{h, i, j, k}
        l & m,{n & o, p},q & r & s & t
        end{filecontents*}
        csvreader[
        tabular=|c|c|c|,
        nohead
        ]{mydata.csv}% filename
        {}{csvcoli & csvcolii & csvcoliii}

        end{document}


        enter image description here






        share|improve this answer















        As Bernard suggested, why don't use csvsimple?



        If you have commas in your cells, just put the contents within curly brackets.



        If you have & in your cells, just write &.



        documentclass{article}
        usepackage{filecontents}
        usepackage{csvsimple}

        begin{document}

        begin{filecontents*}{mydata.csv}
        a,b,c
        end{filecontents*}
        csvreader[
        tabular=|c|c|c|,
        nohead
        ]{mydata.csv}% filename
        {}{csvcoli & csvcolii & csvcoliii}

        vspace{3ex}
        and if you have commas or & in your cells:
        vspace{3ex}

        begin{filecontents*}{mydata.csv}
        a,b,c
        {c, d},{e, f, g},{h, i, j, k}
        l & m,{n & o, p},q & r & s & t
        end{filecontents*}
        csvreader[
        tabular=|c|c|c|,
        nohead
        ]{mydata.csv}% filename
        {}{csvcoli & csvcolii & csvcoliii}

        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 8 hours ago

























        answered 19 hours ago









        CarLaTeXCarLaTeX

        32.6k551135




        32.6k551135























            8














            You can use the spalign package (documentation here), which includes spaligntabular that acts exactly like tabular, except it uses both space and comma as the align character & and semicolon as the the end-of-row control
            sequence \:



            documentclass[12pt]{report}
            usepackage{spalign}

            begin{document}

            spaligntabular{lcr}{a b c; aa bb cc}

            spaligntabular{|c|c|c}{a,b,c}

            end{document}


            It produces this:



            spaligntabular example



            and



            spaligntabular example 2



            The spalign package also includes similar commands, such as spalignmat for a matrix and spalignarray for a generic array.



            There are options to use different characters instead of or in addition to space, comma, and semicolon (see the documentation).



            By the way, if you need to include a comma, space, or semicolon in your table, just enclose it in braces {}.






            share|improve this answer





















            • 2





              I didn't know this package, I think it does exactly what the OP wants, +1!

              – CarLaTeX
              8 hours ago











            • Absolutely I agree with @CarLaTeX :-) Very good.

              – Sebastiano
              2 hours ago
















            8














            You can use the spalign package (documentation here), which includes spaligntabular that acts exactly like tabular, except it uses both space and comma as the align character & and semicolon as the the end-of-row control
            sequence \:



            documentclass[12pt]{report}
            usepackage{spalign}

            begin{document}

            spaligntabular{lcr}{a b c; aa bb cc}

            spaligntabular{|c|c|c}{a,b,c}

            end{document}


            It produces this:



            spaligntabular example



            and



            spaligntabular example 2



            The spalign package also includes similar commands, such as spalignmat for a matrix and spalignarray for a generic array.



            There are options to use different characters instead of or in addition to space, comma, and semicolon (see the documentation).



            By the way, if you need to include a comma, space, or semicolon in your table, just enclose it in braces {}.






            share|improve this answer





















            • 2





              I didn't know this package, I think it does exactly what the OP wants, +1!

              – CarLaTeX
              8 hours ago











            • Absolutely I agree with @CarLaTeX :-) Very good.

              – Sebastiano
              2 hours ago














            8












            8








            8







            You can use the spalign package (documentation here), which includes spaligntabular that acts exactly like tabular, except it uses both space and comma as the align character & and semicolon as the the end-of-row control
            sequence \:



            documentclass[12pt]{report}
            usepackage{spalign}

            begin{document}

            spaligntabular{lcr}{a b c; aa bb cc}

            spaligntabular{|c|c|c}{a,b,c}

            end{document}


            It produces this:



            spaligntabular example



            and



            spaligntabular example 2



            The spalign package also includes similar commands, such as spalignmat for a matrix and spalignarray for a generic array.



            There are options to use different characters instead of or in addition to space, comma, and semicolon (see the documentation).



            By the way, if you need to include a comma, space, or semicolon in your table, just enclose it in braces {}.






            share|improve this answer















            You can use the spalign package (documentation here), which includes spaligntabular that acts exactly like tabular, except it uses both space and comma as the align character & and semicolon as the the end-of-row control
            sequence \:



            documentclass[12pt]{report}
            usepackage{spalign}

            begin{document}

            spaligntabular{lcr}{a b c; aa bb cc}

            spaligntabular{|c|c|c}{a,b,c}

            end{document}


            It produces this:



            spaligntabular example



            and



            spaligntabular example 2



            The spalign package also includes similar commands, such as spalignmat for a matrix and spalignarray for a generic array.



            There are options to use different characters instead of or in addition to space, comma, and semicolon (see the documentation).



            By the way, if you need to include a comma, space, or semicolon in your table, just enclose it in braces {}.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 11 hours ago

























            answered 11 hours ago









            JasonVJasonV

            914




            914








            • 2





              I didn't know this package, I think it does exactly what the OP wants, +1!

              – CarLaTeX
              8 hours ago











            • Absolutely I agree with @CarLaTeX :-) Very good.

              – Sebastiano
              2 hours ago














            • 2





              I didn't know this package, I think it does exactly what the OP wants, +1!

              – CarLaTeX
              8 hours ago











            • Absolutely I agree with @CarLaTeX :-) Very good.

              – Sebastiano
              2 hours ago








            2




            2





            I didn't know this package, I think it does exactly what the OP wants, +1!

            – CarLaTeX
            8 hours ago





            I didn't know this package, I think it does exactly what the OP wants, +1!

            – CarLaTeX
            8 hours ago













            Absolutely I agree with @CarLaTeX :-) Very good.

            – Sebastiano
            2 hours ago





            Absolutely I agree with @CarLaTeX :-) Very good.

            – Sebastiano
            2 hours ago










            limlian is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            limlian is a new contributor. Be nice, and check out our Code of Conduct.













            limlian is a new contributor. Be nice, and check out our Code of Conduct.












            limlian is a new contributor. Be nice, and check out our Code of Conduct.
















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477714%2fuse-comma-instead-of-in-table%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 label and detect the document text images

            Vallis Paradisi

            Tabula Rosettana