Adding column to table in Latex and optimizing columns width












3















Here is my table:
table



This is my code for it:



documentclass[smallextended]{svjour3} 
usepackage{tabularx, booktabs, makecell} %
usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
renewcommand{thetable}{arabic{table}}
begin{document}
begin{table}[!htb]
centering
sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
setlength{tabcolsep}{3pt}
small
centering

sisetup{detect-weight,mode=text}
renewrobustcmd{bfseries}{fontseries{b}selectfont}
renewrobustcmd{boldmath}{}
% abbreviation
newrobustcmd{B}{bfseries}
% shorten the intercolumn spaces
setlength{tabcolsep}{4pt}
begin{tabularx}{linewidth}{l>{centering}XSSS}
toprule

thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
& {thead{PPPPPP Alg\ccc} } \ [0.5ex]
midrule
POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 \
POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 \
POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 \
POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754 \
CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
\
CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
\
AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 \
AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 \
JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 \
JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998\
JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 \
JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654 \ [1ex]
bottomrule
end{tabularx}
% end{tabular}
caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
label{table:2}
end{table}
end{document}


I would like to add at the end of the table another column, with numbers. In addition, I would like to optimize the columns width so that the second column won't be so wide. How can I do it?










share|improve this question




















  • 1





    please, extend your code snippet to complete small document with your table. information contained in your document preamble are important for helping you. added one more column: just write it where you like to ad (& ...)

    – Zarko
    Feb 18 at 14:52













  • in your mwe are still missing some packages ... where you like to ad new column? after last in temporary table?

    – Zarko
    Feb 18 at 15:01
















3















Here is my table:
table



This is my code for it:



documentclass[smallextended]{svjour3} 
usepackage{tabularx, booktabs, makecell} %
usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
renewcommand{thetable}{arabic{table}}
begin{document}
begin{table}[!htb]
centering
sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
setlength{tabcolsep}{3pt}
small
centering

sisetup{detect-weight,mode=text}
renewrobustcmd{bfseries}{fontseries{b}selectfont}
renewrobustcmd{boldmath}{}
% abbreviation
newrobustcmd{B}{bfseries}
% shorten the intercolumn spaces
setlength{tabcolsep}{4pt}
begin{tabularx}{linewidth}{l>{centering}XSSS}
toprule

thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
& {thead{PPPPPP Alg\ccc} } \ [0.5ex]
midrule
POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 \
POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 \
POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 \
POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754 \
CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
\
CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
\
AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 \
AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 \
JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 \
JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998\
JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 \
JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654 \ [1ex]
bottomrule
end{tabularx}
% end{tabular}
caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
label{table:2}
end{table}
end{document}


I would like to add at the end of the table another column, with numbers. In addition, I would like to optimize the columns width so that the second column won't be so wide. How can I do it?










share|improve this question




















  • 1





    please, extend your code snippet to complete small document with your table. information contained in your document preamble are important for helping you. added one more column: just write it where you like to ad (& ...)

    – Zarko
    Feb 18 at 14:52













  • in your mwe are still missing some packages ... where you like to ad new column? after last in temporary table?

    – Zarko
    Feb 18 at 15:01














3












3








3


1






Here is my table:
table



This is my code for it:



documentclass[smallextended]{svjour3} 
usepackage{tabularx, booktabs, makecell} %
usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
renewcommand{thetable}{arabic{table}}
begin{document}
begin{table}[!htb]
centering
sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
setlength{tabcolsep}{3pt}
small
centering

sisetup{detect-weight,mode=text}
renewrobustcmd{bfseries}{fontseries{b}selectfont}
renewrobustcmd{boldmath}{}
% abbreviation
newrobustcmd{B}{bfseries}
% shorten the intercolumn spaces
setlength{tabcolsep}{4pt}
begin{tabularx}{linewidth}{l>{centering}XSSS}
toprule

thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
& {thead{PPPPPP Alg\ccc} } \ [0.5ex]
midrule
POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 \
POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 \
POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 \
POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754 \
CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
\
CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
\
AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 \
AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 \
JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 \
JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998\
JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 \
JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654 \ [1ex]
bottomrule
end{tabularx}
% end{tabular}
caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
label{table:2}
end{table}
end{document}


