Adding column to table in Latex and optimizing columns width
Here is my 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
add a comment |
Here is my 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
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
Thanks @Zarko, I added.
– Avi
Feb 18 at 14:58
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
add a comment |
Here is my 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
Here is my 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
tables
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
Thanks @Zarko, I added.
– Avi
Feb 18 at 14:58
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
add a comment |
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
Thanks @Zarko, I added.
– Avi
Feb 18 at 14:58
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
Thanks @Zarko, I added.
– Avi
Feb 18 at 14:58
Thanks @Zarko, I added.
– Avi
Feb 18 at 14:58
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
add a comment |
2 Answers
2
active
oldest
votes
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}
add a comment |
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}
(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 newcommand
s to document preamble and remove superfluous sisetup
and preserve tabularx
table environment.
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%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
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}
add a comment |
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}
add a comment |
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}
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}
edited Feb 18 at 15:30
answered Feb 18 at 15:24
user181777user181777
1085
1085
add a comment |
add a comment |
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}
(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 newcommand
s to document preamble and remove superfluous sisetup
and preserve tabularx
table environment.
add a comment |
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}
(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 newcommand
s to document preamble and remove superfluous sisetup
and preserve tabularx
table environment.
add a comment |
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}
(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 newcommand
s to document preamble and remove superfluous sisetup
and preserve tabularx
table environment.
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}
(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 newcommand
s to document preamble and remove superfluous sisetup
and preserve tabularx
table environment.
edited Feb 18 at 16:15
answered Feb 18 at 15:26
ZarkoZarko
125k867164
125k867164
add a comment |
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.
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%2f475506%2fadding-column-to-table-in-latex-and-optimizing-columns-width%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
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
Thanks @Zarko, I added.
– Avi
Feb 18 at 14:58
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