Uneven column widths when using a long multi-column header Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Table column widths disproportionate due to multicolumn cell being too longltablex - Multi-column problemMulti-column problemTable with multi columnDifferent column widths when using multicolumn in tabular enviromentMulti-column problem with booktabs packageTables: adjust column widthsHow does multicolumn allocate column widths?Multi column TableChange placement of multi-column headerMulti-header column alignment with booktabs
How does TikZ render an arc?
Tips to organize LaTeX presentations for a semester
Trying to understand entropy as a novice in thermodynamics
How to ask rejected full-time candidates to apply to teach individual courses?
How were pictures turned from film to a big picture in a picture frame before digital scanning?
Google .dev domain strangely redirects to https
What's the difference between Try Ubuntu and Install Ubuntu option in VirtualBox?
How does the body cool itself in a stillsuit?
What does 丫 mean? 丫是什么意思?
What order were files/directories output in dir?
Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?
Why complex landing gears are used instead of simple,reliability and light weight muscle wire or shape memory alloys?
Delete free apps from Play Store library
Why is it faster to reheat something than it is to cook it?
Are there any irrational/transcendental numbers for which the distribution of decimal digits is not uniform?
Nose gear failure in single prop aircraft: belly landing or nose landing?
Short story about astronauts fertilizing soil with their own bodies
Does the Mueller report show a conspiracy between Russia and the Trump Campaign?
Why datecode is SO IMPORTANT to chip manufacturers?
malloc in main() or malloc in another function: allocating memory for a struct and its members
Putting class ranking in CV, but against dept guidelines
Why are vacuum tubes still used in amateur radios?
How do living politicians protect their readily obtainable signatures from misuse?
Weaponising the Grasp-at-a-Distance spell
Uneven column widths when using a long multi-column header
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Table column widths disproportionate due to multicolumn cell being too longltablex - Multi-column problemMulti-column problemTable with multi columnDifferent column widths when using multicolumn in tabular enviromentMulti-column problem with booktabs packageTables: adjust column widthsHow does multicolumn allocate column widths?Multi column TableChange placement of multi-column headerMulti-header column alignment with booktabs
I have the following MWE, but I have a problem with the alignment of the last column (under the multicolumn)
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
%
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
% table 2
% not evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
enddocument
The result I am getting is that the columns under the multicolumns are not evenly separated. And when I increase the width of the text argument to multicolumn command it becomes even worse, first example seems to be fine but with the second there is definitely a problem. Here is the output of the above code:
Any ideas are appreciated to solve this issue.
Many thanks in advance.
tables horizontal-alignment multicolumn booktabs
add a comment |
I have the following MWE, but I have a problem with the alignment of the last column (under the multicolumn)
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
%
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
% table 2
% not evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
enddocument
The result I am getting is that the columns under the multicolumns are not evenly separated. And when I increase the width of the text argument to multicolumn command it becomes even worse, first example seems to be fine but with the second there is definitely a problem. Here is the output of the above code:
Any ideas are appreciated to solve this issue.
Many thanks in advance.
tables horizontal-alignment multicolumn booktabs
Closely related: Table column widths disproportionate due to multicolumn cell being too long
– leandriis
1 hour ago
1
booktabs
andcmidrule
are not involved. This is a known feature of TeX's alignments: when columns are spanned, the excess always go to the last spanned column. Overlong header text should be avoided.
– egreg
29 mins ago
Thanks egreg, I just learned it this morning ;)
– Umut Tabak
27 mins ago
add a comment |
I have the following MWE, but I have a problem with the alignment of the last column (under the multicolumn)
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
%
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
% table 2
% not evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
enddocument
The result I am getting is that the columns under the multicolumns are not evenly separated. And when I increase the width of the text argument to multicolumn command it becomes even worse, first example seems to be fine but with the second there is definitely a problem. Here is the output of the above code:
Any ideas are appreciated to solve this issue.
Many thanks in advance.
tables horizontal-alignment multicolumn booktabs
I have the following MWE, but I have a problem with the alignment of the last column (under the multicolumn)
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
%
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
% table 2
% not evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
enddocument
The result I am getting is that the columns under the multicolumns are not evenly separated. And when I increase the width of the text argument to multicolumn command it becomes even worse, first example seems to be fine but with the second there is definitely a problem. Here is the output of the above code:
Any ideas are appreciated to solve this issue.
Many thanks in advance.
tables horizontal-alignment multicolumn booktabs
tables horizontal-alignment multicolumn booktabs
edited 5 mins ago


