Unexpected space in table
up vote
6
down vote
favorite
I try to create a table in latex, however, the space between some columns is very unexpected.
Here is my working example:
begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}
If the title of the table is short then, there is no problem.
Any help, please?
tables
add a comment |
up vote
6
down vote
favorite
I try to create a table in latex, however, the space between some columns is very unexpected.
Here is my working example:
begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}
If the title of the table is short then, there is no problem.
Any help, please?
tables
1
Consider usingbooktabs
...
– Werner
Dec 2 at 7:31
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I try to create a table in latex, however, the space between some columns is very unexpected.
Here is my working example:
begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}
If the title of the table is short then, there is no problem.
Any help, please?
tables
I try to create a table in latex, however, the space between some columns is very unexpected.
Here is my working example:
begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}
If the title of the table is short then, there is no problem.
Any help, please?
tables
tables
asked Dec 2 at 6:47
Maryam
457
457
1
Consider usingbooktabs
...
– Werner
Dec 2 at 7:31
add a comment |
1
Consider usingbooktabs
...
– Werner
Dec 2 at 7:31
1
1
Consider using
booktabs
...– Werner
Dec 2 at 7:31
Consider using
booktabs
...– Werner
Dec 2 at 7:31
add a comment |
2 Answers
2
active
oldest
votes
up vote
10
down vote
accepted
Reason
The title of your table is considered as an element in Column 3.
Fix
documentclass{article}
begin{document}
begin{table}
centering
begin{tabular}{cccccc}
hlinehline
multicolumn{6}{c}{The title of my table is long}\
hlinehline
Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
1 & 1400 & 1450 & 300 & 3340 & 0 \
2 & & & & & \
3 & & & & & \
hlinehline
end{tabular}
caption{Caption}
end{table}
end{document}
add a comment |
up vote
12
down vote
As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.
One way to fix this issue is to let the title string span all 6 columns of the tabular
environment, via a multicolumn{6}{c}{...}
directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table
and that it should not be placed inside the tabular
environment. Instead, it should be placed inside the argument of caption
, and the caption
statement should likely be placed above rather than below the tabular
material.
While you're at it, you may also want to improve the "look" of the table by replacing the hline
statements with toprule
, midrule
, and bottomrule
-- macros provided by the booktabs package.
The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn
, and (3) the fix achieved by moving the title outside of the tabular
environment (and using the line-drawing macros of the booktabs
package).
documentclass{article}
usepackage{booktabs}
usepackage[skip=0.333baselineskip]{caption} % optional
begin{document}
begin{table}[ht!] %% OP's original code
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \
hline hline
Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_1}
end{table}
begin{table}[h] %% using multicolumn to fix the spacing issue
centering
begin{tabular}{c c c c c c}
hline hline
multicolumn{6}{c}{The title of my table is long}\
hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_2}
end{table}
begin{table}[h] %% using caption and the macros of the booktabs package
caption{The title of my table}
label{tab:my_label_3}
centering
begin{tabular}{@{} *{6}{c} @{}}
toprule
Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
midrule
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
bottomrule
end{tabular}
end{table}
end{document}
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
Reason
The title of your table is considered as an element in Column 3.
Fix
documentclass{article}
begin{document}
begin{table}
centering
begin{tabular}{cccccc}
hlinehline
multicolumn{6}{c}{The title of my table is long}\
hlinehline
Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
1 & 1400 & 1450 & 300 & 3340 & 0 \
2 & & & & & \
3 & & & & & \
hlinehline
end{tabular}
caption{Caption}
end{table}
end{document}
add a comment |
up vote
10
down vote
accepted
Reason
The title of your table is considered as an element in Column 3.
Fix
documentclass{article}
begin{document}
begin{table}
centering
begin{tabular}{cccccc}
hlinehline
multicolumn{6}{c}{The title of my table is long}\
hlinehline
Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
1 & 1400 & 1450 & 300 & 3340 & 0 \
2 & & & & & \
3 & & & & & \
hlinehline
end{tabular}
caption{Caption}
end{table}
end{document}
add a comment |
up vote
10
down vote
accepted
up vote
10
down vote
accepted
Reason
The title of your table is considered as an element in Column 3.
Fix
documentclass{article}
begin{document}
begin{table}
centering
begin{tabular}{cccccc}
hlinehline
multicolumn{6}{c}{The title of my table is long}\
hlinehline
Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
1 & 1400 & 1450 & 300 & 3340 & 0 \
2 & & & & & \
3 & & & & & \
hlinehline
end{tabular}
caption{Caption}
end{table}
end{document}
Reason
The title of your table is considered as an element in Column 3.
Fix
documentclass{article}
begin{document}
begin{table}
centering
begin{tabular}{cccccc}
hlinehline
multicolumn{6}{c}{The title of my table is long}\
hlinehline
Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
1 & 1400 & 1450 & 300 & 3340 & 0 \
2 & & & & & \
3 & & & & & \
hlinehline
end{tabular}
caption{Caption}
end{table}
end{document}
edited Dec 2 at 10:57
answered Dec 2 at 7:11
JouleV
1,777425
1,777425
add a comment |
add a comment |
up vote
12
down vote
As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.
One way to fix this issue is to let the title string span all 6 columns of the tabular
environment, via a multicolumn{6}{c}{...}
directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table
and that it should not be placed inside the tabular
environment. Instead, it should be placed inside the argument of caption
, and the caption
statement should likely be placed above rather than below the tabular
material.
While you're at it, you may also want to improve the "look" of the table by replacing the hline
statements with toprule
, midrule
, and bottomrule
-- macros provided by the booktabs package.
The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn
, and (3) the fix achieved by moving the title outside of the tabular
environment (and using the line-drawing macros of the booktabs
package).
documentclass{article}
usepackage{booktabs}
usepackage[skip=0.333baselineskip]{caption} % optional
begin{document}
begin{table}[ht!] %% OP's original code
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \
hline hline
Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_1}
end{table}
begin{table}[h] %% using multicolumn to fix the spacing issue
centering
begin{tabular}{c c c c c c}
hline hline
multicolumn{6}{c}{The title of my table is long}\
hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_2}
end{table}
begin{table}[h] %% using caption and the macros of the booktabs package
caption{The title of my table}
label{tab:my_label_3}
centering
begin{tabular}{@{} *{6}{c} @{}}
toprule
Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
midrule
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
bottomrule
end{tabular}
end{table}
end{document}
add a comment |
up vote
12
down vote
As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.
One way to fix this issue is to let the title string span all 6 columns of the tabular
environment, via a multicolumn{6}{c}{...}
directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table
and that it should not be placed inside the tabular
environment. Instead, it should be placed inside the argument of caption
, and the caption
statement should likely be placed above rather than below the tabular
material.
While you're at it, you may also want to improve the "look" of the table by replacing the hline
statements with toprule
, midrule
, and bottomrule
-- macros provided by the booktabs package.
The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn
, and (3) the fix achieved by moving the title outside of the tabular
environment (and using the line-drawing macros of the booktabs
package).
documentclass{article}
usepackage{booktabs}
usepackage[skip=0.333baselineskip]{caption} % optional
begin{document}
begin{table}[ht!] %% OP's original code
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \
hline hline
Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_1}
end{table}
begin{table}[h] %% using multicolumn to fix the spacing issue
centering
begin{tabular}{c c c c c c}
hline hline
multicolumn{6}{c}{The title of my table is long}\
hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_2}
end{table}
begin{table}[h] %% using caption and the macros of the booktabs package
caption{The title of my table}
label{tab:my_label_3}
centering
begin{tabular}{@{} *{6}{c} @{}}
toprule
Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
midrule
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
bottomrule
end{tabular}
end{table}
end{document}
add a comment |
up vote
12
down vote
up vote
12
down vote
As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.
One way to fix this issue is to let the title string span all 6 columns of the tabular
environment, via a multicolumn{6}{c}{...}
directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table
and that it should not be placed inside the tabular
environment. Instead, it should be placed inside the argument of caption
, and the caption
statement should likely be placed above rather than below the tabular
material.
While you're at it, you may also want to improve the "look" of the table by replacing the hline
statements with toprule
, midrule
, and bottomrule
-- macros provided by the booktabs package.
The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn
, and (3) the fix achieved by moving the title outside of the tabular
environment (and using the line-drawing macros of the booktabs
package).
documentclass{article}
usepackage{booktabs}
usepackage[skip=0.333baselineskip]{caption} % optional
begin{document}
begin{table}[ht!] %% OP's original code
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \
hline hline
Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_1}
end{table}
begin{table}[h] %% using multicolumn to fix the spacing issue
centering
begin{tabular}{c c c c c c}
hline hline
multicolumn{6}{c}{The title of my table is long}\
hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_2}
end{table}
begin{table}[h] %% using caption and the macros of the booktabs package
caption{The title of my table}
label{tab:my_label_3}
centering
begin{tabular}{@{} *{6}{c} @{}}
toprule
Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
midrule
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
bottomrule
end{tabular}
end{table}
end{document}
As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.
One way to fix this issue is to let the title string span all 6 columns of the tabular
environment, via a multicolumn{6}{c}{...}
directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table
and that it should not be placed inside the tabular
environment. Instead, it should be placed inside the argument of caption
, and the caption
statement should likely be placed above rather than below the tabular
material.
While you're at it, you may also want to improve the "look" of the table by replacing the hline
statements with toprule
, midrule
, and bottomrule
-- macros provided by the booktabs package.
The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn
, and (3) the fix achieved by moving the title outside of the tabular
environment (and using the line-drawing macros of the booktabs
package).
documentclass{article}
usepackage{booktabs}
usepackage[skip=0.333baselineskip]{caption} % optional
begin{document}
begin{table}[ht!] %% OP's original code
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \
hline hline
Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_1}
end{table}
begin{table}[h] %% using multicolumn to fix the spacing issue
centering
begin{tabular}{c c c c c c}
hline hline
multicolumn{6}{c}{The title of my table is long}\
hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
hline hline
end{tabular}
caption{Caption}
label{tab:my_label_2}
end{table}
begin{table}[h] %% using caption and the macros of the booktabs package
caption{The title of my table}
label{tab:my_label_3}
centering
begin{tabular}{@{} *{6}{c} @{}}
toprule
Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
midrule
1 & 1400 & 1450& 300 &3340 & 4400 \
2 & & & & & \
3 & & & & & \
bottomrule
end{tabular}
end{table}
end{document}
edited Dec 2 at 8:08
answered Dec 2 at 7:52
Mico
272k30369756
272k30369756
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462788%2funexpected-space-in-table%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
Consider using
booktabs
...– Werner
Dec 2 at 7:31