I would like to add at the end of the table another column, with numbers. In addition, I would like to optimize the columns width so that the second column won't be so wide. How can I do it?










share|improve this question
















Here is my table:
table



This is my code for it:



documentclass[smallextended]{svjour3} 
usepackage{tabularx, booktabs, makecell} %
usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
renewcommand{thetable}{arabic{table}}
begin{document}
begin{table}[!htb]
centering
sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
setlength{tabcolsep}{3pt}
small
centering

sisetup{detect-weight,mode=text}
renewrobustcmd{bfseries}{fontseries{b}selectfont}
renewrobustcmd{boldmath}{}
% abbreviation
newrobustcmd{B}{bfseries}
% shorten the intercolumn spaces
setlength{tabcolsep}{4pt}
begin{tabularx}{linewidth}{l>{centering}XSSS}
toprule

thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
& {thead{PPPPPP Alg\ccc} } \ [0.5ex]
midrule
POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 \
POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 \
POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 \
POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754 \
CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
\
CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
\
AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 \
AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 \
JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 \
JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998\
JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 \
JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654 \ [1ex]
bottomrule
end{tabularx}
% end{tabular}
caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
label{table:2}
end{table}
end{document}


I would like to add at the end of the table another column, with numbers. In addition, I would like to optimize the columns width so that the second column won't be so wide. How can I do it?







tables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 18 at 14:57







Avi

















asked Feb 18 at 14:49









AviAvi

357514




357514








  • 1





    please, extend your code snippet to complete small document with your table. information contained in your document preamble are important for helping you. added one more column: just write it where you like to ad (& ...)

    – Zarko
    Feb 18 at 14:52













  • in your mwe are still missing some packages ... where you like to ad new column? after last in temporary table?

    – Zarko
    Feb 18 at 15:01














  • 1





    please, extend your code snippet to complete small document with your table. information contained in your document preamble are important for helping you. added one more column: just write it where you like to ad (& ...)

    – Zarko
    Feb 18 at 14:52













  • in your mwe are still missing some packages ... where you like to ad new column? after last in temporary table?

    – Zarko
    Feb 18 at 15:01








1




1





please, extend your code snippet to complete small document with your table. information contained in your document preamble are important for helping you. added one more column: just write it where you like to ad (& ...)

– Zarko
Feb 18 at 14:52







please, extend your code snippet to complete small document with your table. information contained in your document preamble are important for helping you. added one more column: just write it where you like to ad (& ...)

– Zarko
Feb 18 at 14:52















in your mwe are still missing some packages ... where you like to ad new column? after last in temporary table?

– Zarko
Feb 18 at 15:01





in your mwe are still missing some packages ... where you like to ad new column? after last in temporary table?

– Zarko
Feb 18 at 15:01










2 Answers
2






active

oldest

votes


















2














By using a tabularx and only having one X column, which is allowed to stretch, this column is forced to be very wide. If it should have its natural width, use a normal tabular instead.



For adding an additional column with numbers, add one S column and add them at the end of each line with & <number>



documentclass[smallextended]{svjour3} 
usepackage{tabularx, booktabs, makecell} %
usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
usepackage{siunitx}
usepackage{etoolbox}
renewcommand{thetable}{arabic{table}}
begin{document}
begin{table}[!htb]
centering
sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
setlength{tabcolsep}{3pt}
small
centering

sisetup{detect-weight,mode=text}
renewrobustcmd{bfseries}{fontseries{b}selectfont}
renewrobustcmd{boldmath}{}
% abbreviation
newrobustcmd{B}{bfseries}
% shorten the intercolumn spaces
setlength{tabcolsep}{4pt}
begin{tabular}{l>{centering}lSSSS}
toprule

thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
& {thead{PPPPPP Alg\ccc} } & {thead{foo}} \ [0.5ex]
midrule
POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 0.780 \
POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 0.780\
POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 & 0.780 \
POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754& 0.780 \
CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
& 0.780 \
CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
& 0.780 \
AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 & 0.780\
AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 & 0.780\
JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 & 0.780\
JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998& 0.780\
JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 & 0.780\
JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654& 0.780 \ [1ex]
bottomrule
end{tabular}
% end{tabular}
caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
label{table:2}
end{table}
end{document}


