How to position text in the top of all columns in the upper row of a table [diagbox]

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question























  • 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














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









share|improve this question























  • 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












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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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










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:



enter image description here



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:



enter image description here



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:



enter image description here



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.






share|improve this answer






















  • 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

















up vote
2
down vote













It is quite possible with some raiseboxes, 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


enter image description here






share|improve this answer




















    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',
    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
    );



    );













    draft saved

    draft discarded


















    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

























    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:



    enter image description here



    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:



    enter image description here



    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:



    enter image description here



    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.






    share|improve this answer






















    • 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














    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:



    enter image description here



    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:



    enter image description here



    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:



    enter image description here



    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.






    share|improve this answer






















    • 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












    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:



    enter image description here



    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:



    enter image description here



    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:



    enter image description here



    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.






    share|improve this answer














    meanwhile when you wait on desired solution, see if the following redesign of your table is acceptable to you:



    enter image description here



    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:



    enter image description here



    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:



    enter image description here



    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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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
















    • 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










    up vote
    2
    down vote













    It is quite possible with some raiseboxes, 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


    enter image description here






    share|improve this answer
























      up vote
      2
      down vote













      It is quite possible with some raiseboxes, 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


      enter image description here






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        It is quite possible with some raiseboxes, 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


        enter image description here






        share|improve this answer












        It is quite possible with some raiseboxes, 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


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 2 at 0:41









        Bernard

        164k769192




        164k769192



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay