center a table that uses resizebox












16















I create a table that I would like centered on the page horizontally. I scale the table size using resizebox. However, doing so, left aligns the table. How do I center it?



Here's a MWE:



documentclass[11pt,english,titlepage]{article}
usepackage{graphicx}


begin{document}

begin{table}
caption{mytable}
resizebox{.5textwidth}{!}{

begin{centering}
begin{tabular}{rrr}
A & B & C \
hline
A1 & B1 &C1\
A2 & B2 & C2 \
A3 & B3 & C3 \
end{tabular}
end{centering}
}
end{table}

end{document}









share|improve this question





























    16















    I create a table that I would like centered on the page horizontally. I scale the table size using resizebox. However, doing so, left aligns the table. How do I center it?



    Here's a MWE:



    documentclass[11pt,english,titlepage]{article}
    usepackage{graphicx}


    begin{document}

    begin{table}
    caption{mytable}
    resizebox{.5textwidth}{!}{

    begin{centering}
    begin{tabular}{rrr}
    A & B & C \
    hline
    A1 & B1 &C1\
    A2 & B2 & C2 \
    A3 & B3 & C3 \
    end{tabular}
    end{centering}
    }
    end{table}

    end{document}









    share|improve this question



























      16












      16








      16


      4






      I create a table that I would like centered on the page horizontally. I scale the table size using resizebox. However, doing so, left aligns the table. How do I center it?



      Here's a MWE:



      documentclass[11pt,english,titlepage]{article}
      usepackage{graphicx}


      begin{document}

      begin{table}
      caption{mytable}
      resizebox{.5textwidth}{!}{

      begin{centering}
      begin{tabular}{rrr}
      A & B & C \
      hline
      A1 & B1 &C1\
      A2 & B2 & C2 \
      A3 & B3 & C3 \
      end{tabular}
      end{centering}
      }
      end{table}

      end{document}









      share|improve this question
















      I create a table that I would like centered on the page horizontally. I scale the table size using resizebox. However, doing so, left aligns the table. How do I center it?



      Here's a MWE:



      documentclass[11pt,english,titlepage]{article}
      usepackage{graphicx}


      begin{document}

      begin{table}
      caption{mytable}
      resizebox{.5textwidth}{!}{

      begin{centering}
      begin{tabular}{rrr}
      A & B & C \
      hline
      A1 & B1 &C1\
      A2 & B2 & C2 \
      A3 & B3 & C3 \
      end{tabular}
      end{centering}
      }
      end{table}

      end{document}






      tables horizontal-alignment scaling






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 20 mins ago









      Martin Scharrer

      199k45634818




      199k45634818










      asked Apr 30 '14 at 21:42









      AlexAlex

      87141935




      87141935






















          2 Answers
          2






          active

          oldest

          votes


















          25














          There is no centering environment. And issuing centering inside resizebox doesn't make sense anyway: it should be outside, because you want to center the resized box.



          documentclass[11pt,english,titlepage]{article}
          usepackage{graphicx}

          begin{document}

          begin{table}
          centering
          caption{mytable}
          resizebox{.5textwidth}{!}{% <------ Don't forget this %
          begin{tabular}{rrr}
          A & B & C \
          hline
          A1 & B1 & C1 \
          A2 & B2 & C2 \
          A3 & B3 & C3 \
          end{tabular}% <------ Don't forget this %
          }
          end{table}

          end{document}





          share|improve this answer



















          • 1





            @HeikoOberdiek That's my speciality, ask David in chat. ;-)

            – egreg
            Apr 30 '14 at 22:32








          • 1





            @egreg: why do you need the % there?

            – Alex
            Jul 28 '16 at 4:21








          • 6





            @Alex Without them you'd get spaces on either side of the table

            – egreg
            Jul 28 '16 at 7:35



















          0














          Here an alternative answer using adjustbox. It covers the functionality of resizebox and is also able to center its content. It also removes the need of escaping the line breaks with % as seen in egregs answer, as the adjustbox environment removes the spaces added by them.



          It is even possible to produce the table environment using adjustbox keys, or even to get the whole tabular environment replaced. This saves you a lot of typing in the long run. Note that the order of most adjustbox keys matter.



          documentclass[11pt,english,titlepage]{article}
          usepackage{adjustbox}

          begin{document}

          begin{table}
          caption{mytable}% will not give you proper skip as it is configured for placement below the content
          begin{adjustbox}{width=.5textwidth,center}
          begin{tabular}{rrr}
          A & B & C \
          hline
          A1 & B1 & C1 \
          A2 & B2 & C2 \
          A3 & B3 & C3 \
          end{tabular}
          end{adjustbox}
          end{table}

          % shorter, also covering the `table` environment
          begin{adjustbox}{width=.5textwidth,center,caption=mytable,float=table}
          begin{tabular}{rrr}
          A & B & C \
          hline
          A1 & B1 & C1 \
          A2 & B2 & C2 \
          A3 & B3 & C3 \
          end{tabular}
          end{adjustbox}

          % even shorter, now also covering the `tabular` environment
          begin{adjustbox}{tabular=rrr,width=.5textwidth,center,caption=mytable,float=table}
          A & B & C \
          hline
          A1 & B1 & C1 \
          A2 & B2 & C2 \
          A3 & B3 & C3 \
          end{adjustbox}

          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%2f174566%2fcenter-a-table-that-uses-resizebox%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









            25














            There is no centering environment. And issuing centering inside resizebox doesn't make sense anyway: it should be outside, because you want to center the resized box.



            documentclass[11pt,english,titlepage]{article}
            usepackage{graphicx}

            begin{document}

            begin{table}
            centering
            caption{mytable}
            resizebox{.5textwidth}{!}{% <------ Don't forget this %
            begin{tabular}{rrr}
            A & B & C \
            hline
            A1 & B1 & C1 \
            A2 & B2 & C2 \
            A3 & B3 & C3 \
            end{tabular}% <------ Don't forget this %
            }
            end{table}

            end{document}





            share|improve this answer



















            • 1





              @HeikoOberdiek That's my speciality, ask David in chat. ;-)

              – egreg
              Apr 30 '14 at 22:32








            • 1





              @egreg: why do you need the % there?

              – Alex
              Jul 28 '16 at 4:21








            • 6





              @Alex Without them you'd get spaces on either side of the table

              – egreg
              Jul 28 '16 at 7:35
















            25














            There is no centering environment. And issuing centering inside resizebox doesn't make sense anyway: it should be outside, because you want to center the resized box.



            documentclass[11pt,english,titlepage]{article}
            usepackage{graphicx}

            begin{document}

            begin{table}
            centering
            caption{mytable}
            resizebox{.5textwidth}{!}{% <------ Don't forget this %
            begin{tabular}{rrr}
            A & B & C \
            hline
            A1 & B1 & C1 \
            A2 & B2 & C2 \
            A3 & B3 & C3 \
            end{tabular}% <------ Don't forget this %
            }
            end{table}

            end{document}





            share|improve this answer



















            • 1





              @HeikoOberdiek That's my speciality, ask David in chat. ;-)

              – egreg
              Apr 30 '14 at 22:32








            • 1





              @egreg: why do you need the % there?

              – Alex
              Jul 28 '16 at 4:21








            • 6





              @Alex Without them you'd get spaces on either side of the table

              – egreg
              Jul 28 '16 at 7:35














            25












            25








            25







            There is no centering environment. And issuing centering inside resizebox doesn't make sense anyway: it should be outside, because you want to center the resized box.



            documentclass[11pt,english,titlepage]{article}
            usepackage{graphicx}

            begin{document}

            begin{table}
            centering
            caption{mytable}
            resizebox{.5textwidth}{!}{% <------ Don't forget this %
            begin{tabular}{rrr}
            A & B & C \
            hline
            A1 & B1 & C1 \
            A2 & B2 & C2 \
            A3 & B3 & C3 \
            end{tabular}% <------ Don't forget this %
            }
            end{table}

            end{document}





            share|improve this answer













            There is no centering environment. And issuing centering inside resizebox doesn't make sense anyway: it should be outside, because you want to center the resized box.



            documentclass[11pt,english,titlepage]{article}
            usepackage{graphicx}

            begin{document}

            begin{table}
            centering
            caption{mytable}
            resizebox{.5textwidth}{!}{% <------ Don't forget this %
            begin{tabular}{rrr}
            A & B & C \
            hline
            A1 & B1 & C1 \
            A2 & B2 & C2 \
            A3 & B3 & C3 \
            end{tabular}% <------ Don't forget this %
            }
            end{table}

            end{document}






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 30 '14 at 22:22









            egregegreg

            712k8618933179




            712k8618933179








            • 1





              @HeikoOberdiek That's my speciality, ask David in chat. ;-)

              – egreg
              Apr 30 '14 at 22:32








            • 1





              @egreg: why do you need the % there?

              – Alex
              Jul 28 '16 at 4:21








            • 6





              @Alex Without them you'd get spaces on either side of the table

              – egreg
              Jul 28 '16 at 7:35














            • 1





              @HeikoOberdiek That's my speciality, ask David in chat. ;-)

              – egreg
              Apr 30 '14 at 22:32








            • 1





              @egreg: why do you need the % there?

              – Alex
              Jul 28 '16 at 4:21








            • 6





              @Alex Without them you'd get spaces on either side of the table

              – egreg
              Jul 28 '16 at 7:35








            1




            1





            @HeikoOberdiek That's my speciality, ask David in chat. ;-)

            – egreg
            Apr 30 '14 at 22:32







            @HeikoOberdiek That's my speciality, ask David in chat. ;-)

            – egreg
            Apr 30 '14 at 22:32






            1




            1





            @egreg: why do you need the % there?

            – Alex
            Jul 28 '16 at 4:21







            @egreg: why do you need the % there?

            – Alex
            Jul 28 '16 at 4:21






            6




            6





            @Alex Without them you'd get spaces on either side of the table

            – egreg
            Jul 28 '16 at 7:35





            @Alex Without them you'd get spaces on either side of the table

            – egreg
            Jul 28 '16 at 7:35











            0














            Here an alternative answer using adjustbox. It covers the functionality of resizebox and is also able to center its content. It also removes the need of escaping the line breaks with % as seen in egregs answer, as the adjustbox environment removes the spaces added by them.



            It is even possible to produce the table environment using adjustbox keys, or even to get the whole tabular environment replaced. This saves you a lot of typing in the long run. Note that the order of most adjustbox keys matter.



            documentclass[11pt,english,titlepage]{article}
            usepackage{adjustbox}

            begin{document}

            begin{table}
            caption{mytable}% will not give you proper skip as it is configured for placement below the content
            begin{adjustbox}{width=.5textwidth,center}
            begin{tabular}{rrr}
            A & B & C \
            hline
            A1 & B1 & C1 \
            A2 & B2 & C2 \
            A3 & B3 & C3 \
            end{tabular}
            end{adjustbox}
            end{table}

            % shorter, also covering the `table` environment
            begin{adjustbox}{width=.5textwidth,center,caption=mytable,float=table}
            begin{tabular}{rrr}
            A & B & C \
            hline
            A1 & B1 & C1 \
            A2 & B2 & C2 \
            A3 & B3 & C3 \
            end{tabular}
            end{adjustbox}

            % even shorter, now also covering the `tabular` environment
            begin{adjustbox}{tabular=rrr,width=.5textwidth,center,caption=mytable,float=table}
            A & B & C \
            hline
            A1 & B1 & C1 \
            A2 & B2 & C2 \
            A3 & B3 & C3 \
            end{adjustbox}

            end{document}





            share|improve this answer




























              0














              Here an alternative answer using adjustbox. It covers the functionality of resizebox and is also able to center its content. It also removes the need of escaping the line breaks with % as seen in egregs answer, as the adjustbox environment removes the spaces added by them.



              It is even possible to produce the table environment using adjustbox keys, or even to get the whole tabular environment replaced. This saves you a lot of typing in the long run. Note that the order of most adjustbox keys matter.



              documentclass[11pt,english,titlepage]{article}
              usepackage{adjustbox}

              begin{document}

              begin{table}
              caption{mytable}% will not give you proper skip as it is configured for placement below the content
              begin{adjustbox}{width=.5textwidth,center}
              begin{tabular}{rrr}
              A & B & C \
              hline
              A1 & B1 & C1 \
              A2 & B2 & C2 \
              A3 & B3 & C3 \
              end{tabular}
              end{adjustbox}
              end{table}

              % shorter, also covering the `table` environment
              begin{adjustbox}{width=.5textwidth,center,caption=mytable,float=table}
              begin{tabular}{rrr}
              A & B & C \
              hline
              A1 & B1 & C1 \
              A2 & B2 & C2 \
              A3 & B3 & C3 \
              end{tabular}
              end{adjustbox}

              % even shorter, now also covering the `tabular` environment
              begin{adjustbox}{tabular=rrr,width=.5textwidth,center,caption=mytable,float=table}
              A & B & C \
              hline
              A1 & B1 & C1 \
              A2 & B2 & C2 \
              A3 & B3 & C3 \
              end{adjustbox}

              end{document}





              share|improve this answer


























                0












                0








                0







                Here an alternative answer using adjustbox. It covers the functionality of resizebox and is also able to center its content. It also removes the need of escaping the line breaks with % as seen in egregs answer, as the adjustbox environment removes the spaces added by them.



                It is even possible to produce the table environment using adjustbox keys, or even to get the whole tabular environment replaced. This saves you a lot of typing in the long run. Note that the order of most adjustbox keys matter.



                documentclass[11pt,english,titlepage]{article}
                usepackage{adjustbox}

                begin{document}

                begin{table}
                caption{mytable}% will not give you proper skip as it is configured for placement below the content
                begin{adjustbox}{width=.5textwidth,center}
                begin{tabular}{rrr}
                A & B & C \
                hline
                A1 & B1 & C1 \
                A2 & B2 & C2 \
                A3 & B3 & C3 \
                end{tabular}
                end{adjustbox}
                end{table}

                % shorter, also covering the `table` environment
                begin{adjustbox}{width=.5textwidth,center,caption=mytable,float=table}
                begin{tabular}{rrr}
                A & B & C \
                hline
                A1 & B1 & C1 \
                A2 & B2 & C2 \
                A3 & B3 & C3 \
                end{tabular}
                end{adjustbox}

                % even shorter, now also covering the `tabular` environment
                begin{adjustbox}{tabular=rrr,width=.5textwidth,center,caption=mytable,float=table}
                A & B & C \
                hline
                A1 & B1 & C1 \
                A2 & B2 & C2 \
                A3 & B3 & C3 \
                end{adjustbox}

                end{document}





                share|improve this answer













                Here an alternative answer using adjustbox. It covers the functionality of resizebox and is also able to center its content. It also removes the need of escaping the line breaks with % as seen in egregs answer, as the adjustbox environment removes the spaces added by them.



                It is even possible to produce the table environment using adjustbox keys, or even to get the whole tabular environment replaced. This saves you a lot of typing in the long run. Note that the order of most adjustbox keys matter.



                documentclass[11pt,english,titlepage]{article}
                usepackage{adjustbox}

                begin{document}

                begin{table}
                caption{mytable}% will not give you proper skip as it is configured for placement below the content
                begin{adjustbox}{width=.5textwidth,center}
                begin{tabular}{rrr}
                A & B & C \
                hline
                A1 & B1 & C1 \
                A2 & B2 & C2 \
                A3 & B3 & C3 \
                end{tabular}
                end{adjustbox}
                end{table}

                % shorter, also covering the `table` environment
                begin{adjustbox}{width=.5textwidth,center,caption=mytable,float=table}
                begin{tabular}{rrr}
                A & B & C \
                hline
                A1 & B1 & C1 \
                A2 & B2 & C2 \
                A3 & B3 & C3 \
                end{tabular}
                end{adjustbox}

                % even shorter, now also covering the `tabular` environment
                begin{adjustbox}{tabular=rrr,width=.5textwidth,center,caption=mytable,float=table}
                A & B & C \
                hline
                A1 & B1 & C1 \
                A2 & B2 & C2 \
                A3 & B3 & C3 \
                end{adjustbox}

                end{document}






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 20 mins ago









                Martin ScharrerMartin Scharrer

                199k45634818




                199k45634818






























                    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%2f174566%2fcenter-a-table-that-uses-resizebox%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

                    サソリ

                    広島県道265号伴広島線

                    Accessing regular linux commands in Huawei's Dopra Linux