enter image description here






share|improve this answer

































    5














    documentclass[smallextended]{svjour3}
    usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
    usepackage{siunitx}
    usepackage{booktabs, makecell, tabularx}
    newcommandmcx[1]{multicolumn{1}{>{centeringarraybackslash}X}{#1}}
    usepackage{etoolbox}
    renewrobustcmd{bfseries}{fontseries{b}selectfont}
    newrobustcmd{B}{bfseries}

    %---------------- show page layout. don't use in a real document!
    usepackage{showframe}
    renewcommandShowFrameLinethickness{0.15pt}
    renewcommand*ShowFrameColor{color{red}}
    %---------------------------------------------------------------%

    begin{document}
    begin{table}[!htb]
    centering
    sisetup{table-format=1.3,
    detect-weight,
    mode=text}
    centering
    begin{tabularx}{linewidth}{ll SS SS}
    toprule
    mcx{DDDDDDnewline NNNNN}
    & mcx{No. of PPPPPP newline rrrrr}
    & mcx{Delta CCCCCnewline AAAA }
    & mcx{EEEEEEEEEEnewline ccc}
    & mcx{PPPPPP Algnewline ccc}
    & mcx{here isnewline new column}
    \
    midrule
    POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 1.234 \
    POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 5.678 \
    bottomrule
    end{tabularx}
    % end{tabular}
    caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
    label{table:2}
    end{table}
    end{document}


    enter image description here



    (red lines indicate page layout)



    above mwe provide equal widths of columns. since real content c cells and cells heads are unknown, this might not be the best choice. let me know. beside this, i move newcommands to document preamble and remove superfluous sisetup and preserve tabularx table environment.






    share|improve this answer

























      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%2f475506%2fadding-column-to-table-in-latex-and-optimizing-columns-width%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      By using a tabularx and only having one X column, which is allowed to stretch, this column is forced to be very wide. If it should have its natural width, use a normal tabular instead.



      For adding an additional column with numbers, add one S column and add them at the end of each line with & <number>



      documentclass[smallextended]{svjour3} 
      usepackage{tabularx, booktabs, makecell} %
      usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
      usepackage{siunitx}
      usepackage{etoolbox}
      renewcommand{thetable}{arabic{table}}
      begin{document}
      begin{table}[!htb]
      centering
      sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
      setlength{tabcolsep}{3pt}
      small
      centering

      sisetup{detect-weight,mode=text}
      renewrobustcmd{bfseries}{fontseries{b}selectfont}
      renewrobustcmd{boldmath}{}
      % abbreviation
      newrobustcmd{B}{bfseries}
      % shorten the intercolumn spaces
      setlength{tabcolsep}{4pt}
      begin{tabular}{l>{centering}lSSSS}
      toprule

      thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
      & {thead{PPPPPP Alg\ccc} } & {thead{foo}} \ [0.5ex]
      midrule
      POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 0.780 \
      POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 0.780\
      POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 & 0.780 \
      POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754& 0.780 \
      CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
      & 0.780 \
      CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
      & 0.780 \
      AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 & 0.780\
      AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 & 0.780\
      JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 & 0.780\
      JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998& 0.780\
      JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 & 0.780\
      JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654& 0.780 \ [1ex]
      bottomrule
      end{tabular}
      % end{tabular}
      caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
      label{table:2}
      end{table}
      end{document}


      enter image description here






      share|improve this answer






























        2














        By using a tabularx and only having one X column, which is allowed to stretch, this column is forced to be very wide. If it should have its natural width, use a normal tabular instead.



        For adding an additional column with numbers, add one S column and add them at the end of each line with & <number>



        documentclass[smallextended]{svjour3} 
        usepackage{tabularx, booktabs, makecell} %
        usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
        usepackage{siunitx}
        usepackage{etoolbox}
        renewcommand{thetable}{arabic{table}}
        begin{document}
        begin{table}[!htb]
        centering
        sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
        setlength{tabcolsep}{3pt}
        small
        centering

        sisetup{detect-weight,mode=text}
        renewrobustcmd{bfseries}{fontseries{b}selectfont}
        renewrobustcmd{boldmath}{}
        % abbreviation
        newrobustcmd{B}{bfseries}
        % shorten the intercolumn spaces
        setlength{tabcolsep}{4pt}
        begin{tabular}{l>{centering}lSSSS}
        toprule

        thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
        & {thead{PPPPPP Alg\ccc} } & {thead{foo}} \ [0.5ex]
        midrule
        POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 0.780 \
        POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 0.780\
        POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 & 0.780 \
        POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754& 0.780 \
        CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
        & 0.780 \
        CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
        & 0.780 \
        AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 & 0.780\
        AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 & 0.780\
        JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 & 0.780\
        JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998& 0.780\
        JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 & 0.780\
        JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654& 0.780 \ [1ex]
        bottomrule
        end{tabular}
        % end{tabular}
        caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
        label{table:2}
        end{table}
        end{document}


        enter image description here






        share|improve this answer




























          2












          2








          2







          By using a tabularx and only having one X column, which is allowed to stretch, this column is forced to be very wide. If it should have its natural width, use a normal tabular instead.



          For adding an additional column with numbers, add one S column and add them at the end of each line with & <number>



          documentclass[smallextended]{svjour3} 
          usepackage{tabularx, booktabs, makecell} %
          usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
          usepackage{siunitx}
          usepackage{etoolbox}
          renewcommand{thetable}{arabic{table}}
          begin{document}
          begin{table}[!htb]
          centering
          sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
          setlength{tabcolsep}{3pt}
          small
          centering

          sisetup{detect-weight,mode=text}
          renewrobustcmd{bfseries}{fontseries{b}selectfont}
          renewrobustcmd{boldmath}{}
          % abbreviation
          newrobustcmd{B}{bfseries}
          % shorten the intercolumn spaces
          setlength{tabcolsep}{4pt}
          begin{tabular}{l>{centering}lSSSS}
          toprule

          thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
          & {thead{PPPPPP Alg\ccc} } & {thead{foo}} \ [0.5ex]
          midrule
          POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 0.780 \
          POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 0.780\
          POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 & 0.780 \
          POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754& 0.780 \
          CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
          & 0.780 \
          CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
          & 0.780 \
          AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 & 0.780\
          AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 & 0.780\
          JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 & 0.780\
          JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998& 0.780\
          JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 & 0.780\
          JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654& 0.780 \ [1ex]
          bottomrule
          end{tabular}
          % end{tabular}
          caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
          label{table:2}
          end{table}
          end{document}


          enter image description here






          share|improve this answer















          By using a tabularx and only having one X column, which is allowed to stretch, this column is forced to be very wide. If it should have its natural width, use a normal tabular instead.



          For adding an additional column with numbers, add one S column and add them at the end of each line with & <number>



          documentclass[smallextended]{svjour3} 
          usepackage{tabularx, booktabs, makecell} %
          usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
          usepackage{siunitx}
          usepackage{etoolbox}
          renewcommand{thetable}{arabic{table}}
          begin{document}
          begin{table}[!htb]
          centering
          sisetup{table-format=1.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
          setlength{tabcolsep}{3pt}
          small
          centering

          sisetup{detect-weight,mode=text}
          renewrobustcmd{bfseries}{fontseries{b}selectfont}
          renewrobustcmd{boldmath}{}
          % abbreviation
          newrobustcmd{B}{bfseries}
          % shorten the intercolumn spaces
          setlength{tabcolsep}{4pt}
          begin{tabular}{l>{centering}lSSSS}
          toprule

          thead {DDDDDD \ NNNNN} & {thead{No. of PPPPPP \ rrrrr} }& {thead{Delta CCCCC\ AAAA }} & {thead{EEEEEEEEEE\ ccc} }
          & {thead{PPPPPP Alg\ccc} } & {thead{foo}} \ [0.5ex]
          midrule
          POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 0.780 \
          POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 0.780\
          POOO HHHH& AAAA to BBBB & 0.988 & B0.831 & B 0.831 & 0.780 \
          POOO HHHH& CCCC to DDDD & 0.780 & B0.784 & B 0.754& 0.780 \
          CCCCCCC & AAAA to BBBB & 0.622 & 0.723 & B 0.735
          & 0.780 \
          CCCCCCC & CCCC to DDDD & 0.563 & B0.674 & 0.665
          & 0.780 \
          AAAAAA & AAAA to BBBB & 0.956 & B 0.957 & 0.956 & 0.780\
          AAAAAA & CCCC to DDDD & 0.949 & B0.955 & B 0.955 & 0.780\
          JJJJJ & RRRRR & 0.999 & B 1.000 & 0.999 & 0.780\
          JJJJJ & KKKKKK & 0.998 & B 0.999 & 0.998& 0.780\
          JJJJJ & HSDFFDSSDF & 0.627 & 0.638 & B 0.646 & 0.780\
          JJJJJ & HSDFFDSSDF & 0.647 & 0.653 & B 0.654& 0.780 \ [1ex]
          bottomrule
          end{tabular}
          % end{tabular}
          caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
          label{table:2}
          end{table}
          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 18 at 15:30

























          answered Feb 18 at 15:24









          user181777user181777

          1185




          1185























              5














              documentclass[smallextended]{svjour3}
              usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
              usepackage{siunitx}
              usepackage{booktabs, makecell, tabularx}
              newcommandmcx[1]{multicolumn{1}{>{centeringarraybackslash}X}{#1}}
              usepackage{etoolbox}
              renewrobustcmd{bfseries}{fontseries{b}selectfont}
              newrobustcmd{B}{bfseries}

              %---------------- show page layout. don't use in a real document!
              usepackage{showframe}
              renewcommandShowFrameLinethickness{0.15pt}
              renewcommand*ShowFrameColor{color{red}}
              %---------------------------------------------------------------%

              begin{document}
              begin{table}[!htb]
              centering
              sisetup{table-format=1.3,
              detect-weight,
              mode=text}
              centering
              begin{tabularx}{linewidth}{ll SS SS}
              toprule
              mcx{DDDDDDnewline NNNNN}
              & mcx{No. of PPPPPP newline rrrrr}
              & mcx{Delta CCCCCnewline AAAA }
              & mcx{EEEEEEEEEEnewline ccc}
              & mcx{PPPPPP Algnewline ccc}
              & mcx{here isnewline new column}
              \
              midrule
              POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 1.234 \
              POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 5.678 \
              bottomrule
              end{tabularx}
              % end{tabular}
              caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
              label{table:2}
              end{table}
              end{document}


              enter image description here



              (red lines indicate page layout)



              above mwe provide equal widths of columns. since real content c cells and cells heads are unknown, this might not be the best choice. let me know. beside this, i move newcommands to document preamble and remove superfluous sisetup and preserve tabularx table environment.






              share|improve this answer






























                5














                documentclass[smallextended]{svjour3}
                usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
                usepackage{siunitx}
                usepackage{booktabs, makecell, tabularx}
                newcommandmcx[1]{multicolumn{1}{>{centeringarraybackslash}X}{#1}}
                usepackage{etoolbox}
                renewrobustcmd{bfseries}{fontseries{b}selectfont}
                newrobustcmd{B}{bfseries}

                %---------------- show page layout. don't use in a real document!
                usepackage{showframe}
                renewcommandShowFrameLinethickness{0.15pt}
                renewcommand*ShowFrameColor{color{red}}
                %---------------------------------------------------------------%

                begin{document}
                begin{table}[!htb]
                centering
                sisetup{table-format=1.3,
                detect-weight,
                mode=text}
                centering
                begin{tabularx}{linewidth}{ll SS SS}
                toprule
                mcx{DDDDDDnewline NNNNN}
                & mcx{No. of PPPPPP newline rrrrr}
                & mcx{Delta CCCCCnewline AAAA }
                & mcx{EEEEEEEEEEnewline ccc}
                & mcx{PPPPPP Algnewline ccc}
                & mcx{here isnewline new column}
                \
                midrule
                POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 1.234 \
                POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 5.678 \
                bottomrule
                end{tabularx}
                % end{tabular}
                caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
                label{table:2}
                end{table}
                end{document}


                enter image description here



                (red lines indicate page layout)



                above mwe provide equal widths of columns. since real content c cells and cells heads are unknown, this might not be the best choice. let me know. beside this, i move newcommands to document preamble and remove superfluous sisetup and preserve tabularx table environment.






                share|improve this answer




























                  5












                  5








                  5







                  documentclass[smallextended]{svjour3}
                  usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
                  usepackage{siunitx}
                  usepackage{booktabs, makecell, tabularx}
                  newcommandmcx[1]{multicolumn{1}{>{centeringarraybackslash}X}{#1}}
                  usepackage{etoolbox}
                  renewrobustcmd{bfseries}{fontseries{b}selectfont}
                  newrobustcmd{B}{bfseries}

                  %---------------- show page layout. don't use in a real document!
                  usepackage{showframe}
                  renewcommandShowFrameLinethickness{0.15pt}
                  renewcommand*ShowFrameColor{color{red}}
                  %---------------------------------------------------------------%

                  begin{document}
                  begin{table}[!htb]
                  centering
                  sisetup{table-format=1.3,
                  detect-weight,
                  mode=text}
                  centering
                  begin{tabularx}{linewidth}{ll SS SS}
                  toprule
                  mcx{DDDDDDnewline NNNNN}
                  & mcx{No. of PPPPPP newline rrrrr}
                  & mcx{Delta CCCCCnewline AAAA }
                  & mcx{EEEEEEEEEEnewline ccc}
                  & mcx{PPPPPP Algnewline ccc}
                  & mcx{here isnewline new column}
                  \
                  midrule
                  POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 1.234 \
                  POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 5.678 \
                  bottomrule
                  end{tabularx}
                  % end{tabular}
                  caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
                  label{table:2}
                  end{table}
                  end{document}


                  enter image description here



                  (red lines indicate page layout)



                  above mwe provide equal widths of columns. since real content c cells and cells heads are unknown, this might not be the best choice. let me know. beside this, i move newcommands to document preamble and remove superfluous sisetup and preserve tabularx table environment.






                  share|improve this answer















                  documentclass[smallextended]{svjour3}
                  usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
                  usepackage{siunitx}
                  usepackage{booktabs, makecell, tabularx}
                  newcommandmcx[1]{multicolumn{1}{>{centeringarraybackslash}X}{#1}}
                  usepackage{etoolbox}
                  renewrobustcmd{bfseries}{fontseries{b}selectfont}
                  newrobustcmd{B}{bfseries}

                  %---------------- show page layout. don't use in a real document!
                  usepackage{showframe}
                  renewcommandShowFrameLinethickness{0.15pt}
                  renewcommand*ShowFrameColor{color{red}}
                  %---------------------------------------------------------------%

                  begin{document}
                  begin{table}[!htb]
                  centering
                  sisetup{table-format=1.3,
                  detect-weight,
                  mode=text}
                  centering
                  begin{tabularx}{linewidth}{ll SS SS}
                  toprule
                  mcx{DDDDDDnewline NNNNN}
                  & mcx{No. of PPPPPP newline rrrrr}
                  & mcx{Delta CCCCCnewline AAAA }
                  & mcx{EEEEEEEEEEnewline ccc}
                  & mcx{PPPPPP Algnewline ccc}
                  & mcx{here isnewline new column}
                  \
                  midrule
                  POOO HHHH & AAAA to BBBB & 0.524 & 0.546 & B 0.547 & 1.234 \
                  POOO HHHH & CCCC to DDDD & 0.554 & B 0.546 & B 0.546 & 5.678 \
                  bottomrule
                  end{tabularx}
                  % end{tabular}
                  caption{Comparison between aaaaa to bbbbb (In textbf{Bold} the most accurate per line)}
                  label{table:2}
                  end{table}
                  end{document}


                  enter image description here



                  (red lines indicate page layout)



                  above mwe provide equal widths of columns. since real content c cells and cells heads are unknown, this might not be the best choice. let me know. beside this, i move newcommands to document preamble and remove superfluous sisetup and preserve tabularx table environment.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 18 at 16:15

























                  answered Feb 18 at 15:26









                  ZarkoZarko

                  127k868167




                  127k868167






























                      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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475506%2fadding-column-to-table-in-latex-and-optimizing-columns-width%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 do I know what Microsoft account the skydrive app is syncing to?

                      When does type information flow backwards in C++?

                      Grease: Live!