How to position text in the top of all columns in the upper row of a table [diagbox]
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
How can I get '1', '2', '3', '4', and 'Supply' (i.e. the entries in the first row (but in different columns)) on the same height (vertical position) as 'Destination' (i.e. at the top of the columns instead of in the middle of the columns)?
Due to using the 'diagbox' option, the vertical position of these elements is off.
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagboxtextbfSourcetextbfDestination & $1$ & $2$ & $3$ & $4$ & textbfSupply \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
tables diagbox
add a comment |
up vote
1
down vote
favorite
How can I get '1', '2', '3', '4', and 'Supply' (i.e. the entries in the first row (but in different columns)) on the same height (vertical position) as 'Destination' (i.e. at the top of the columns instead of in the middle of the columns)?
Due to using the 'diagbox' option, the vertical position of these elements is off.
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagboxtextbfSourcetextbfDestination & $1$ & $2$ & $3$ & $4$ & textbfSupply \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
tables diagbox
please be so kind ans extend your code snippet to complete small document, which we can copy and test as it is in our computers! now wee need to gues which package you use for this table etc ...
– Zarko
Dec 1 at 23:38
@Zarko Done, I use relatively many packages so it was kind of difficult to select the useful ones, but I think this represents the problem well.
– Anna
Dec 1 at 23:48
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How can I get '1', '2', '3', '4', and 'Supply' (i.e. the entries in the first row (but in different columns)) on the same height (vertical position) as 'Destination' (i.e. at the top of the columns instead of in the middle of the columns)?
Due to using the 'diagbox' option, the vertical position of these elements is off.
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagboxtextbfSourcetextbfDestination & $1$ & $2$ & $3$ & $4$ & textbfSupply \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
tables diagbox
How can I get '1', '2', '3', '4', and 'Supply' (i.e. the entries in the first row (but in different columns)) on the same height (vertical position) as 'Destination' (i.e. at the top of the columns instead of in the middle of the columns)?
Due to using the 'diagbox' option, the vertical position of these elements is off.
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagboxtextbfSourcetextbfDestination & $1$ & $2$ & $3$ & $4$ & textbfSupply \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
tables diagbox
tables diagbox
edited Dec 1 at 23:43
asked Dec 1 at 23:10
Anna
276
276
please be so kind ans extend your code snippet to complete small document, which we can copy and test as it is in our computers! now wee need to gues which package you use for this table etc ...
– Zarko
Dec 1 at 23:38
@Zarko Done, I use relatively many packages so it was kind of difficult to select the useful ones, but I think this represents the problem well.
– Anna
Dec 1 at 23:48
add a comment |
please be so kind ans extend your code snippet to complete small document, which we can copy and test as it is in our computers! now wee need to gues which package you use for this table etc ...
– Zarko
Dec 1 at 23:38
@Zarko Done, I use relatively many packages so it was kind of difficult to select the useful ones, but I think this represents the problem well.
– Anna
Dec 1 at 23:48
please be so kind ans extend your code snippet to complete small document, which we can copy and test as it is in our computers! now wee need to gues which package you use for this table etc ...
– Zarko
Dec 1 at 23:38
please be so kind ans extend your code snippet to complete small document, which we can copy and test as it is in our computers! now wee need to gues which package you use for this table etc ...
– Zarko
Dec 1 at 23:38
@Zarko Done, I use relatively many packages so it was kind of difficult to select the useful ones, but I think this represents the problem well.
– Anna
Dec 1 at 23:48
@Zarko Done, I use relatively many packages so it was kind of difficult to select the useful ones, but I think this represents the problem well.
– Anna
Dec 1 at 23:48
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
meanwhile when you wait on desired solution, see if the following redesign of your table is acceptable to you:
documentclass[12pt,fleqn]article
%usepackagepict2e % not needed in this mwe
%usepackagekeyval % not needed in this mwe
%usepackagecalc % not needed in this mwe
%usepackagefp % not needed in this mwe
%usepackagediagbox % not needed in this mwe
usepackagebooktabs,
multirow, % <--- new
tabularx % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabular*6>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3 & 4 & \
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
edit: or you more prefer the following solution:
documentclass[12pt,fleqn]article
usepackagediagbox
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
multirow2*
diagboxtextbfSourcetextbfDestination
& $1$ & $2$ & $3$ & $4$ & textbfSupply \
& & & & & \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
which gives:
it's probably not difficult to guess which solution I prefer ...
addendum:
according to your new question in the comment below ... if i correctly understood it, than you looking for the following:
in above table for the first column is used column type S
provided by the package siunitx
:
documentclass[12pt,fleqn]article
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- instead of colortbl
usepackagesiunitx % <--- new
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabularS[table-format=1.0,
table-space-text-post=*] % <--- new
*5>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3^* & 4^ast & \ % two cases how to write *
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3* & c_31 & c_32 & c_33 & c_34 & s_3 \
4* & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
in the case that *
is intended to write some notes in table, than may the threeparttable
can help you in this.
The first table is absolutely beautiful. Yeah, I think I'll go for that one, since it looks definitely better than what I first intended. Thank you.
– Anna
Dec 2 at 12:40
One small question remaining though: I have to include a subscript star (*) to 3 and 4 but that results in a 1 and 2 at the position of the star (center-right aligned) instead of at the position of 3 and 4 (center-left aligned). How can I fix that?
– Anna
Dec 2 at 13:03
@Anna, sorry, i not understand you. can you write as math expression, what is your problem, i.e. if instead of 3 and 4 you like to have 3_ and 4_ (3_ast and 4_ast)? if you wrote so, where you expect position of star? as 3ast?
– Zarko
Dec 2 at 13:35
I have 3^ast and 4^ast instead of just 3 and 4. 1 and 2 are without superscript *. If you run the code you see that 1 and 2 are then not positioned nicely, i.e. 1 and 2 are above the *'s of 3 and 4 but not right above the actual numbers as they should be (that's what I meant with center-left aligned vs center-right aligned).
– Anna
Dec 2 at 14:22
i guess that you talking about positioning of numbers in the first column. they are horizontal centered but you like to have numbers to be right aligned and * should bi right of numbers. do i'm right? for this the column type should be changed. an example i will prepare asap.
– Zarko
Dec 2 at 14:40
|
show 2 more comments
up vote
2
down vote
It is quite possible with some raisebox
es, but I don't think it's so nice:
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl, makecell, caption
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
raisebox2.5extextbfSourceraisebox-0.5extextbfDestination & raisebox2.25ex$1$ & raisebox2.25ex$2$ & raisebox2.25ex$3$ & raisebox2.25ex$4$ & raisebox2.25extextbfSupply \
hline
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
hline
textbfDemand & d_1 & d_2 & d_3 & d_4 & T\
hline
endtabular
endtable
enddocument
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
meanwhile when you wait on desired solution, see if the following redesign of your table is acceptable to you:
documentclass[12pt,fleqn]article
%usepackagepict2e % not needed in this mwe
%usepackagekeyval % not needed in this mwe
%usepackagecalc % not needed in this mwe
%usepackagefp % not needed in this mwe
%usepackagediagbox % not needed in this mwe
usepackagebooktabs,
multirow, % <--- new
tabularx % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabular*6>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3 & 4 & \
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
edit: or you more prefer the following solution:
documentclass[12pt,fleqn]article
usepackagediagbox
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
multirow2*
diagboxtextbfSourcetextbfDestination
& $1$ & $2$ & $3$ & $4$ & textbfSupply \
& & & & & \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
which gives:
it's probably not difficult to guess which solution I prefer ...
addendum:
according to your new question in the comment below ... if i correctly understood it, than you looking for the following:
in above table for the first column is used column type S
provided by the package siunitx
:
documentclass[12pt,fleqn]article
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- instead of colortbl
usepackagesiunitx % <--- new
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabularS[table-format=1.0,
table-space-text-post=*] % <--- new
*5>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3^* & 4^ast & \ % two cases how to write *
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3* & c_31 & c_32 & c_33 & c_34 & s_3 \
4* & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
in the case that *
is intended to write some notes in table, than may the threeparttable
can help you in this.
The first table is absolutely beautiful. Yeah, I think I'll go for that one, since it looks definitely better than what I first intended. Thank you.
– Anna
Dec 2 at 12:40
One small question remaining though: I have to include a subscript star (*) to 3 and 4 but that results in a 1 and 2 at the position of the star (center-right aligned) instead of at the position of 3 and 4 (center-left aligned). How can I fix that?
– Anna
Dec 2 at 13:03
@Anna, sorry, i not understand you. can you write as math expression, what is your problem, i.e. if instead of 3 and 4 you like to have 3_ and 4_ (3_ast and 4_ast)? if you wrote so, where you expect position of star? as 3ast?
– Zarko
Dec 2 at 13:35
I have 3^ast and 4^ast instead of just 3 and 4. 1 and 2 are without superscript *. If you run the code you see that 1 and 2 are then not positioned nicely, i.e. 1 and 2 are above the *'s of 3 and 4 but not right above the actual numbers as they should be (that's what I meant with center-left aligned vs center-right aligned).
– Anna
Dec 2 at 14:22
i guess that you talking about positioning of numbers in the first column. they are horizontal centered but you like to have numbers to be right aligned and * should bi right of numbers. do i'm right? for this the column type should be changed. an example i will prepare asap.
– Zarko
Dec 2 at 14:40
|
show 2 more comments
up vote
3
down vote
accepted
meanwhile when you wait on desired solution, see if the following redesign of your table is acceptable to you:
documentclass[12pt,fleqn]article
%usepackagepict2e % not needed in this mwe
%usepackagekeyval % not needed in this mwe
%usepackagecalc % not needed in this mwe
%usepackagefp % not needed in this mwe
%usepackagediagbox % not needed in this mwe
usepackagebooktabs,
multirow, % <--- new
tabularx % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabular*6>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3 & 4 & \
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
edit: or you more prefer the following solution:
documentclass[12pt,fleqn]article
usepackagediagbox
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
multirow2*
diagboxtextbfSourcetextbfDestination
& $1$ & $2$ & $3$ & $4$ & textbfSupply \
& & & & & \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
which gives:
it's probably not difficult to guess which solution I prefer ...
addendum:
according to your new question in the comment below ... if i correctly understood it, than you looking for the following:
in above table for the first column is used column type S
provided by the package siunitx
:
documentclass[12pt,fleqn]article
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- instead of colortbl
usepackagesiunitx % <--- new
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabularS[table-format=1.0,
table-space-text-post=*] % <--- new
*5>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3^* & 4^ast & \ % two cases how to write *
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3* & c_31 & c_32 & c_33 & c_34 & s_3 \
4* & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
in the case that *
is intended to write some notes in table, than may the threeparttable
can help you in this.
The first table is absolutely beautiful. Yeah, I think I'll go for that one, since it looks definitely better than what I first intended. Thank you.
– Anna
Dec 2 at 12:40
One small question remaining though: I have to include a subscript star (*) to 3 and 4 but that results in a 1 and 2 at the position of the star (center-right aligned) instead of at the position of 3 and 4 (center-left aligned). How can I fix that?
– Anna
Dec 2 at 13:03
@Anna, sorry, i not understand you. can you write as math expression, what is your problem, i.e. if instead of 3 and 4 you like to have 3_ and 4_ (3_ast and 4_ast)? if you wrote so, where you expect position of star? as 3ast?
– Zarko
Dec 2 at 13:35
I have 3^ast and 4^ast instead of just 3 and 4. 1 and 2 are without superscript *. If you run the code you see that 1 and 2 are then not positioned nicely, i.e. 1 and 2 are above the *'s of 3 and 4 but not right above the actual numbers as they should be (that's what I meant with center-left aligned vs center-right aligned).
– Anna
Dec 2 at 14:22
i guess that you talking about positioning of numbers in the first column. they are horizontal centered but you like to have numbers to be right aligned and * should bi right of numbers. do i'm right? for this the column type should be changed. an example i will prepare asap.
– Zarko
Dec 2 at 14:40
|
show 2 more comments
up vote
3
down vote
accepted
up vote
3
down vote
accepted
meanwhile when you wait on desired solution, see if the following redesign of your table is acceptable to you:
documentclass[12pt,fleqn]article
%usepackagepict2e % not needed in this mwe
%usepackagekeyval % not needed in this mwe
%usepackagecalc % not needed in this mwe
%usepackagefp % not needed in this mwe
%usepackagediagbox % not needed in this mwe
usepackagebooktabs,
multirow, % <--- new
tabularx % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabular*6>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3 & 4 & \
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
edit: or you more prefer the following solution:
documentclass[12pt,fleqn]article
usepackagediagbox
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
multirow2*
diagboxtextbfSourcetextbfDestination
& $1$ & $2$ & $3$ & $4$ & textbfSupply \
& & & & & \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
which gives:
it's probably not difficult to guess which solution I prefer ...
addendum:
according to your new question in the comment below ... if i correctly understood it, than you looking for the following:
in above table for the first column is used column type S
provided by the package siunitx
:
documentclass[12pt,fleqn]article
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- instead of colortbl
usepackagesiunitx % <--- new
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabularS[table-format=1.0,
table-space-text-post=*] % <--- new
*5>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3^* & 4^ast & \ % two cases how to write *
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3* & c_31 & c_32 & c_33 & c_34 & s_3 \
4* & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
in the case that *
is intended to write some notes in table, than may the threeparttable
can help you in this.
meanwhile when you wait on desired solution, see if the following redesign of your table is acceptable to you:
documentclass[12pt,fleqn]article
%usepackagepict2e % not needed in this mwe
%usepackagekeyval % not needed in this mwe
%usepackagecalc % not needed in this mwe
%usepackagefp % not needed in this mwe
%usepackagediagbox % not needed in this mwe
usepackagebooktabs,
multirow, % <--- new
tabularx % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabular*6>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3 & 4 & \
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
edit: or you more prefer the following solution:
documentclass[12pt,fleqn]article
usepackagediagbox
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- changed from colortbl
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
multirow2*
diagboxtextbfSourcetextbfDestination
& $1$ & $2$ & $3$ & $4$ & textbfSupply \
& & & & & \
hline
$1$ & $c_11$ & $c_12$ & $c_13$ & $c_14$ & $s_1$ \
$2$ & $c_21$ & $c_22$ & $c_23$ & $c_24$ & $s_2$ \
$3$ & $c_31$ & $c_32$ & $c_33$ & $c_34$ & $s_3$ \
$4$ & $c_41$ & $c_42$ & $c_43$ & $c_44$ & $s_4$ \
hline
textbfDemand & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
endtabular
endtable
enddocument
which gives:
it's probably not difficult to guess which solution I prefer ...
addendum:
according to your new question in the comment below ... if i correctly understood it, than you looking for the following:
in above table for the first column is used column type S
provided by the package siunitx
:
documentclass[12pt,fleqn]article
usepackagebooktabs,
multirow % <--- new
usepackage[table]xcolor % <--- instead of colortbl
usepackagesiunitx % <--- new
begindocument
begintable[h!]
caption[short caption]long caption
labeltab:table1
centering
begintabularS[table-format=1.0,
table-space-text-post=*] % <--- new
*5>$c<$
toprule
multirow2.4*textbfSource
& multicolumn4ctextbfDestination
& multirow2.4*textbfSupply \
cmidrule2-5
& 1 & 2 & 3^* & 4^ast & \ % two cases how to write *
midrule
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3* & c_31 & c_32 & c_33 & c_34 & s_3 \
4* & c_41 & c_42 & c_43 & c_44 & s_4 \
midrule
textbfDemand
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
endtabular
endtable
enddocument
in the case that *
is intended to write some notes in table, than may the threeparttable
can help you in this.
edited Dec 2 at 14:58
answered Dec 2 at 0:37
Zarko
118k865155
118k865155
The first table is absolutely beautiful. Yeah, I think I'll go for that one, since it looks definitely better than what I first intended. Thank you.
– Anna
Dec 2 at 12:40
One small question remaining though: I have to include a subscript star (*) to 3 and 4 but that results in a 1 and 2 at the position of the star (center-right aligned) instead of at the position of 3 and 4 (center-left aligned). How can I fix that?
– Anna
Dec 2 at 13:03
@Anna, sorry, i not understand you. can you write as math expression, what is your problem, i.e. if instead of 3 and 4 you like to have 3_ and 4_ (3_ast and 4_ast)? if you wrote so, where you expect position of star? as 3ast?
– Zarko
Dec 2 at 13:35
I have 3^ast and 4^ast instead of just 3 and 4. 1 and 2 are without superscript *. If you run the code you see that 1 and 2 are then not positioned nicely, i.e. 1 and 2 are above the *'s of 3 and 4 but not right above the actual numbers as they should be (that's what I meant with center-left aligned vs center-right aligned).
– Anna
Dec 2 at 14:22
i guess that you talking about positioning of numbers in the first column. they are horizontal centered but you like to have numbers to be right aligned and * should bi right of numbers. do i'm right? for this the column type should be changed. an example i will prepare asap.
– Zarko
Dec 2 at 14:40
|
show 2 more comments
The first table is absolutely beautiful. Yeah, I think I'll go for that one, since it looks definitely better than what I first intended. Thank you.
– Anna
Dec 2 at 12:40
One small question remaining though: I have to include a subscript star (*) to 3 and 4 but that results in a 1 and 2 at the position of the star (center-right aligned) instead of at the position of 3 and 4 (center-left aligned). How can I fix that?
– Anna
Dec 2 at 13:03
@Anna, sorry, i not understand you. can you write as math expression, what is your problem, i.e. if instead of 3 and 4 you like to have 3_ and 4_ (3_ast and 4_ast)? if you wrote so, where you expect position of star? as 3ast?
– Zarko
Dec 2 at 13:35
I have 3^ast and 4^ast instead of just 3 and 4. 1 and 2 are without superscript *. If you run the code you see that 1 and 2 are then not positioned nicely, i.e. 1 and 2 are above the *'s of 3 and 4 but not right above the actual numbers as they should be (that's what I meant with center-left aligned vs center-right aligned).
– Anna
Dec 2 at 14:22
i guess that you talking about positioning of numbers in the first column. they are horizontal centered but you like to have numbers to be right aligned and * should bi right of numbers. do i'm right? for this the column type should be changed. an example i will prepare asap.
– Zarko
Dec 2 at 14:40
The first table is absolutely beautiful. Yeah, I think I'll go for that one, since it looks definitely better than what I first intended. Thank you.
– Anna
Dec 2 at 12:40
The first table is absolutely beautiful. Yeah, I think I'll go for that one, since it looks definitely better than what I first intended. Thank you.
– Anna
Dec 2 at 12:40
One small question remaining though: I have to include a subscript star (*) to 3 and 4 but that results in a 1 and 2 at the position of the star (center-right aligned) instead of at the position of 3 and 4 (center-left aligned). How can I fix that?
– Anna
Dec 2 at 13:03
One small question remaining though: I have to include a subscript star (*) to 3 and 4 but that results in a 1 and 2 at the position of the star (center-right aligned) instead of at the position of 3 and 4 (center-left aligned). How can I fix that?
– Anna
Dec 2 at 13:03
@Anna, sorry, i not understand you. can you write as math expression, what is your problem, i.e. if instead of 3 and 4 you like to have 3_ and 4_ (3_ast and 4_ast)? if you wrote so, where you expect position of star? as 3ast?
– Zarko
Dec 2 at 13:35
@Anna, sorry, i not understand you. can you write as math expression, what is your problem, i.e. if instead of 3 and 4 you like to have 3_ and 4_ (3_ast and 4_ast)? if you wrote so, where you expect position of star? as 3ast?
– Zarko
Dec 2 at 13:35
I have 3^ast and 4^ast instead of just 3 and 4. 1 and 2 are without superscript *. If you run the code you see that 1 and 2 are then not positioned nicely, i.e. 1 and 2 are above the *'s of 3 and 4 but not right above the actual numbers as they should be (that's what I meant with center-left aligned vs center-right aligned).
– Anna
Dec 2 at 14:22
I have 3^ast and 4^ast instead of just 3 and 4. 1 and 2 are without superscript *. If you run the code you see that 1 and 2 are then not positioned nicely, i.e. 1 and 2 are above the *'s of 3 and 4 but not right above the actual numbers as they should be (that's what I meant with center-left aligned vs center-right aligned).
– Anna
Dec 2 at 14:22
i guess that you talking about positioning of numbers in the first column. they are horizontal centered but you like to have numbers to be right aligned and * should bi right of numbers. do i'm right? for this the column type should be changed. an example i will prepare asap.
– Zarko
Dec 2 at 14:40
i guess that you talking about positioning of numbers in the first column. they are horizontal centered but you like to have numbers to be right aligned and * should bi right of numbers. do i'm right? for this the column type should be changed. an example i will prepare asap.
– Zarko
Dec 2 at 14:40
|
show 2 more comments
up vote
2
down vote
It is quite possible with some raisebox
es, but I don't think it's so nice:
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl, makecell, caption
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
raisebox2.5extextbfSourceraisebox-0.5extextbfDestination & raisebox2.25ex$1$ & raisebox2.25ex$2$ & raisebox2.25ex$3$ & raisebox2.25ex$4$ & raisebox2.25extextbfSupply \
hline
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
hline
textbfDemand & d_1 & d_2 & d_3 & d_4 & T\
hline
endtabular
endtable
enddocument
add a comment |
up vote
2
down vote
It is quite possible with some raisebox
es, but I don't think it's so nice:
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl, makecell, caption
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
raisebox2.5extextbfSourceraisebox-0.5extextbfDestination & raisebox2.25ex$1$ & raisebox2.25ex$2$ & raisebox2.25ex$3$ & raisebox2.25ex$4$ & raisebox2.25extextbfSupply \
hline
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
hline
textbfDemand & d_1 & d_2 & d_3 & d_4 & T\
hline
endtabular
endtable
enddocument
add a comment |
up vote
2
down vote
up vote
2
down vote
It is quite possible with some raisebox
es, but I don't think it's so nice:
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl, makecell, caption
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
raisebox2.5extextbfSourceraisebox-0.5extextbfDestination & raisebox2.25ex$1$ & raisebox2.25ex$2$ & raisebox2.25ex$3$ & raisebox2.25ex$4$ & raisebox2.25extextbfSupply \
hline
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
hline
textbfDemand & d_1 & d_2 & d_3 & d_4 & T\
hline
endtabular
endtable
enddocument
It is quite possible with some raisebox
es, but I don't think it's so nice:
documentclass[12pt,fleqn]article
usepackagepict2e
usepackagekeyval
usepackagecalc
usepackagefp
usepackagediagbox
usepackagebooktabs
usepackagetabularx,colortbl, makecell, caption
begindocument
begintable[h!]
centering
caption[caption]Table 1
labeltab:table1
begintabular
hline
diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
raisebox2.5extextbfSourceraisebox-0.5extextbfDestination & raisebox2.25ex$1$ & raisebox2.25ex$2$ & raisebox2.25ex$3$ & raisebox2.25ex$4$ & raisebox2.25extextbfSupply \
hline
1 & c_11 & c_12 & c_13 & c_14 & s_1 \
2 & c_21 & c_22 & c_23 & c_24 & s_2 \
3 & c_31 & c_32 & c_33 & c_34 & s_3 \
4 & c_41 & c_42 & c_43 & c_44 & s_4 \
hline
textbfDemand & d_1 & d_2 & d_3 & d_4 & T\
hline
endtabular
endtable
enddocument
answered Dec 2 at 0:41
Bernard
164k769192
164k769192
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%2f462761%2fhow-to-position-text-in-the-top-of-all-columns-in-the-upper-row-of-a-table-diag%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
please be so kind ans extend your code snippet to complete small document, which we can copy and test as it is in our computers! now wee need to gues which package you use for this table etc ...
– Zarko
Dec 1 at 23:38
@Zarko Done, I use relatively many packages so it was kind of difficult to select the useful ones, but I think this represents the problem well.
– Anna
Dec 1 at 23:48