Actual table column width is unequal with set number












2















I want to create a table with fixed column lengths like this:



documentclass[a4paper,12pt]{article}

begin{document}

begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

Table with actual widths

begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

end{document}


enter image description here



But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.



Why this is happening and how I can automate the process of getting right value?










share|improve this question


















  • 2





    The argument of the p columns specifies the textwidth inside the cells, not the total width with padding around the text.

    – samcarter
    1 hour ago






  • 2





    If you just for fun remove all other spaces begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|} you can see the effect

    – samcarter
    1 hour ago
















2















I want to create a table with fixed column lengths like this:



documentclass[a4paper,12pt]{article}

begin{document}

begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

Table with actual widths

begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

end{document}


enter image description here



But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.



Why this is happening and how I can automate the process of getting right value?










share|improve this question


















  • 2





    The argument of the p columns specifies the textwidth inside the cells, not the total width with padding around the text.

    – samcarter
    1 hour ago






  • 2





    If you just for fun remove all other spaces begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|} you can see the effect

    – samcarter
    1 hour ago














2












2








2








I want to create a table with fixed column lengths like this:



documentclass[a4paper,12pt]{article}

begin{document}

begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

Table with actual widths

begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

end{document}


enter image description here



But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.



Why this is happening and how I can automate the process of getting right value?










share|improve this question














I want to create a table with fixed column lengths like this:



documentclass[a4paper,12pt]{article}

begin{document}

begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

Table with actual widths

begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

end{document}


enter image description here



But column lengths are not the exact number, that I set. So I found the shift to make column with lengths, that I want.



Why this is happening and how I can automate the process of getting right value?







tables columns lengths






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









Shalom AlecheimShalom Alecheim

626




626








  • 2





    The argument of the p columns specifies the textwidth inside the cells, not the total width with padding around the text.

    – samcarter
    1 hour ago






  • 2





    If you just for fun remove all other spaces begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|} you can see the effect

    – samcarter
    1 hour ago














  • 2





    The argument of the p columns specifies the textwidth inside the cells, not the total width with padding around the text.

    – samcarter
    1 hour ago






  • 2





    If you just for fun remove all other spaces begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|} you can see the effect

    – samcarter
    1 hour ago








2




2





The argument of the p columns specifies the textwidth inside the cells, not the total width with padding around the text.

– samcarter
1 hour ago





The argument of the p columns specifies the textwidth inside the cells, not the total width with padding around the text.

– samcarter
1 hour ago




2




2





If you just for fun remove all other spaces begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|} you can see the effect

– samcarter
1 hour ago





If you just for fun remove all other spaces begin{tabular}{|@{}p{1cm}@{}|@{}p{2cm}@{}|@{}p{3cm}@{}|} you can see the effect

– samcarter
1 hour ago










2 Answers
2






active

oldest

votes


















3














documentclass[a4paper,12pt]{article}

begin{document}

setlengtharrayrulewidth{2pt}
begin{tabular}{|p{dimexpr1cm-2tabcolsep}
|p{dimexpr2cm-2tabcolsep}
|p{dimexpr3cm-2tabcolsep}|}
hline
1 cm & 2 cm & 3 cm \
hline
end{tabular}

rule{6cm}{2pt}
end{document}


make absolute width of cells as you like to have. rule is comparison of the table width.