Mico
288k32394781
288k32394781
asked 1 hour ago
Umut TabakUmut Tabak
2571213
2571213
Closely related: Table column widths disproportionate due to multicolumn cell being too long
– leandriis
1 hour ago
1
booktabs
andcmidrule
are not involved. This is a known feature of TeX's alignments: when columns are spanned, the excess always go to the last spanned column. Overlong header text should be avoided.
– egreg
29 mins ago
Thanks egreg, I just learned it this morning ;)
– Umut Tabak
27 mins ago
add a comment |
Closely related: Table column widths disproportionate due to multicolumn cell being too long
– leandriis
1 hour ago
1
booktabs
andcmidrule
are not involved. This is a known feature of TeX's alignments: when columns are spanned, the excess always go to the last spanned column. Overlong header text should be avoided.
– egreg
29 mins ago
Thanks egreg, I just learned it this morning ;)
– Umut Tabak
27 mins ago
Closely related: Table column widths disproportionate due to multicolumn cell being too long
– leandriis
1 hour ago
Closely related: Table column widths disproportionate due to multicolumn cell being too long
– leandriis
1 hour ago
1
1
booktabs
and cmidrule
are not involved. This is a known feature of TeX's alignments: when columns are spanned, the excess always go to the last spanned column. Overlong header text should be avoided.– egreg
29 mins ago
booktabs
and cmidrule
are not involved. This is a known feature of TeX's alignments: when columns are spanned, the excess always go to the last spanned column. Overlong header text should be avoided.– egreg
29 mins ago
Thanks egreg, I just learned it this morning ;)
– Umut Tabak
27 mins ago
Thanks egreg, I just learned it this morning ;)
– Umut Tabak
27 mins ago
add a comment |
2 Answers
2
active
oldest
votes
I suggest two kinds of solutions.
The first one with makecell
which puts the multicolumn header on many lines; the second one with tabularx
which equally distributes the spaces among the last 3 columns, leaving the header in one line.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
usepackagemakecell
usepackagetabularx
newcolumntypeC>centeringarraybackslashX
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cmakecellReduced component\ matrix sizes\ textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionWith textbackslashtextttmakecell
labeltab:information-overview-academic-modelbis
endtable
begintable[htbp]
centering
begintabularxlinewidthccCCC
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabularx
captionWith texttttabularx
labeltab:information-overview-academic-modelter
endtable
enddocument
Thanks, without reading the documentation for makecell, I tried to use makecell with one line without the linebreaks as you suggested and then the problem still persists. I guess it is better to use tabularx for this one.
– Umut Tabak
28 mins ago
1
@UmutTabakmakecell
is created to divide lines. If you don't add\
within amakecell
it makes no sense to use it.
– CarLaTeX
22 mins ago
add a comment |
Just for the sake of variety, here's a solution which (a) calculates the natural widths of columns 3, 4, and 5 and (b) uses the combined widths of the three columns (plus the intercolumn whitespace amount) to typeset the long header string in a way that allows for automatic line-breaking.
This approach keeps the tabular material nice and compact; this is generally considered to be a good thing.
Observe that I would place the headers "Component" and "Full size" at the top rather than at the bottom of the header material.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor,booktabs,array,ragged2e
%% Create a new column type:
newcolumntypeC[1]>Centeringarraybackslashp#1
begindocument
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
cmidrule3-5
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionOP's original layout
labeltab:a
endtable
%% perform a few length calculations
newlengthmylen
newlengthmylena
newlengthmylenb
settowidthmylena$m=4$
settowidthmylenb$m=12$
setlengthmylendimexpr2mylena+mylenb+4tabcolseprelax
begintable[htbp]
centering
begintabular@ccccc@
toprule
Component & Full size &
multicolumn3Cmylen@Reduced component matrix sizes textcolorredtest text added\
cmidrule(l)3-5
& & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionAutomatic line-breaking in cols 3 to 5
labeltab:b
endtable
enddocument
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%2f485870%2funeven-column-widths-when-using-a-long-multi-column-header%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
I suggest two kinds of solutions.
The first one with makecell
which puts the multicolumn header on many lines; the second one with tabularx
which equally distributes the spaces among the last 3 columns, leaving the header in one line.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
usepackagemakecell
usepackagetabularx
newcolumntypeC>centeringarraybackslashX
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cmakecellReduced component\ matrix sizes\ textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionWith textbackslashtextttmakecell
labeltab:information-overview-academic-modelbis
endtable
begintable[htbp]
centering
begintabularxlinewidthccCCC
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabularx
captionWith texttttabularx
labeltab:information-overview-academic-modelter
endtable
enddocument
Thanks, without reading the documentation for makecell, I tried to use makecell with one line without the linebreaks as you suggested and then the problem still persists. I guess it is better to use tabularx for this one.
– Umut Tabak
28 mins ago
1
@UmutTabakmakecell
is created to divide lines. If you don't add\
within amakecell
it makes no sense to use it.
– CarLaTeX
22 mins ago
add a comment |
I suggest two kinds of solutions.
The first one with makecell
which puts the multicolumn header on many lines; the second one with tabularx
which equally distributes the spaces among the last 3 columns, leaving the header in one line.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
usepackagemakecell
usepackagetabularx
newcolumntypeC>centeringarraybackslashX
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cmakecellReduced component\ matrix sizes\ textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionWith textbackslashtextttmakecell
labeltab:information-overview-academic-modelbis
endtable
begintable[htbp]
centering
begintabularxlinewidthccCCC
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabularx
captionWith texttttabularx
labeltab:information-overview-academic-modelter
endtable
enddocument
Thanks, without reading the documentation for makecell, I tried to use makecell with one line without the linebreaks as you suggested and then the problem still persists. I guess it is better to use tabularx for this one.
– Umut Tabak
28 mins ago
1
@UmutTabakmakecell
is created to divide lines. If you don't add\
within amakecell
it makes no sense to use it.
– CarLaTeX
22 mins ago
add a comment |
I suggest two kinds of solutions.
The first one with makecell
which puts the multicolumn header on many lines; the second one with tabularx
which equally distributes the spaces among the last 3 columns, leaving the header in one line.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
usepackagemakecell
usepackagetabularx
newcolumntypeC>centeringarraybackslashX
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cmakecellReduced component\ matrix sizes\ textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionWith textbackslashtextttmakecell
labeltab:information-overview-academic-modelbis
endtable
begintable[htbp]
centering
begintabularxlinewidthccCCC
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabularx
captionWith texttttabularx
labeltab:information-overview-academic-modelter
endtable
enddocument
I suggest two kinds of solutions.
The first one with makecell
which puts the multicolumn header on many lines; the second one with tabularx
which equally distributes the spaces among the last 3 columns, leaving the header in one line.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagebooktabs
usepackagecalc
usepackagearray
usepackagecolor
usepackagemakecell
usepackagetabularx
newcolumntypeC>centeringarraybackslashX
begindocument
%
% table 1
% evenly alined
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionInformation on component level degrees of freedom
labeltab:information-overview-academic-model
endtable
%
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cmakecellReduced component\ matrix sizes\ textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionWith textbackslashtextttmakecell
labeltab:information-overview-academic-modelbis
endtable
begintable[htbp]
centering
begintabularxlinewidthccCCC
toprule
& & multicolumn3cReduced component matrix sizes textcolorredtest text added\
%cmidrule(r)3-5
cmidrule3-5
% multicolumn2cInternal mode count, $m$ &10&20&30&10&20&30\
%midrule
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabularx
captionWith texttttabularx
labeltab:information-overview-academic-modelter
endtable
enddocument
edited 1 hour ago
Bernard
177k778210
177k778210
answered 1 hour ago


