Unexpected space in table












6














I try to create a table in latex, however, the space between some columns is very unexpected.



Here is my working example:



begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


Here is the output



If the title of the table is short then, there is no problem.



Any help, please?










share|improve this question


















  • 1




    Consider using booktabs...
    – Werner
    Dec 2 at 7:31
















6














I try to create a table in latex, however, the space between some columns is very unexpected.



Here is my working example:



begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


Here is the output



If the title of the table is short then, there is no problem.



Any help, please?










share|improve this question


















  • 1




    Consider using booktabs...
    – Werner
    Dec 2 at 7:31














6












6








6


1





I try to create a table in latex, however, the space between some columns is very unexpected.



Here is my working example:



begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


Here is the output



If the title of the table is short then, there is no problem.



Any help, please?










share|improve this question













I try to create a table in latex, however, the space between some columns is very unexpected.



Here is my working example:



begin{table}[H]
centering
begin{tabular}{c c c c c c}
hline hline
& & The title of my table is long & & \ hline hline
Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
1 & 1400 & 1450& 300 &3340 & \
2 & & & & & \
3 & & & & &
\
hline
hline
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


Here is the output



If the title of the table is short then, there is no problem.



Any help, please?







tables






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 2 at 6:47









Maryam

457




457








  • 1




    Consider using booktabs...
    – Werner
    Dec 2 at 7:31














  • 1




    Consider using booktabs...
    – Werner
    Dec 2 at 7:31








1




1




Consider using booktabs...
– Werner
Dec 2 at 7:31




Consider using booktabs...
– Werner
Dec 2 at 7:31










2 Answers
2






active

oldest

votes


















10














Reason



The title of your table is considered as an element in Column 3.





Fix



documentclass{article}
begin{document}
begin{table}
centering
begin{tabular}{cccccc}
hlinehline
multicolumn{6}{c}{The title of my table is long}\
hlinehline
Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
1 & 1400 & 1450 & 300 & 3340 & 0 \
2 & & & & & \
3 & & & & & \
hlinehline
end{tabular}
caption{Caption}
end{table}
end{document}


enter image description here