share|improve this answer































    2














    Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:



    documentclass[a4paper,12pt]{article}
    usepackage{array, calc}

    newlength{lw}
    setlength{lw}{2tabcolsep+arrayrulewidth}

    begin{document}

    begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
    hline
    1 cm & 2 cm & 3 cm \
    hline
    end{tabular}
    Table with actual widths
    begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
    hline
    1 cm & 2 cm & 3 cm \
    hline
    end{tabular}

    end{document}


    producing :



    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',
      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%2f470712%2factual-table-column-width-is-unequal-with-set-number%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









      3














      documentclass[a4paper,12pt]{article}

      begin{document}

      setlengtharrayrulewidth{2pt}
      begin{tabular}{|p{dimexpr1cm-2tabcolsep}
      |p{dimexpr2cm-2tabcolsep}
      |p{dimexpr3cm-2tabcolsep}|}
      hline
      1 cm & 2 cm & 3 cm \
      hline
      end{tabular}

      rule{6cm}{2pt}
      end{document}


      make absolute width of cells as you like to have. rule is comparison of the table width.






      share|improve this answer




























        3














        documentclass[a4paper,12pt]{article}

        begin{document}

        setlengtharrayrulewidth{2pt}
        begin{tabular}{|p{dimexpr1cm-2tabcolsep}
        |p{dimexpr2cm-2tabcolsep}
        |p{dimexpr3cm-2tabcolsep}|}
        hline
        1 cm & 2 cm & 3 cm \
        hline
        end{tabular}

        rule{6cm}{2pt}
        end{document}


        make absolute width of cells as you like to have. rule is comparison of the table width.






        share|improve this answer


























          3












          3








          3







          documentclass[a4paper,12pt]{article}

          begin{document}

          setlengtharrayrulewidth{2pt}
          begin{tabular}{|p{dimexpr1cm-2tabcolsep}
          |p{dimexpr2cm-2tabcolsep}
          |p{dimexpr3cm-2tabcolsep}|}
          hline
          1 cm & 2 cm & 3 cm \
          hline
          end{tabular}

          rule{6cm}{2pt}
          end{document}


          make absolute width of cells as you like to have. rule is comparison of the table width.






          share|improve this answer













          documentclass[a4paper,12pt]{article}

          begin{document}

          setlengtharrayrulewidth{2pt}
          begin{tabular}{|p{dimexpr1cm-2tabcolsep}
          |p{dimexpr2cm-2tabcolsep}
          |p{dimexpr3cm-2tabcolsep}|}
          hline
          1 cm & 2 cm & 3 cm \
          hline
          end{tabular}

          rule{6cm}{2pt}
          end{document}


          make absolute width of cells as you like to have. rule is comparison of the table width.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          ZarkoZarko

          122k865160




          122k865160























              2














              Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:



              documentclass[a4paper,12pt]{article}
              usepackage{array, calc}

              newlength{lw}
              setlength{lw}{2tabcolsep+arrayrulewidth}

              begin{document}

              begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
              hline
              1 cm & 2 cm & 3 cm \
              hline
              end{tabular}
              Table with actual widths
              begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
              hline
              1 cm & 2 cm & 3 cm \
              hline
              end{tabular}

              end{document}


              producing :



              enter image description here






              share|improve this answer




























                2














                Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:



                documentclass[a4paper,12pt]{article}
                usepackage{array, calc}

                newlength{lw}
                setlength{lw}{2tabcolsep+arrayrulewidth}

                begin{document}

                begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
                hline
                1 cm & 2 cm & 3 cm \
                hline
                end{tabular}
                Table with actual widths
                begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
                hline
                1 cm & 2 cm & 3 cm \
                hline
                end{tabular}

                end{document}


                producing :



                enter image description here






                share|improve this answer


























                  2












                  2








                  2







                  Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:



                  documentclass[a4paper,12pt]{article}
                  usepackage{array, calc}

                  newlength{lw}
                  setlength{lw}{2tabcolsep+arrayrulewidth}

                  begin{document}

                  begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
                  hline
                  1 cm & 2 cm & 3 cm \
                  hline
                  end{tabular}
                  Table with actual widths
                  begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
                  hline
                  1 cm & 2 cm & 3 cm \
                  hline
                  end{tabular}

                  end{document}


                  producing :



                  enter image description here






                  share|improve this answer













                  Almost the same as @Zarko's answer, except reducing the (fine) length of the line separating columns... and a introducing a customized macro:



                  documentclass[a4paper,12pt]{article}
                  usepackage{array, calc}

                  newlength{lw}
                  setlength{lw}{2tabcolsep+arrayrulewidth}

                  begin{document}

                  begin{tabular}{| p{1cm-lw} | p{2cm-lw} | p{3cm-lw} |}
                  hline
                  1 cm & 2 cm & 3 cm \
                  hline
                  end{tabular}
                  Table with actual widths
                  begin{tabular}{|p{0.56cm}|p{1.56cm}|p{2.56cm}|}
                  hline
                  1 cm & 2 cm & 3 cm \
                  hline
                  end{tabular}

                  end{document}


                  producing :



                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Partha D.Partha D.

                  46816




                  46816






























                      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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f470712%2factual-table-column-width-is-unequal-with-set-number%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

                      Knooppunt Holsloot

                      Altaar (religie)

                      Gregoriusmis