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











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}
usepackage{pict2e}
usepackage{keyval}
usepackage{calc}
usepackage{fp}
usepackage{diagbox}
usepackage{booktabs}
usepackage{tabularx,colortbl}
begin{document}
begin{table}[h!]
centering
caption[caption]{Table 1}
label{tab:table1}
begin{tabular}{|l|cccc|c|}
hline
diagbox{textbf{Source}}{textbf{Destination}} & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
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
textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
end{tabular}
end{table}
end{document}









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
    3 hours ago










  • @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
    3 hours ago















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}
usepackage{pict2e}
usepackage{keyval}
usepackage{calc}
usepackage{fp}
usepackage{diagbox}
usepackage{booktabs}
usepackage{tabularx,colortbl}
begin{document}
begin{table}[h!]
centering
caption[caption]{Table 1}
label{tab:table1}
begin{tabular}{|l|cccc|c|}
hline
diagbox{textbf{Source}}{textbf{Destination}} & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
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
textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
end{tabular}
end{table}
end{document}









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
    3 hours ago










  • @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
    3 hours ago













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}
usepackage{pict2e}
usepackage{keyval}
usepackage{calc}
usepackage{fp}
usepackage{diagbox}
usepackage{booktabs}
usepackage{tabularx,colortbl}
begin{document}
begin{table}[h!]
centering
caption[caption]{Table 1}
label{tab:table1}
begin{tabular}{|l|cccc|c|}
hline
diagbox{textbf{Source}}{textbf{Destination}} & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
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
textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
end{tabular}
end{table}
end{document}









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}
usepackage{pict2e}
usepackage{keyval}
usepackage{calc}
usepackage{fp}
usepackage{diagbox}
usepackage{booktabs}
usepackage{tabularx,colortbl}
begin{document}
begin{table}[h!]
centering
caption[caption]{Table 1}
label{tab:table1}
begin{tabular}{|l|cccc|c|}
hline
diagbox{textbf{Source}}{textbf{Destination}} & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
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
textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
end{tabular}
end{table}
end{document}






tables diagbox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago

























asked 4 hours ago









Anna

234




234












  • 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
    3 hours ago










  • @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
    3 hours ago


















  • 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
    3 hours ago










  • @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
    3 hours ago
















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
3 hours ago




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
3 hours ago












@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
3 hours ago




@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
3 hours ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote













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}
%usepackage{pict2e} % not needed in this mwe
%usepackage{keyval} % not needed in this mwe
%usepackage{calc} % not needed in this mwe
%usepackage{fp} % not needed in this mwe
%usepackage{diagbox}
usepackage{booktabs,
multirow, % <--- new
tabularx}
usepackage[table]{xcolor}

