How to center the middle of a table to be in the center of the page?












1















I'd like to have the vertical rule in my {r|l} table to be horizontally aligned in the center of the page.



So far, I've only managed to do



begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}

begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}


which yields Output



How can I center the vertical lines of my tables to be in the center of the page?










share|improve this question







New contributor




Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I'd like to have them both aligned such that the vertical line is in the middle of pagewidth

    – Stephan
    2 hours ago
















1















I'd like to have the vertical rule in my {r|l} table to be horizontally aligned in the center of the page.



So far, I've only managed to do



begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}

begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}


which yields Output



How can I center the vertical lines of my tables to be in the center of the page?










share|improve this question







New contributor




Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I'd like to have them both aligned such that the vertical line is in the middle of pagewidth

    – Stephan
    2 hours ago














1












1








1


0






I'd like to have the vertical rule in my {r|l} table to be horizontally aligned in the center of the page.



So far, I've only managed to do



begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}

begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}


which yields Output



How can I center the vertical lines of my tables to be in the center of the page?










share|improve this question







New contributor




Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'd like to have the vertical rule in my {r|l} table to be horizontally aligned in the center of the page.



So far, I've only managed to do



begin{center}
begin{tabular}{r|l}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}

begin{center}
begin{tabular}{r|l}
long long & short
end{tabular}
end{center}


which yields Output



How can I center the vertical lines of my tables to be in the center of the page?







tables horizontal-alignment






share|improve this question







New contributor




Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









StephanStephan

1084




1084




New contributor




Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • I'd like to have them both aligned such that the vertical line is in the middle of pagewidth

    – Stephan
    2 hours ago



















  • I'd like to have them both aligned such that the vertical line is in the middle of pagewidth

    – Stephan
    2 hours ago

















I'd like to have them both aligned such that the vertical line is in the middle of pagewidth

– Stephan
2 hours ago





I'd like to have them both aligned such that the vertical line is in the middle of pagewidth

– Stephan
2 hours ago










2 Answers
2






active

oldest

votes


















2














You may need to define new column type (thanks @lockstep in his answer)



documentclass{article}
usepackage{array}

newcolumntype{L}[1]{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{C}[1]{>{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
newcolumntype{R}[1]{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}

begin{document}

begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}

begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
long long & short
end{tabular}

end{document}


which gives



enter image description here






share|improve this answer


























  • That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?

    – Stephan
    2 hours ago






  • 2





    The command raggedleft pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).

    – Partha D.
    1 hour ago











  • The answer from @CarLaTeX is definitely the more (probably the most) scientific and general solution.

    – Partha D.
    1 min ago





















2














You could give a fixed length to the columns of the tables.



If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:
.5linewidth (half line)
-2tabsep (minus the two spaces before and after the text column)
-.5arrayrulewidth (minus half of the width of the vertical bar).



In my MWE I use the calc package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth} to get the same result.



You can use lockstep's definitions with this length.



documentclass{article}
usepackage{array}
usepackage{calc}
newlength{myhalfpage}
setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}

begin{document}

