Multicolumn (Tables) trouble
I am trying to get my table working for last couple of days. But I couldnt fix the problem. The way I want my table to look like is below (figure 1).
With my following code
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{l}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
I am getting (figure 2):
I tried using tabularx and defined the size of each column. It worked until I added last long row (which is a merged form of all 9 columns). Also the the header "B" and last coulmn (figure 1) is going out of the page in figure 2.
It would be nice if someone can help me. Also, detailed explanation of the solution would be appreciated.
Thanks in advance.
tables tabularx wrap
add a comment |
I am trying to get my table working for last couple of days. But I couldnt fix the problem. The way I want my table to look like is below (figure 1).
With my following code
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{l}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
I am getting (figure 2):
I tried using tabularx and defined the size of each column. It worked until I added last long row (which is a merged form of all 9 columns). Also the the header "B" and last coulmn (figure 1) is going out of the page in figure 2.
It would be nice if someone can help me. Also, detailed explanation of the solution would be appreciated.
Thanks in advance.
tables tabularx wrap
2
By using thel
column type for the super-long word, you’ve disabled automatic line-breaking. Even if you chose a different column type, i.e., a column type that allows line breaking, how is LaTeX even supposed to decide how and where to insert line breaks in the super-long word?
– Mico
2 days ago
Thanks, @Mico for your replay. I changed now a long word with a bunch of "Blah Blah"s (so latex should know where to break the line) and also changed column type froml
toc
. However, the problem isn't solved. Definitely, I am doing something wrong.
– pukumarathe
2 days ago
2
Thec
,l
, andr
column types do no allow line breaking.
– Mico
2 days ago
2
we need to know your page layout and desired width of table. ...
– Zarko
2 days ago
add a comment |
I am trying to get my table working for last couple of days. But I couldnt fix the problem. The way I want my table to look like is below (figure 1).
With my following code
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{l}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
I am getting (figure 2):
I tried using tabularx and defined the size of each column. It worked until I added last long row (which is a merged form of all 9 columns). Also the the header "B" and last coulmn (figure 1) is going out of the page in figure 2.
It would be nice if someone can help me. Also, detailed explanation of the solution would be appreciated.
Thanks in advance.
tables tabularx wrap
I am trying to get my table working for last couple of days. But I couldnt fix the problem. The way I want my table to look like is below (figure 1).
With my following code
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{l}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
I am getting (figure 2):
I tried using tabularx and defined the size of each column. It worked until I added last long row (which is a merged form of all 9 columns). Also the the header "B" and last coulmn (figure 1) is going out of the page in figure 2.
It would be nice if someone can help me. Also, detailed explanation of the solution would be appreciated.
Thanks in advance.
tables tabularx wrap
tables tabularx wrap
edited 2 days ago
Mico
274k30371758
274k30371758
asked Jan 5 at 18:08
pukumarathepukumarathe
526
526
2
By using thel
column type for the super-long word, you’ve disabled automatic line-breaking. Even if you chose a different column type, i.e., a column type that allows line breaking, how is LaTeX even supposed to decide how and where to insert line breaks in the super-long word?
– Mico
2 days ago
Thanks, @Mico for your replay. I changed now a long word with a bunch of "Blah Blah"s (so latex should know where to break the line) and also changed column type froml
toc
. However, the problem isn't solved. Definitely, I am doing something wrong.
– pukumarathe
2 days ago
2
Thec
,l
, andr
column types do no allow line breaking.
– Mico
2 days ago
2
we need to know your page layout and desired width of table. ...
– Zarko
2 days ago
add a comment |
2
By using thel
column type for the super-long word, you’ve disabled automatic line-breaking. Even if you chose a different column type, i.e., a column type that allows line breaking, how is LaTeX even supposed to decide how and where to insert line breaks in the super-long word?
– Mico
2 days ago
Thanks, @Mico for your replay. I changed now a long word with a bunch of "Blah Blah"s (so latex should know where to break the line) and also changed column type froml
toc
. However, the problem isn't solved. Definitely, I am doing something wrong.
– pukumarathe
2 days ago
2
Thec
,l
, andr
column types do no allow line breaking.
– Mico
2 days ago
2
we need to know your page layout and desired width of table. ...
– Zarko
2 days ago
2
2
By using the
l
column type for the super-long word, you’ve disabled automatic line-breaking. Even if you chose a different column type, i.e., a column type that allows line breaking, how is LaTeX even supposed to decide how and where to insert line breaks in the super-long word?– Mico
2 days ago
By using the
l
column type for the super-long word, you’ve disabled automatic line-breaking. Even if you chose a different column type, i.e., a column type that allows line breaking, how is LaTeX even supposed to decide how and where to insert line breaks in the super-long word?– Mico
2 days ago
Thanks, @Mico for your replay. I changed now a long word with a bunch of "Blah Blah"s (so latex should know where to break the line) and also changed column type from
l
to c
. However, the problem isn't solved. Definitely, I am doing something wrong.– pukumarathe
2 days ago
Thanks, @Mico for your replay. I changed now a long word with a bunch of "Blah Blah"s (so latex should know where to break the line) and also changed column type from
l
to c
. However, the problem isn't solved. Definitely, I am doing something wrong.– pukumarathe
2 days ago
2
2
The
c
, l
, and r
column types do no allow line breaking.– Mico
2 days ago
The
c
, l
, and r
column types do no allow line breaking.– Mico
2 days ago
2
2
we need to know your page layout and desired width of table. ...
– Zarko
2 days ago
we need to know your page layout and desired width of table. ...
– Zarko
2 days ago
add a comment |
3 Answers
3
active
oldest
votes
As far as I can tell, the "Blah Blah ..." material is only indirectly related to the preceding, table-like material. Is the "Blah Blah" material maybe some kind of legend? If this guess is correct, you'd be better off not placing it inside the tabular
environment. Instead, I suggest you load the threeparttable
package and place the legend in a tablenotes
environment, which (thanks to the behind-the-scenes work of the threeparttable
environment) will automatically be as wide as the preceding tabular
environment.
In case you're curious about the name threeparttable
of the package: It can handle three types of elements: The table caption (which is absent in the case of your code), the tabular
-like material, and the tablenotes
material. The package works, though, even if there is no caption.
documentclass{article}
usepackage[flushleft]{threeparttable}
begin{document}
begin{table}
centering
begin{threeparttable}
begin{tabular}{@{} l *{8}{c} @{}}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B}
& multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \
hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2}
& multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \
hline
end{tabular}
smallskip
begin{tablenotes}
itemNotes: Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
end{tablenotes}
end{threeparttable}
end{table}
end{document}
Thanks a lot @Mico ! I really liked this arrangement of having tablenotes. It precisely solved my problem. :)
– pukumarathe
2 days ago
add a comment |
since you tag your question with tabularx
i suggest to use this package. beside it more nice result you will obtain by use of the booktabs
package for horizontal rules:
documentclass{article}
usepackage{booktabs, tabularx}
newcolumntype{C}{>{centeringarraybackslash}X}
newcommandmcc[1]{multicolumn{2}{c}{#1}}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
begin{table}[p]
begin{tabularx}{linewidth}{@{} c *{8}{C} @{}}
toprule
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
cmidrule(lr){2-5}cmidrule(l){6-9}
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
cmidrule(lr){2-3}cmidrule(lr){4-5}
cmidrule(lr){6-7}cmidrule(lr){8-9}
feedstock & mcc{C} & mcc{B} & mcc{C} & mcc{B} \
midrule
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & mcc{1} & mcc{2} & mcc{3} & mcc{4} \
midrule
multicolumn{9}{@{} p{linewidth} @{}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \
bottomrule
end{tabularx}
end{table}
end{document}
(red lines indicate text border)
add a comment |
You can add width argument to your columns, like multicolumn{9}{p{linewidth}}
. Perhaps multicolumn{9}{p{.7linewidth}}
will do even better. Addding this to your example produces the following https://imgur.com/WcNyPXb
Here is the complete code of mwe
documentclass{article}
begin{document}
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{p{linewidth}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
end{document}
New contributor
1
Your solution has the (presumably unintended) side-effect of making the final column very wide indeed in case the combined width of the 9 columns is less thanlinewidth
. Can you think of a way of avoiding this issue?
– Mico
2 days ago
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%2f468732%2fmulticolumn-tables-trouble%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
As far as I can tell, the "Blah Blah ..." material is only indirectly related to the preceding, table-like material. Is the "Blah Blah" material maybe some kind of legend? If this guess is correct, you'd be better off not placing it inside the tabular
environment. Instead, I suggest you load the threeparttable
package and place the legend in a tablenotes
environment, which (thanks to the behind-the-scenes work of the threeparttable
environment) will automatically be as wide as the preceding tabular
environment.
In case you're curious about the name threeparttable
of the package: It can handle three types of elements: The table caption (which is absent in the case of your code), the tabular
-like material, and the tablenotes
material. The package works, though, even if there is no caption.
documentclass{article}
usepackage[flushleft]{threeparttable}
begin{document}
begin{table}
centering
begin{threeparttable}
begin{tabular}{@{} l *{8}{c} @{}}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B}
& multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \
hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2}
& multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \
hline
end{tabular}
smallskip
begin{tablenotes}
itemNotes: Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
end{tablenotes}
end{threeparttable}
end{table}
end{document}
Thanks a lot @Mico ! I really liked this arrangement of having tablenotes. It precisely solved my problem. :)
– pukumarathe
2 days ago
add a comment |
As far as I can tell, the "Blah Blah ..." material is only indirectly related to the preceding, table-like material. Is the "Blah Blah" material maybe some kind of legend? If this guess is correct, you'd be better off not placing it inside the tabular
environment. Instead, I suggest you load the threeparttable
package and place the legend in a tablenotes
environment, which (thanks to the behind-the-scenes work of the threeparttable
environment) will automatically be as wide as the preceding tabular
environment.
In case you're curious about the name threeparttable
of the package: It can handle three types of elements: The table caption (which is absent in the case of your code), the tabular
-like material, and the tablenotes
material. The package works, though, even if there is no caption.
documentclass{article}
usepackage[flushleft]{threeparttable}
begin{document}
begin{table}
centering
begin{threeparttable}
begin{tabular}{@{} l *{8}{c} @{}}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B}
& multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \
hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2}
& multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \
hline
end{tabular}
smallskip
begin{tablenotes}
itemNotes: Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
end{tablenotes}
end{threeparttable}
end{table}
end{document}
Thanks a lot @Mico ! I really liked this arrangement of having tablenotes. It precisely solved my problem. :)
– pukumarathe
2 days ago
add a comment |
As far as I can tell, the "Blah Blah ..." material is only indirectly related to the preceding, table-like material. Is the "Blah Blah" material maybe some kind of legend? If this guess is correct, you'd be better off not placing it inside the tabular
environment. Instead, I suggest you load the threeparttable
package and place the legend in a tablenotes
environment, which (thanks to the behind-the-scenes work of the threeparttable
environment) will automatically be as wide as the preceding tabular
environment.
In case you're curious about the name threeparttable
of the package: It can handle three types of elements: The table caption (which is absent in the case of your code), the tabular
-like material, and the tablenotes
material. The package works, though, even if there is no caption.
documentclass{article}
usepackage[flushleft]{threeparttable}
begin{document}
begin{table}
centering
begin{threeparttable}
begin{tabular}{@{} l *{8}{c} @{}}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B}
& multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \
hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2}
& multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \
hline
end{tabular}
smallskip
begin{tablenotes}
itemNotes: Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
end{tablenotes}
end{threeparttable}
end{table}
end{document}
As far as I can tell, the "Blah Blah ..." material is only indirectly related to the preceding, table-like material. Is the "Blah Blah" material maybe some kind of legend? If this guess is correct, you'd be better off not placing it inside the tabular
environment. Instead, I suggest you load the threeparttable
package and place the legend in a tablenotes
environment, which (thanks to the behind-the-scenes work of the threeparttable
environment) will automatically be as wide as the preceding tabular
environment.
In case you're curious about the name threeparttable
of the package: It can handle three types of elements: The table caption (which is absent in the case of your code), the tabular
-like material, and the tablenotes
material. The package works, though, even if there is no caption.
documentclass{article}
usepackage[flushleft]{threeparttable}
begin{document}
begin{table}
centering
begin{threeparttable}
begin{tabular}{@{} l *{8}{c} @{}}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B}
& multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \
hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2}
& multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \
hline
end{tabular}
smallskip
begin{tablenotes}
itemNotes: Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
end{tablenotes}
end{threeparttable}
end{table}
end{document}
edited 2 days ago
answered 2 days ago
MicoMico
274k30371758
274k30371758
Thanks a lot @Mico ! I really liked this arrangement of having tablenotes. It precisely solved my problem. :)
– pukumarathe
2 days ago
add a comment |
Thanks a lot @Mico ! I really liked this arrangement of having tablenotes. It precisely solved my problem. :)
– pukumarathe
2 days ago
Thanks a lot @Mico ! I really liked this arrangement of having tablenotes. It precisely solved my problem. :)
– pukumarathe
2 days ago
Thanks a lot @Mico ! I really liked this arrangement of having tablenotes. It precisely solved my problem. :)
– pukumarathe
2 days ago
add a comment |
since you tag your question with tabularx
i suggest to use this package. beside it more nice result you will obtain by use of the booktabs
package for horizontal rules:
documentclass{article}
usepackage{booktabs, tabularx}
newcolumntype{C}{>{centeringarraybackslash}X}
newcommandmcc[1]{multicolumn{2}{c}{#1}}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
begin{table}[p]
begin{tabularx}{linewidth}{@{} c *{8}{C} @{}}
toprule
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
cmidrule(lr){2-5}cmidrule(l){6-9}
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
cmidrule(lr){2-3}cmidrule(lr){4-5}
cmidrule(lr){6-7}cmidrule(lr){8-9}
feedstock & mcc{C} & mcc{B} & mcc{C} & mcc{B} \
midrule
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & mcc{1} & mcc{2} & mcc{3} & mcc{4} \
midrule
multicolumn{9}{@{} p{linewidth} @{}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \
bottomrule
end{tabularx}
end{table}
end{document}
(red lines indicate text border)
add a comment |
since you tag your question with tabularx
i suggest to use this package. beside it more nice result you will obtain by use of the booktabs
package for horizontal rules:
documentclass{article}
usepackage{booktabs, tabularx}
newcolumntype{C}{>{centeringarraybackslash}X}
newcommandmcc[1]{multicolumn{2}{c}{#1}}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
begin{table}[p]
begin{tabularx}{linewidth}{@{} c *{8}{C} @{}}
toprule
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
cmidrule(lr){2-5}cmidrule(l){6-9}
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
cmidrule(lr){2-3}cmidrule(lr){4-5}
cmidrule(lr){6-7}cmidrule(lr){8-9}
feedstock & mcc{C} & mcc{B} & mcc{C} & mcc{B} \
midrule
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & mcc{1} & mcc{2} & mcc{3} & mcc{4} \
midrule
multicolumn{9}{@{} p{linewidth} @{}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \
bottomrule
end{tabularx}
end{table}
end{document}
(red lines indicate text border)
add a comment |
since you tag your question with tabularx
i suggest to use this package. beside it more nice result you will obtain by use of the booktabs
package for horizontal rules:
documentclass{article}
usepackage{booktabs, tabularx}
newcolumntype{C}{>{centeringarraybackslash}X}
newcommandmcc[1]{multicolumn{2}{c}{#1}}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
begin{table}[p]
begin{tabularx}{linewidth}{@{} c *{8}{C} @{}}
toprule
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
cmidrule(lr){2-5}cmidrule(l){6-9}
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
cmidrule(lr){2-3}cmidrule(lr){4-5}
cmidrule(lr){6-7}cmidrule(lr){8-9}
feedstock & mcc{C} & mcc{B} & mcc{C} & mcc{B} \
midrule
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & mcc{1} & mcc{2} & mcc{3} & mcc{4} \
midrule
multicolumn{9}{@{} p{linewidth} @{}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \
bottomrule
end{tabularx}
end{table}
end{document}
(red lines indicate text border)
since you tag your question with tabularx
i suggest to use this package. beside it more nice result you will obtain by use of the booktabs
package for horizontal rules:
documentclass{article}
usepackage{booktabs, tabularx}
newcolumntype{C}{>{centeringarraybackslash}X}
newcommandmcc[1]{multicolumn{2}{c}{#1}}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
begin{table}[p]
begin{tabularx}{linewidth}{@{} c *{8}{C} @{}}
toprule
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
cmidrule(lr){2-5}cmidrule(l){6-9}
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
cmidrule(lr){2-3}cmidrule(lr){4-5}
cmidrule(lr){6-7}cmidrule(lr){8-9}
feedstock & mcc{C} & mcc{B} & mcc{C} & mcc{B} \
midrule
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & mcc{1} & mcc{2} & mcc{3} & mcc{4} \
midrule
multicolumn{9}{@{} p{linewidth} @{}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \
bottomrule
end{tabularx}
end{table}
end{document}
(red lines indicate text border)
edited 2 days ago
answered 2 days ago
ZarkoZarko
121k865158
121k865158
add a comment |
add a comment |
You can add width argument to your columns, like multicolumn{9}{p{linewidth}}
. Perhaps multicolumn{9}{p{.7linewidth}}
will do even better. Addding this to your example produces the following https://imgur.com/WcNyPXb
Here is the complete code of mwe
documentclass{article}
begin{document}
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{p{linewidth}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
end{document}
New contributor
1
Your solution has the (presumably unintended) side-effect of making the final column very wide indeed in case the combined width of the 9 columns is less thanlinewidth
. Can you think of a way of avoiding this issue?
– Mico
2 days ago
add a comment |
You can add width argument to your columns, like multicolumn{9}{p{linewidth}}
. Perhaps multicolumn{9}{p{.7linewidth}}
will do even better. Addding this to your example produces the following https://imgur.com/WcNyPXb
Here is the complete code of mwe
documentclass{article}
begin{document}
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{p{linewidth}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
end{document}
New contributor
1
Your solution has the (presumably unintended) side-effect of making the final column very wide indeed in case the combined width of the 9 columns is less thanlinewidth
. Can you think of a way of avoiding this issue?
– Mico
2 days ago
add a comment |
You can add width argument to your columns, like multicolumn{9}{p{linewidth}}
. Perhaps multicolumn{9}{p{.7linewidth}}
will do even better. Addding this to your example produces the following https://imgur.com/WcNyPXb
Here is the complete code of mwe
documentclass{article}
begin{document}
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{p{linewidth}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
end{document}
New contributor
You can add width argument to your columns, like multicolumn{9}{p{linewidth}}
. Perhaps multicolumn{9}{p{.7linewidth}}
will do even better. Addding this to your example produces the following https://imgur.com/WcNyPXb
Here is the complete code of mwe
documentclass{article}
begin{document}
begin{table}[p]
begin{tabular}{ccccccccc}
hline
Compound & multicolumn{4}{c}{A} & multicolumn{4}{c}{B} \
AT & #1 & #2 & #1 & #2 & #1 & #2 & #1 & #2 \
feedstock & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} & multicolumn{2}{c}{C} & multicolumn{2}{c}{B} \ hline
Par 1 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 2 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 3 & 1 & 1 & 2 & 2 & 3 & 3 & 4 & 4 \
Par 4 & multicolumn{2}{c}{1} & multicolumn{2}{c}{2} & multicolumn{2}{c}{3} & multicolumn{2}{c}{4} \ hline
multicolumn{9}{p{linewidth}}{Blah Blah Blah Blah Blah Blah Blah Blah Blah
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah} \ hline
end{tabular} end{table}
end{document}
New contributor
edited 2 days ago
New contributor
answered 2 days ago
Nikita SkybytskyiNikita Skybytskyi
487
487
New contributor
New contributor
1
Your solution has the (presumably unintended) side-effect of making the final column very wide indeed in case the combined width of the 9 columns is less thanlinewidth
. Can you think of a way of avoiding this issue?
– Mico
2 days ago
add a comment |
1
Your solution has the (presumably unintended) side-effect of making the final column very wide indeed in case the combined width of the 9 columns is less thanlinewidth
. Can you think of a way of avoiding this issue?
– Mico
2 days ago
1
1
Your solution has the (presumably unintended) side-effect of making the final column very wide indeed in case the combined width of the 9 columns is less than
linewidth
. Can you think of a way of avoiding this issue?– Mico
2 days ago
Your solution has the (presumably unintended) side-effect of making the final column very wide indeed in case the combined width of the 9 columns is less than
linewidth
. Can you think of a way of avoiding this issue?– Mico
2 days ago
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%2f468732%2fmulticolumn-tables-trouble%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
2
By using the
l
column type for the super-long word, you’ve disabled automatic line-breaking. Even if you chose a different column type, i.e., a column type that allows line breaking, how is LaTeX even supposed to decide how and where to insert line breaks in the super-long word?– Mico
2 days ago
Thanks, @Mico for your replay. I changed now a long word with a bunch of "Blah Blah"s (so latex should know where to break the line) and also changed column type from
l
toc
. However, the problem isn't solved. Definitely, I am doing something wrong.– pukumarathe
2 days ago
2
The
c
,l
, andr
column types do no allow line breaking.– Mico
2 days ago
2
we need to know your page layout and desired width of table. ...
– Zarko
2 days ago