CarLaTeXCarLaTeX
35.1k554146
35.1k554146
Thanks, without reading the documentation for makecell, I tried to use makecell with one line without the linebreaks as you suggested and then the problem still persists. I guess it is better to use tabularx for this one.
– Umut Tabak
28 mins ago
1
@UmutTabakmakecell
is created to divide lines. If you don't add\
within amakecell
it makes no sense to use it.
– CarLaTeX
22 mins ago
add a comment |
Thanks, without reading the documentation for makecell, I tried to use makecell with one line without the linebreaks as you suggested and then the problem still persists. I guess it is better to use tabularx for this one.
– Umut Tabak
28 mins ago
1
@UmutTabakmakecell
is created to divide lines. If you don't add\
within amakecell
it makes no sense to use it.
– CarLaTeX
22 mins ago
Thanks, without reading the documentation for makecell, I tried to use makecell with one line without the linebreaks as you suggested and then the problem still persists. I guess it is better to use tabularx for this one.
– Umut Tabak
28 mins ago
Thanks, without reading the documentation for makecell, I tried to use makecell with one line without the linebreaks as you suggested and then the problem still persists. I guess it is better to use tabularx for this one.
– Umut Tabak
28 mins ago
1
1
@UmutTabak
makecell
is created to divide lines. If you don't add \
within a makecell
it makes no sense to use it.– CarLaTeX
22 mins ago
@UmutTabak
makecell
is created to divide lines. If you don't add \
within a makecell
it makes no sense to use it.– CarLaTeX
22 mins ago
add a comment |
Just for the sake of variety, here's a solution which (a) calculates the natural widths of columns 3, 4, and 5 and (b) uses the combined widths of the three columns (plus the intercolumn whitespace amount) to typeset the long header string in a way that allows for automatic line-breaking.
This approach keeps the tabular material nice and compact; this is generally considered to be a good thing.
Observe that I would place the headers "Component" and "Full size" at the top rather than at the bottom of the header material.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor,booktabs,array,ragged2e
%% Create a new column type:
newcolumntypeC[1]>Centeringarraybackslashp#1
begindocument
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
cmidrule3-5
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionOP's original layout
labeltab:a
endtable
%% perform a few length calculations
newlengthmylen
newlengthmylena
newlengthmylenb
settowidthmylena$m=4$
settowidthmylenb$m=12$
setlengthmylendimexpr2mylena+mylenb+4tabcolseprelax
begintable[htbp]
centering
begintabular@ccccc@
toprule
Component & Full size &
multicolumn3Cmylen@Reduced component matrix sizes textcolorredtest text added\
cmidrule(l)3-5
& & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionAutomatic line-breaking in cols 3 to 5
labeltab:b
endtable
enddocument
add a comment |
Just for the sake of variety, here's a solution which (a) calculates the natural widths of columns 3, 4, and 5 and (b) uses the combined widths of the three columns (plus the intercolumn whitespace amount) to typeset the long header string in a way that allows for automatic line-breaking.
This approach keeps the tabular material nice and compact; this is generally considered to be a good thing.
Observe that I would place the headers "Component" and "Full size" at the top rather than at the bottom of the header material.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor,booktabs,array,ragged2e
%% Create a new column type:
newcolumntypeC[1]>Centeringarraybackslashp#1
begindocument
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
cmidrule3-5
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionOP's original layout
labeltab:a
endtable
%% perform a few length calculations
newlengthmylen
newlengthmylena
newlengthmylenb
settowidthmylena$m=4$
settowidthmylenb$m=12$
setlengthmylendimexpr2mylena+mylenb+4tabcolseprelax
begintable[htbp]
centering
begintabular@ccccc@
toprule
Component & Full size &
multicolumn3Cmylen@Reduced component matrix sizes textcolorredtest text added\
cmidrule(l)3-5
& & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionAutomatic line-breaking in cols 3 to 5
labeltab:b
endtable
enddocument
add a comment |
Just for the sake of variety, here's a solution which (a) calculates the natural widths of columns 3, 4, and 5 and (b) uses the combined widths of the three columns (plus the intercolumn whitespace amount) to typeset the long header string in a way that allows for automatic line-breaking.
This approach keeps the tabular material nice and compact; this is generally considered to be a good thing.
Observe that I would place the headers "Component" and "Full size" at the top rather than at the bottom of the header material.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor,booktabs,array,ragged2e
%% Create a new column type:
newcolumntypeC[1]>Centeringarraybackslashp#1
begindocument
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
cmidrule3-5
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionOP's original layout
labeltab:a
endtable
%% perform a few length calculations
newlengthmylen
newlengthmylena
newlengthmylenb
settowidthmylena$m=4$
settowidthmylenb$m=12$
setlengthmylendimexpr2mylena+mylenb+4tabcolseprelax
begintable[htbp]
centering
begintabular@ccccc@
toprule
Component & Full size &
multicolumn3Cmylen@Reduced component matrix sizes textcolorredtest text added\
cmidrule(l)3-5
& & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionAutomatic line-breaking in cols 3 to 5
labeltab:b
endtable
enddocument
Just for the sake of variety, here's a solution which (a) calculates the natural widths of columns 3, 4, and 5 and (b) uses the combined widths of the three columns (plus the intercolumn whitespace amount) to typeset the long header string in a way that allows for automatic line-breaking.
This approach keeps the tabular material nice and compact; this is generally considered to be a good thing.
Observe that I would place the headers "Component" and "Full size" at the top rather than at the bottom of the header material.
documentclassreport
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackagexcolor,booktabs,array,ragged2e
%% Create a new column type:
newcolumntypeC[1]>Centeringarraybackslashp#1
begindocument
begintable[htbp]
centering
begintabularccccc
toprule
& & multicolumn3cReduced component sizes\
cmidrule3-5
Component & Full size & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionOP's original layout
labeltab:a
endtable
%% perform a few length calculations
newlengthmylen
newlengthmylena
newlengthmylenb
settowidthmylena$m=4$
settowidthmylenb$m=12$
setlengthmylendimexpr2mylena+mylenb+4tabcolseprelax
begintable[htbp]
centering
begintabular@ccccc@
toprule
Component & Full size &
multicolumn3Cmylen@Reduced component matrix sizes textcolorredtest text added\
cmidrule(l)3-5
& & $m=4$ & $m=8$ & $m=12$\
midrule
1 & 257 & 24 & 28 & 32 \
2 & 420 & 47 & 51 & 55 \
3 & 177 & 24 & 28 & 32 \
bottomrule
endtabular
captionAutomatic line-breaking in cols 3 to 5
labeltab:b
endtable
enddocument
answered 8 mins ago


MicoMico
288k32394781
288k32394781
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%2f485870%2funeven-column-widths-when-using-a-long-multi-column-header%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
Closely related: Table column widths disproportionate due to multicolumn cell being too long
– leandriis
1 hour ago
1
booktabs
andcmidrule
are not involved. This is a known feature of TeX's alignments: when columns are spanned, the excess always go to the last spanned column. Overlong header text should be avoided.– egreg
29 mins ago
Thanks egreg, I just learned it this morning ;)
– Umut Tabak
27 mins ago