begin{center}
begin{tabular}{R|L}
short & long long long \
short & long long long \
short & long long \
short & long long long\
end{tabular}
end{center}
begin{center}
begin{tabular}{R|L}
long long & short
end{tabular}
end{center}
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',
    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
    });


    }
    });






    Stephan is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f470181%2fhow-to-center-the-middle-of-a-table-to-be-in-the-center-of-the-page%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









    2














    You may need to define new column type (thanks @lockstep in his answer)



    documentclass{article}
    usepackage{array}

    newcolumntype{L}[1]{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{C}[1]{>{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{R}[1]{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}

    begin{document}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    short & long long long \
    short & long long long \
    short & long long \
    short & long long long\
    end{tabular}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    long long & short
    end{tabular}

    end{document}


    which gives



    enter image description here






    share|improve this answer


























    • That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?

      – Stephan
      2 hours ago






    • 2





      The command raggedleft pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).

      – Partha D.
      1 hour ago











    • The answer from @CarLaTeX is definitely the more (probably the most) scientific and general solution.

      – Partha D.
      1 min ago


















    2














    You may need to define new column type (thanks @lockstep in his answer)



    documentclass{article}
    usepackage{array}

    newcolumntype{L}[1]{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{C}[1]{>{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{R}[1]{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}

    begin{document}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    short & long long long \
    short & long long long \
    short & long long \
    short & long long long\
    end{tabular}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    long long & short
    end{tabular}

    end{document}


    which gives



    enter image description here






    share|improve this answer


























    • That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?

      – Stephan
      2 hours ago






    • 2





      The command raggedleft pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).

      – Partha D.
      1 hour ago











    • The answer from @CarLaTeX is definitely the more (probably the most) scientific and general solution.

      – Partha D.
      1 min ago
















    2












    2








    2







    You may need to define new column type (thanks @lockstep in his answer)



    documentclass{article}
    usepackage{array}

    newcolumntype{L}[1]{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{C}[1]{>{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{R}[1]{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}

    begin{document}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    short & long long long \
    short & long long long \
    short & long long \
    short & long long long\
    end{tabular}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    long long & short
    end{tabular}

    end{document}


    which gives



    enter image description here






    share|improve this answer















    You may need to define new column type (thanks @lockstep in his answer)



    documentclass{article}
    usepackage{array}

    newcolumntype{L}[1]{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{C}[1]{>{centeringletnewline\arraybackslashhspace{0pt}}m{#1}}
    newcolumntype{R}[1]{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{#1}}

    begin{document}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    short & long long long \
    short & long long long \
    short & long long \
    short & long long long\
    end{tabular}

    begin{tabular}{ R{0.465textwidth} | L{0.465textwidth}}
    long long & short
    end{tabular}

    end{document}


    which gives



    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 1 hour ago

























    answered 2 hours ago









    Partha D.Partha D.

    39316




    39316













    • That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?

      – Stephan
      2 hours ago






    • 2





      The command raggedleft pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).

      – Partha D.
      1 hour ago











    • The answer from @CarLaTeX is definitely the more (probably the most) scientific and general solution.

      – Partha D.
      1 min ago





















    • That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?

      – Stephan
      2 hours ago






    • 2





      The command raggedleft pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).

      – Partha D.
      1 hour ago











    • The answer from @CarLaTeX is definitely the more (probably the most) scientific and general solution.

      – Partha D.
      1 min ago



















    That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?

    – Stephan
    2 hours ago





    That's exactly it, thank you! One question though: why is raggedleft used in the right-aligned column?

    – Stephan
    2 hours ago




    2




    2





    The command raggedleft pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).

    – Partha D.
    1 hour ago





    The command raggedleft pushes all text to the right of the line or column, keeping the left side text margin ragged. // ...One more minor correction to my answer: 0.49textwidth gives an "Overfull hbox (10.59pt too wide)". This is due to the column separator and the adjacent spaces on either side. So, you will have to allot somewhat less width to the columns to really center the column-separator. In my example, 0.465 worked best (editing accordingly).

    – Partha D.
    1 hour ago













    The answer from @CarLaTeX is definitely the more (probably the most) scientific and general solution.

    – Partha D.
    1 min ago







    The answer from @CarLaTeX is definitely the more (probably the most) scientific and general solution.

    – Partha D.
    1 min ago













    2














    You could give a fixed length to the columns of the tables.



    If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:
    .5linewidth (half line)
    -2tabsep (minus the two spaces before and after the text column)
    -.5arrayrulewidth (minus half of the width of the vertical bar).



    In my MWE I use the calc package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth} to get the same result.



    You can use lockstep's definitions with this length.



    documentclass{article}
    usepackage{array}
    usepackage{calc}
    newlength{myhalfpage}
    setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
    newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
    newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
    newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}

    begin{document}

    begin{center}
    begin{tabular}{R|L}
    short & long long long \
    short & long long long \
    short & long long \
    short & long long long\
    end{tabular}
    end{center}
    begin{center}
    begin{tabular}{R|L}
    long long & short
    end{tabular}
    end{center}
    end{document}


    enter image description here






    share|improve this answer






























      2














      You could give a fixed length to the columns of the tables.



      If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:
      .5linewidth (half line)
      -2tabsep (minus the two spaces before and after the text column)
      -.5arrayrulewidth (minus half of the width of the vertical bar).



      In my MWE I use the calc package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth} to get the same result.



      You can use lockstep's definitions with this length.



      documentclass{article}
      usepackage{array}
      usepackage{calc}
      newlength{myhalfpage}
      setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
      newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
      newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
      newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}

      begin{document}

      begin{center}
      begin{tabular}{R|L}
      short & long long long \
      short & long long long \
      short & long long \
      short & long long long\
      end{tabular}
      end{center}
      begin{center}
      begin{tabular}{R|L}
      long long & short
      end{tabular}
      end{center}
      end{document}


      enter image description here






      share|improve this answer




























        2












        2








        2







        You could give a fixed length to the columns of the tables.



        If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:
        .5linewidth (half line)
        -2tabsep (minus the two spaces before and after the text column)
        -.5arrayrulewidth (minus half of the width of the vertical bar).



        In my MWE I use the calc package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth} to get the same result.



        You can use lockstep's definitions with this length.



        documentclass{article}
        usepackage{array}
        usepackage{calc}
        newlength{myhalfpage}
        setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
        newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
        newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
        newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}

        begin{document}

        begin{center}
        begin{tabular}{R|L}
        short & long long long \
        short & long long long \
        short & long long \
        short & long long long\
        end{tabular}
        end{center}
        begin{center}
        begin{tabular}{R|L}
        long long & short
        end{tabular}
        end{center}
        end{document}


        enter image description here






        share|improve this answer















        You could give a fixed length to the columns of the tables.



        If you want the columns to occupy all the space possible in the half of the line, you have to calculate their column width in this way, in order to not have an overfull hbox:
        .5linewidth (half line)
        -2tabsep (minus the two spaces before and after the text column)
        -.5arrayrulewidth (minus half of the width of the vertical bar).



        In my MWE I use the calc package, without it you can write setlength{myhalfpage}{dimexpr .5linewidth-2tabcolsep-.5arrayrulewidth} to get the same result.



        You can use lockstep's definitions with this length.



        documentclass{article}
        usepackage{array}
        usepackage{calc}
        newlength{myhalfpage}
        setlength{myhalfpage}{.5linewidth-2tabcolsep-.5arrayrulewidth}
        newcolumntype{L}{>{raggedrightletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
        newcolumntype{C}{>{centeringletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}
        newcolumntype{R}{>{raggedleftletnewline\arraybackslashhspace{0pt}}m{myhalfpage}}

        begin{document}

        begin{center}
        begin{tabular}{R|L}
        short & long long long \
        short & long long long \
        short & long long \
        short & long long long\
        end{tabular}
        end{center}
        begin{center}
        begin{tabular}{R|L}
        long long & short
        end{tabular}
        end{center}
        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 19 mins ago

























        answered 2 hours ago









        CarLaTeXCarLaTeX

        30.2k447127




        30.2k447127






















            Stephan is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Stephan is a new contributor. Be nice, and check out our Code of Conduct.













            Stephan is a new contributor. Be nice, and check out our Code of Conduct.












            Stephan is a new contributor. Be nice, and check out our Code of Conduct.
















            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%2f470181%2fhow-to-center-the-middle-of-a-table-to-be-in-the-center-of-the-page%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

            Plaza Victoria

            Puebla de Zaragoza

            Musa