share|improve this answer































    12














    As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.



    One way to fix this issue is to let the title string span all 6 columns of the tabular environment, via a multicolumn{6}{c}{...} directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table and that it should not be placed inside the tabular environment. Instead, it should be placed inside the argument of caption, and the caption statement should likely be placed above rather than below the tabular material.



    While you're at it, you may also want to improve the "look" of the table by replacing the hline statements with toprule, midrule, and bottomrule -- macros provided by the booktabs package.



    The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn, and (3) the fix achieved by moving the title outside of the tabular environment (and using the line-drawing macros of the booktabs package).



    enter image description here



    documentclass{article}
    usepackage{booktabs}
    usepackage[skip=0.333baselineskip]{caption} % optional
    begin{document}

    begin{table}[ht!] %% OP's original code
    centering
    begin{tabular}{c c c c c c}
    hline hline
    & & The title of my table is long & & \
    hline hline
    Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
    1 & 1400 & 1450& 300 &3340 & 4400 \
    2 & & & & & \
    3 & & & & & \
    hline hline
    end{tabular}
    caption{Caption}
    label{tab:my_label_1}
    end{table}

    begin{table}[h] %% using multicolumn to fix the spacing issue
    centering
    begin{tabular}{c c c c c c}
    hline hline
    multicolumn{6}{c}{The title of my table is long}\
    hline hline
    Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
    1 & 1400 & 1450& 300 &3340 & 4400 \
    2 & & & & & \
    3 & & & & & \
    hline hline
    end{tabular}
    caption{Caption}
    label{tab:my_label_2}
    end{table}

    begin{table}[h] %% using caption and the macros of the booktabs package
    caption{The title of my table}
    label{tab:my_label_3}
    centering
    begin{tabular}{@{} *{6}{c} @{}}
    toprule
    Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
    midrule
    1 & 1400 & 1450& 300 &3340 & 4400 \
    2 & & & & & \
    3 & & & & & \
    bottomrule
    end{tabular}
    end{table}
    end{document}








    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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462788%2funexpected-space-in-table%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









      10














      Reason



      The title of your table is considered as an element in Column 3.





      Fix



      documentclass{article}
      begin{document}
      begin{table}
      centering
      begin{tabular}{cccccc}
      hlinehline
      multicolumn{6}{c}{The title of my table is long}\
      hlinehline
      Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
      1 & 1400 & 1450 & 300 & 3340 & 0 \
      2 & & & & & \
      3 & & & & & \
      hlinehline
      end{tabular}
      caption{Caption}
      end{table}
      end{document}


      enter image description here






      share|improve this answer




























        10














        Reason



        The title of your table is considered as an element in Column 3.





        Fix



        documentclass{article}
        begin{document}
        begin{table}
        centering
        begin{tabular}{cccccc}
        hlinehline
        multicolumn{6}{c}{The title of my table is long}\
        hlinehline
        Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
        1 & 1400 & 1450 & 300 & 3340 & 0 \
        2 & & & & & \
        3 & & & & & \
        hlinehline
        end{tabular}
        caption{Caption}
        end{table}
        end{document}


        enter image description here






        share|improve this answer


























          10












          10








          10






          Reason



          The title of your table is considered as an element in Column 3.





          Fix



          documentclass{article}
          begin{document}
          begin{table}
          centering
          begin{tabular}{cccccc}
          hlinehline
          multicolumn{6}{c}{The title of my table is long}\
          hlinehline
          Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
          1 & 1400 & 1450 & 300 & 3340 & 0 \
          2 & & & & & \
          3 & & & & & \
          hlinehline
          end{tabular}
          caption{Caption}
          end{table}
          end{document}


          enter image description here






          share|improve this answer














          Reason



          The title of your table is considered as an element in Column 3.





          Fix



          documentclass{article}
          begin{document}
          begin{table}
          centering
          begin{tabular}{cccccc}
          hlinehline
          multicolumn{6}{c}{The title of my table is long}\
          hlinehline
          Criteria & $M_1$ & $M_2$ & $M_3$ & $M_4$ & $M_5$ \
          1 & 1400 & 1450 & 300 & 3340 & 0 \
          2 & & & & & \
          3 & & & & & \
          hlinehline
          end{tabular}
          caption{Caption}
          end{table}
          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 2 at 10:57

























          answered Dec 2 at 7:11









          JouleV

          1,976425




          1,976425























              12














              As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.



              One way to fix this issue is to let the title string span all 6 columns of the tabular environment, via a multicolumn{6}{c}{...} directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table and that it should not be placed inside the tabular environment. Instead, it should be placed inside the argument of caption, and the caption statement should likely be placed above rather than below the tabular material.



              While you're at it, you may also want to improve the "look" of the table by replacing the hline statements with toprule, midrule, and bottomrule -- macros provided by the booktabs package.



              The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn, and (3) the fix achieved by moving the title outside of the tabular environment (and using the line-drawing macros of the booktabs package).



              enter image description here



              documentclass{article}
              usepackage{booktabs}
              usepackage[skip=0.333baselineskip]{caption} % optional
              begin{document}

              begin{table}[ht!] %% OP's original code
              centering
              begin{tabular}{c c c c c c}
              hline hline
              & & The title of my table is long & & \
              hline hline
              Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
              1 & 1400 & 1450& 300 &3340 & 4400 \
              2 & & & & & \
              3 & & & & & \
              hline hline
              end{tabular}
              caption{Caption}
              label{tab:my_label_1}
              end{table}

              begin{table}[h] %% using multicolumn to fix the spacing issue
              centering
              begin{tabular}{c c c c c c}
              hline hline
              multicolumn{6}{c}{The title of my table is long}\
              hline hline
              Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
              1 & 1400 & 1450& 300 &3340 & 4400 \
              2 & & & & & \
              3 & & & & & \
              hline hline
              end{tabular}
              caption{Caption}
              label{tab:my_label_2}
              end{table}

              begin{table}[h] %% using caption and the macros of the booktabs package
              caption{The title of my table}
              label{tab:my_label_3}
              centering
              begin{tabular}{@{} *{6}{c} @{}}
              toprule
              Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
              midrule
              1 & 1400 & 1450& 300 &3340 & 4400 \
              2 & & & & & \
              3 & & & & & \
              bottomrule
              end{tabular}
              end{table}
              end{document}








              share|improve this answer




























                12














                As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.



                One way to fix this issue is to let the title string span all 6 columns of the tabular environment, via a multicolumn{6}{c}{...} directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table and that it should not be placed inside the tabular environment. Instead, it should be placed inside the argument of caption, and the caption statement should likely be placed above rather than below the tabular material.



                While you're at it, you may also want to improve the "look" of the table by replacing the hline statements with toprule, midrule, and bottomrule -- macros provided by the booktabs package.



                The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn, and (3) the fix achieved by moving the title outside of the tabular environment (and using the line-drawing macros of the booktabs package).



                enter image description here



                documentclass{article}
                usepackage{booktabs}
                usepackage[skip=0.333baselineskip]{caption} % optional
                begin{document}

                begin{table}[ht!] %% OP's original code
                centering
                begin{tabular}{c c c c c c}
                hline hline
                & & The title of my table is long & & \
                hline hline
                Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
                1 & 1400 & 1450& 300 &3340 & 4400 \
                2 & & & & & \
                3 & & & & & \
                hline hline
                end{tabular}
                caption{Caption}
                label{tab:my_label_1}
                end{table}

                begin{table}[h] %% using multicolumn to fix the spacing issue
                centering
                begin{tabular}{c c c c c c}
                hline hline
                multicolumn{6}{c}{The title of my table is long}\
                hline hline
                Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
                1 & 1400 & 1450& 300 &3340 & 4400 \
                2 & & & & & \
                3 & & & & & \
                hline hline
                end{tabular}
                caption{Caption}
                label{tab:my_label_2}
                end{table}

                begin{table}[h] %% using caption and the macros of the booktabs package
                caption{The title of my table}
                label{tab:my_label_3}
                centering
                begin{tabular}{@{} *{6}{c} @{}}
                toprule
                Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
                midrule
                1 & 1400 & 1450& 300 &3340 & 4400 \
                2 & & & & & \
                3 & & & & & \
                bottomrule
                end{tabular}
                end{table}
                end{document}








                share|improve this answer


























                  12












                  12








                  12






                  As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.



                  One way to fix this issue is to let the title string span all 6 columns of the tabular environment, via a multicolumn{6}{c}{...} directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table and that it should not be placed inside the tabular environment. Instead, it should be placed inside the argument of caption, and the caption statement should likely be placed above rather than below the tabular material.



                  While you're at it, you may also want to improve the "look" of the table by replacing the hline statements with toprule, midrule, and bottomrule -- macros provided by the booktabs package.



                  The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn, and (3) the fix achieved by moving the title outside of the tabular environment (and using the line-drawing macros of the booktabs package).



                  enter image description here



                  documentclass{article}
                  usepackage{booktabs}
                  usepackage[skip=0.333baselineskip]{caption} % optional
                  begin{document}

                  begin{table}[ht!] %% OP's original code
                  centering
                  begin{tabular}{c c c c c c}
                  hline hline
                  & & The title of my table is long & & \
                  hline hline
                  Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
                  1 & 1400 & 1450& 300 &3340 & 4400 \
                  2 & & & & & \
                  3 & & & & & \
                  hline hline
                  end{tabular}
                  caption{Caption}
                  label{tab:my_label_1}
                  end{table}

                  begin{table}[h] %% using multicolumn to fix the spacing issue
                  centering
                  begin{tabular}{c c c c c c}
                  hline hline
                  multicolumn{6}{c}{The title of my table is long}\
                  hline hline
                  Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
                  1 & 1400 & 1450& 300 &3340 & 4400 \
                  2 & & & & & \
                  3 & & & & & \
                  hline hline
                  end{tabular}
                  caption{Caption}
                  label{tab:my_label_2}
                  end{table}

                  begin{table}[h] %% using caption and the macros of the booktabs package
                  caption{The title of my table}
                  label{tab:my_label_3}
                  centering
                  begin{tabular}{@{} *{6}{c} @{}}
                  toprule
                  Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
                  midrule
                  1 & 1400 & 1450& 300 &3340 & 4400 \
                  2 & & & & & \
                  3 & & & & & \
                  bottomrule
                  end{tabular}
                  end{table}
                  end{document}








                  share|improve this answer














                  As @DũngVũ has already pointed out in this answer, the immediate cause of the problem is that you've assigned the string "The title of my table is long" to the third column of the six-column table. That third column is thus made as wide as is needed to display the title string.



                  One way to fix this issue is to let the title string span all 6 columns of the tabular environment, via a multicolumn{6}{c}{...} directive. This method "works", but only if the width of the title string is less than the width of the remaining tabular material. A second, and in my view more robust fix starts off by recognizing that the title string is, structurally speaking, part of the title of the table and that it should not be placed inside the tabular environment. Instead, it should be placed inside the argument of caption, and the caption statement should likely be placed above rather than below the tabular material.



                  While you're at it, you may also want to improve the "look" of the table by replacing the hline statements with toprule, midrule, and bottomrule -- macros provided by the booktabs package.



                  The following screenshot displays 3 tables: (1) the OP's original approach, (2) the fix achieved by using multicolumn, and (3) the fix achieved by moving the title outside of the tabular environment (and using the line-drawing macros of the booktabs package).



                  enter image description here



                  documentclass{article}
                  usepackage{booktabs}
                  usepackage[skip=0.333baselineskip]{caption} % optional
                  begin{document}

                  begin{table}[ht!] %% OP's original code
                  centering
                  begin{tabular}{c c c c c c}
                  hline hline
                  & & The title of my table is long & & \
                  hline hline
                  Criteria & M$_{1}$ & M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
                  1 & 1400 & 1450& 300 &3340 & 4400 \
                  2 & & & & & \
                  3 & & & & & \
                  hline hline
                  end{tabular}
                  caption{Caption}
                  label{tab:my_label_1}
                  end{table}

                  begin{table}[h] %% using multicolumn to fix the spacing issue
                  centering
                  begin{tabular}{c c c c c c}
                  hline hline
                  multicolumn{6}{c}{The title of my table is long}\
                  hline hline
                  Criteria & M$_{1}$& M$_{2}$ & M$_{3}$& M$_{4}$& M$_{5}$\
                  1 & 1400 & 1450& 300 &3340 & 4400 \
                  2 & & & & & \
                  3 & & & & & \
                  hline hline
                  end{tabular}
                  caption{Caption}
                  label{tab:my_label_2}
                  end{table}

                  begin{table}[h] %% using caption and the macros of the booktabs package
                  caption{The title of my table}
                  label{tab:my_label_3}
                  centering
                  begin{tabular}{@{} *{6}{c} @{}}
                  toprule
                  Criteria & Mtextsubscript{1}& Mtextsubscript{2} & Mtextsubscript{3}& Mtextsubscript{4}& Mtextsubscript{5}\
                  midrule
                  1 & 1400 & 1450& 300 &3340 & 4400 \
                  2 & & & & & \
                  3 & & & & & \
                  bottomrule
                  end{tabular}
                  end{table}
                  end{document}









                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 2 at 8:08

























                  answered Dec 2 at 7:52









                  Mico

                  273k30369756




                  273k30369756






























                      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%2f462788%2funexpected-space-in-table%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

                      AnyDesk - Fatal Program Failure

                      How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

                      QoS: MAC-Priority for clients behind a repeater