begin{document}
begin{table}[h!]
caption[short caption]{long caption}
label{tab:table1}
centering
begin{tabular}{*{6}{>{$}c<{$}} }
toprule
multirow{2.4}{*}{textbf{Source}}
& multicolumn{4}{c}{textbf{Destination}}
& multirow{2.4}{*}{textbf{Supply}} \
cmidrule{2-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
textbf{Demand}
& d_1 & d_2 & d_3 & d_4 & T \
bottomrule
end{tabular}
end{table}
end{document}


edit: or you more prefer the following solution:



documentclass[12pt,fleqn]{article}
usepackage{diagbox}
usepackage{booktabs,
makecell, % <--- new
multirow, % <--- new
tabularx}
usepackage[table]{xcolor}

begin{document}
begin{table}[h!]
centering
caption[caption]{Table 1}
label{tab:table1}
begin{tabular}{|l|cccc|c|}
hline
multirow{2}{*}{
diagbox{textbf{Source}}{textbf{Destination}}
}
& $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
& & & & & \
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
textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
hline
end{tabular}
end{table}
end{document}


which gives:



enter image description here



it's probably not difficult to guess which solution I prefer ...






share|improve this answer






























    up vote
    1
    down vote













    It is quite possible with some raiseboxes, but I don't think it's so nice:



    documentclass[12pt,fleqn]{article}
    usepackage{pict2e}
    usepackage{keyval}
    usepackage{calc}
    usepackage{fp}
    usepackage{diagbox}
    usepackage{booktabs}
    usepackage{tabularx,colortbl, makecell, caption}

    begin{document}

    begin{table}[h!]
    centering
    caption[caption]{Table 1}
    label{tab:table1}
    begin{tabular}{|l|*{4}{>{$}c<{$}}|>{$}c<{$}|}
    hline
    diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
    {raisebox{2.5ex}{textbf{Source}}}{raisebox{-0.5ex}{textbf{Destination}}} & raisebox{2.25ex}{$1$} & raisebox{2.25ex}{$2$} & raisebox{2.25ex}{$3$} & raisebox{2.25ex}{$4$} & raisebox{2.25ex}{textbf{Supply}} \
    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
    textbf{Demand} & d_1 & d_2 & d_3 & d_4 & T\
    hline
    end{tabular}
    end{table}

    end{document}


    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
      2
      down vote













      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}
      %usepackage{pict2e} % not needed in this mwe
      %usepackage{keyval} % not needed in this mwe
      %usepackage{calc} % not needed in this mwe
      %usepackage{fp} % not needed in this mwe
      %usepackage{diagbox}
      usepackage{booktabs,
      multirow, % <--- new
      tabularx}
      usepackage[table]{xcolor}

      begin{document}
      begin{table}[h!]
      caption[short caption]{long caption}
      label{tab:table1}
      centering
      begin{tabular}{*{6}{>{$}c<{$}} }
      toprule
      multirow{2.4}{*}{textbf{Source}}
      & multicolumn{4}{c}{textbf{Destination}}
      & multirow{2.4}{*}{textbf{Supply}} \
      cmidrule{2-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
      textbf{Demand}
      & d_1 & d_2 & d_3 & d_4 & T \
      bottomrule
      end{tabular}
      end{table}
      end{document}


      edit: or you more prefer the following solution:



      documentclass[12pt,fleqn]{article}
      usepackage{diagbox}
      usepackage{booktabs,
      makecell, % <--- new
      multirow, % <--- new
      tabularx}
      usepackage[table]{xcolor}

      begin{document}
      begin{table}[h!]
      centering
      caption[caption]{Table 1}
      label{tab:table1}
      begin{tabular}{|l|cccc|c|}
      hline
      multirow{2}{*}{
      diagbox{textbf{Source}}{textbf{Destination}}
      }
      & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
      & & & & & \
      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
      textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
      hline
      end{tabular}
      end{table}
      end{document}


      which gives:



      enter image description here



      it's probably not difficult to guess which solution I prefer ...






      share|improve this answer



























        up vote
        2
        down vote













        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}
        %usepackage{pict2e} % not needed in this mwe
        %usepackage{keyval} % not needed in this mwe
        %usepackage{calc} % not needed in this mwe
        %usepackage{fp} % not needed in this mwe
        %usepackage{diagbox}
        usepackage{booktabs,
        multirow, % <--- new
        tabularx}
        usepackage[table]{xcolor}

        begin{document}
        begin{table}[h!]
        caption[short caption]{long caption}
        label{tab:table1}
        centering
        begin{tabular}{*{6}{>{$}c<{$}} }
        toprule
        multirow{2.4}{*}{textbf{Source}}
        & multicolumn{4}{c}{textbf{Destination}}
        & multirow{2.4}{*}{textbf{Supply}} \
        cmidrule{2-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
        textbf{Demand}
        & d_1 & d_2 & d_3 & d_4 & T \
        bottomrule
        end{tabular}
        end{table}
        end{document}


        edit: or you more prefer the following solution:



        documentclass[12pt,fleqn]{article}
        usepackage{diagbox}
        usepackage{booktabs,
        makecell, % <--- new
        multirow, % <--- new
        tabularx}
        usepackage[table]{xcolor}

        begin{document}
        begin{table}[h!]
        centering
        caption[caption]{Table 1}
        label{tab:table1}
        begin{tabular}{|l|cccc|c|}
        hline
        multirow{2}{*}{
        diagbox{textbf{Source}}{textbf{Destination}}
        }
        & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
        & & & & & \
        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
        textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
        hline
        end{tabular}
        end{table}
        end{document}


        which gives:



        enter image description here



        it's probably not difficult to guess which solution I prefer ...






        share|improve this answer

























          up vote
          2
          down vote










          up vote
          2
          down vote









          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}
          %usepackage{pict2e} % not needed in this mwe
          %usepackage{keyval} % not needed in this mwe
          %usepackage{calc} % not needed in this mwe
          %usepackage{fp} % not needed in this mwe
          %usepackage{diagbox}
          usepackage{booktabs,
          multirow, % <--- new
          tabularx}
          usepackage[table]{xcolor}

          begin{document}
          begin{table}[h!]
          caption[short caption]{long caption}
          label{tab:table1}
          centering
          begin{tabular}{*{6}{>{$}c<{$}} }
          toprule
          multirow{2.4}{*}{textbf{Source}}
          & multicolumn{4}{c}{textbf{Destination}}
          & multirow{2.4}{*}{textbf{Supply}} \
          cmidrule{2-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
          textbf{Demand}
          & d_1 & d_2 & d_3 & d_4 & T \
          bottomrule
          end{tabular}
          end{table}
          end{document}


          edit: or you more prefer the following solution:



          documentclass[12pt,fleqn]{article}
          usepackage{diagbox}
          usepackage{booktabs,
          makecell, % <--- new
          multirow, % <--- new
          tabularx}
          usepackage[table]{xcolor}

          begin{document}
          begin{table}[h!]
          centering
          caption[caption]{Table 1}
          label{tab:table1}
          begin{tabular}{|l|cccc|c|}
          hline
          multirow{2}{*}{
          diagbox{textbf{Source}}{textbf{Destination}}
          }
          & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
          & & & & & \
          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
          textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
          hline
          end{tabular}
          end{table}
          end{document}


          which gives:



          enter image description here



          it's probably not difficult to guess which solution I prefer ...






          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}
          %usepackage{pict2e} % not needed in this mwe
          %usepackage{keyval} % not needed in this mwe
          %usepackage{calc} % not needed in this mwe
          %usepackage{fp} % not needed in this mwe
          %usepackage{diagbox}
          usepackage{booktabs,
          multirow, % <--- new
          tabularx}
          usepackage[table]{xcolor}

          begin{document}
          begin{table}[h!]
          caption[short caption]{long caption}
          label{tab:table1}
          centering
          begin{tabular}{*{6}{>{$}c<{$}} }
          toprule
          multirow{2.4}{*}{textbf{Source}}
          & multicolumn{4}{c}{textbf{Destination}}
          & multirow{2.4}{*}{textbf{Supply}} \
          cmidrule{2-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
          textbf{Demand}
          & d_1 & d_2 & d_3 & d_4 & T \
          bottomrule
          end{tabular}
          end{table}
          end{document}


          edit: or you more prefer the following solution:



          documentclass[12pt,fleqn]{article}
          usepackage{diagbox}
          usepackage{booktabs,
          makecell, % <--- new
          multirow, % <--- new
          tabularx}
          usepackage[table]{xcolor}

          begin{document}
          begin{table}[h!]
          centering
          caption[caption]{Table 1}
          label{tab:table1}
          begin{tabular}{|l|cccc|c|}
          hline
          multirow{2}{*}{
          diagbox{textbf{Source}}{textbf{Destination}}
          }
          & $1$ & $2$ & $3$ & $4$ & textbf{Supply} \
          & & & & & \
          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
          textbf{Demand} & $d_1$ & $d_2$ & $d_3$ & $d_4$ & $T$\
          hline
          end{tabular}
          end{table}
          end{document}


          which gives:



          enter image description here



          it's probably not difficult to guess which solution I prefer ...







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 2 hours ago









          Zarko

          117k865155




          117k865155






















              up vote
              1
              down vote













              It is quite possible with some raiseboxes, but I don't think it's so nice:



              documentclass[12pt,fleqn]{article}
              usepackage{pict2e}
              usepackage{keyval}
              usepackage{calc}
              usepackage{fp}
              usepackage{diagbox}
              usepackage{booktabs}
              usepackage{tabularx,colortbl, makecell, caption}

              begin{document}

              begin{table}[h!]
              centering
              caption[caption]{Table 1}
              label{tab:table1}
              begin{tabular}{|l|*{4}{>{$}c<{$}}|>{$}c<{$}|}
              hline
              diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
              {raisebox{2.5ex}{textbf{Source}}}{raisebox{-0.5ex}{textbf{Destination}}} & raisebox{2.25ex}{$1$} & raisebox{2.25ex}{$2$} & raisebox{2.25ex}{$3$} & raisebox{2.25ex}{$4$} & raisebox{2.25ex}{textbf{Supply}} \
              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
              textbf{Demand} & d_1 & d_2 & d_3 & d_4 & T\
              hline
              end{tabular}
              end{table}

              end{document}


              enter image description here






              share|improve this answer

























                up vote
                1
                down vote













                It is quite possible with some raiseboxes, but I don't think it's so nice:



                documentclass[12pt,fleqn]{article}
                usepackage{pict2e}
                usepackage{keyval}
                usepackage{calc}
                usepackage{fp}
                usepackage{diagbox}
                usepackage{booktabs}
                usepackage{tabularx,colortbl, makecell, caption}

                begin{document}

                begin{table}[h!]
                centering
                caption[caption]{Table 1}
                label{tab:table1}
                begin{tabular}{|l|*{4}{>{$}c<{$}}|>{$}c<{$}|}
                hline
                diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
                {raisebox{2.5ex}{textbf{Source}}}{raisebox{-0.5ex}{textbf{Destination}}} & raisebox{2.25ex}{$1$} & raisebox{2.25ex}{$2$} & raisebox{2.25ex}{$3$} & raisebox{2.25ex}{$4$} & raisebox{2.25ex}{textbf{Supply}} \
                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
                textbf{Demand} & d_1 & d_2 & d_3 & d_4 & T\
                hline
                end{tabular}
                end{table}

                end{document}


                enter image description here






                share|improve this answer























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  It is quite possible with some raiseboxes, but I don't think it's so nice:



                  documentclass[12pt,fleqn]{article}
                  usepackage{pict2e}
                  usepackage{keyval}
                  usepackage{calc}
                  usepackage{fp}
                  usepackage{diagbox}
                  usepackage{booktabs}
                  usepackage{tabularx,colortbl, makecell, caption}

                  begin{document}

                  begin{table}[h!]
                  centering
                  caption[caption]{Table 1}
                  label{tab:table1}
                  begin{tabular}{|l|*{4}{>{$}c<{$}}|>{$}c<{$}|}
                  hline
                  diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
                  {raisebox{2.5ex}{textbf{Source}}}{raisebox{-0.5ex}{textbf{Destination}}} & raisebox{2.25ex}{$1$} & raisebox{2.25ex}{$2$} & raisebox{2.25ex}{$3$} & raisebox{2.25ex}{$4$} & raisebox{2.25ex}{textbf{Supply}} \
                  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
                  textbf{Demand} & d_1 & d_2 & d_3 & d_4 & T\
                  hline
                  end{tabular}
                  end{table}

                  end{document}


                  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}
                  usepackage{pict2e}
                  usepackage{keyval}
                  usepackage{calc}
                  usepackage{fp}
                  usepackage{diagbox}
                  usepackage{booktabs}
                  usepackage{tabularx,colortbl, makecell, caption}

                  begin{document}

                  begin{table}[h!]
                  centering
                  caption[caption]{Table 1}
                  label{tab:table1}
                  begin{tabular}{|l|*{4}{>{$}c<{$}}|>{$}c<{$}|}
                  hline
                  diagbox[innerwidth =40mm, height =15mm]%,innerleftsep = 12pt
                  {raisebox{2.5ex}{textbf{Source}}}{raisebox{-0.5ex}{textbf{Destination}}} & raisebox{2.25ex}{$1$} & raisebox{2.25ex}{$2$} & raisebox{2.25ex}{$3$} & raisebox{2.25ex}{$4$} & raisebox{2.25ex}{textbf{Supply}} \
                  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
                  textbf{Demand} & d_1 & d_2 & d_3 & d_4 & T\
                  hline
                  end{tabular}
                  end{table}

                  end{document}


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 hours ago









                  Bernard

                  163k768192




                  163k768192






























                      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

                      Михайлов, Христо

                      Гороховецкий артиллерийский полигон

                      Центральная группа войск