Centering a box independent of documents margin












2














Is there a way to center a box (for example, adjustbox) even if the documents margins are not equal (left and right)?



documentclass{article}
usepackage{adjustbox}
usepackage[pass]{geometry}
usepackage{lipsum}

begin{document}

begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}
begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

end{document}









share|improve this question




















  • 4




    Centred w.r.t. what? The sheet of paper width?
    – Bernard
    Jun 8 at 23:44










  • this should be relevant (and a possible duplicate): Center figure that is wider than textwidth
    – barbara beeton
    Jun 9 at 19:57










  • If the problem is the one @barbarabeeton suggests, I find lying is generally the most straightforward and most effective solution if the figure is too wide. (Height/depth is a bit different.)
    – cfr
    Jun 10 at 2:09
















2














Is there a way to center a box (for example, adjustbox) even if the documents margins are not equal (left and right)?



documentclass{article}
usepackage{adjustbox}
usepackage[pass]{geometry}
usepackage{lipsum}

begin{document}

begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}
begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

end{document}









share|improve this question




















  • 4




    Centred w.r.t. what? The sheet of paper width?
    – Bernard
    Jun 8 at 23:44










  • this should be relevant (and a possible duplicate): Center figure that is wider than textwidth
    – barbara beeton
    Jun 9 at 19:57










  • If the problem is the one @barbarabeeton suggests, I find lying is generally the most straightforward and most effective solution if the figure is too wide. (Height/depth is a bit different.)
    – cfr
    Jun 10 at 2:09














2












2








2


0





Is there a way to center a box (for example, adjustbox) even if the documents margins are not equal (left and right)?



documentclass{article}
usepackage{adjustbox}
usepackage[pass]{geometry}
usepackage{lipsum}

begin{document}

begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}
begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

end{document}









share|improve this question















Is there a way to center a box (for example, adjustbox) even if the documents margins are not equal (left and right)?



documentclass{article}
usepackage{adjustbox}
usepackage[pass]{geometry}
usepackage{lipsum}

begin{document}

begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}
begin{adjustbox}{minipage=0.99paperwidth,margin=0pt,center}
lipsum[2]
end{adjustbox}

end{document}






horizontal-alignment minipage geometry adjustbox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 15 mins ago









Martin Scharrer

198k45632813




198k45632813










asked Jun 8 at 23:34









Felix Dietrich

111




111








  • 4




    Centred w.r.t. what? The sheet of paper width?
    – Bernard
    Jun 8 at 23:44










  • this should be relevant (and a possible duplicate): Center figure that is wider than textwidth
    – barbara beeton
    Jun 9 at 19:57










  • If the problem is the one @barbarabeeton suggests, I find lying is generally the most straightforward and most effective solution if the figure is too wide. (Height/depth is a bit different.)
    – cfr
    Jun 10 at 2:09














  • 4




    Centred w.r.t. what? The sheet of paper width?
    – Bernard
    Jun 8 at 23:44










  • this should be relevant (and a possible duplicate): Center figure that is wider than textwidth
    – barbara beeton
    Jun 9 at 19:57










  • If the problem is the one @barbarabeeton suggests, I find lying is generally the most straightforward and most effective solution if the figure is too wide. (Height/depth is a bit different.)
    – cfr
    Jun 10 at 2:09








4




4




Centred w.r.t. what? The sheet of paper width?
– Bernard
Jun 8 at 23:44




Centred w.r.t. what? The sheet of paper width?
– Bernard
Jun 8 at 23:44












this should be relevant (and a possible duplicate): Center figure that is wider than textwidth
– barbara beeton
Jun 9 at 19:57




this should be relevant (and a possible duplicate): Center figure that is wider than textwidth
– barbara beeton
Jun 9 at 19:57












If the problem is the one @barbarabeeton suggests, I find lying is generally the most straightforward and most effective solution if the figure is too wide. (Height/depth is a bit different.)
– cfr
Jun 10 at 2:09




If the problem is the one @barbarabeeton suggests, I find lying is generally the most straightforward and most effective solution if the figure is too wide. (Height/depth is a bit different.)
– cfr
Jun 10 at 2:09










3 Answers
3






active

oldest

votes


















1














You can put it inside a tikz node with position (current page.center) as follows:



documentclass{article}
usepackage{adjustbox}
usepackage[pass]{geometry}
usepackage{lipsum}
usepackage{tikz}


begin{document}



begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
begin{tikzpicture}[overlay, remember picture]
node[text width=0.7*linewidth] at (current page.center)
{lipsum[2]};
end{tikzpicture}
end{adjustbox}


newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}


begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
begin{tikzpicture}[overlay, remember picture]
node[text width=0.7*linewidth] at (current page.center)
{lipsum[2]};
end{tikzpicture}
end{adjustbox}


end{document}





share|improve this answer































    0














    It is not clear exactly what you are centering on, but you can use the adjustwith command from the changepage package to temporarily adjust margins.



    The command takes two arguments for left and right margin respectively. The value is the amount by which the text block will be REDUCED (so negative values enlarge). The effect is on linewidth not textwidth.



    The below MWE and output together with some reading should explain.



    documentclass{article}
    usepackage[pass]{geometry}
    usepackage{changepage}

    begin{document}

    newgeometry{left=100pt,top=1cm,bottom=1cm,includefoot}

    begin{center}
    Center within margins
    end{center}
    Left
    flushright Right

    newgeometry{left=200pt,top=1cm,bottom=1cm,includefoot}

    begin{center}
    Center within margins
    end{center}
    begin{adjustwidth}{-100pt}{0pt}
    begin{center}
    Center on temporarily adjusted margin
    end{center}
    Left
    flushright Right
    end{adjustwidth}

    newgeometry{left=300pt,top=1cm,bottom=1cm,includefoot}

    begin{center}
    Center within margins
    end{center}
    begin{adjustwidth}{-200pt}{0pt}
    begin{center}
    Center on temporarily adjusted margin
    end{center}
    Text
    flushright Right
    end{adjustwidth}

    newgeometry{left=400pt,top=1cm,bottom=1cm,includefoot}

    begin{center}
    Center within margins
    end{center}
    begin{adjustwidth}{-300pt}{0pt}
    begin{center}
    Center on temporarily adjusted margin
    end{center}
    Text
    flushright Right
    end{adjustwidth}

    end{document}


    enter image description here



    It is possible to automate slightly but depends what you are centering on. Manual use may be easiest when you understand how it works. Obviously if you have different margins on odd and even pages that needs taking into account as well.






    share|improve this answer































      0














      If you want to center the box on the page, not the text area, one way to do this is to make it lap into the left text margin of the page. The required dimensions can be read using the layout package.



      The following code uses the ifoddpage package together with adjustbox to get the right amount.



      documentclass[twopages]{book}
      usepackage{ifoddpage}
      usepackage{adjustbox}
      usepackage[pass,showframe]{geometry}
      usepackage{layout}
      usepackage{lipsum}


      begin{document}
      lipsum[1]

      checkoddpage
      begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
      lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
      lipsum[2]
      end{adjustbox}

      lipsum

      checkoddpage
      begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
      lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
      lipsum[2]
      end{adjustbox}

      lipsum[1]

      clearpage
      layout


      end{document}


      enter image description here



      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%2f435633%2fcentering-a-box-independent-of-documents-margin%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        You can put it inside a tikz node with position (current page.center) as follows:



        documentclass{article}
        usepackage{adjustbox}
        usepackage[pass]{geometry}
        usepackage{lipsum}
        usepackage{tikz}


        begin{document}



        begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
        begin{tikzpicture}[overlay, remember picture]
        node[text width=0.7*linewidth] at (current page.center)
        {lipsum[2]};
        end{tikzpicture}
        end{adjustbox}


        newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}


        begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
        begin{tikzpicture}[overlay, remember picture]
        node[text width=0.7*linewidth] at (current page.center)
        {lipsum[2]};
        end{tikzpicture}
        end{adjustbox}


        end{document}





        share|improve this answer




























          1














          You can put it inside a tikz node with position (current page.center) as follows:



          documentclass{article}
          usepackage{adjustbox}
          usepackage[pass]{geometry}
          usepackage{lipsum}
          usepackage{tikz}


          begin{document}



          begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
          begin{tikzpicture}[overlay, remember picture]
          node[text width=0.7*linewidth] at (current page.center)
          {lipsum[2]};
          end{tikzpicture}
          end{adjustbox}


          newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}


          begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
          begin{tikzpicture}[overlay, remember picture]
          node[text width=0.7*linewidth] at (current page.center)
          {lipsum[2]};
          end{tikzpicture}
          end{adjustbox}


          end{document}





          share|improve this answer


























            1












            1








            1






            You can put it inside a tikz node with position (current page.center) as follows:



            documentclass{article}
            usepackage{adjustbox}
            usepackage[pass]{geometry}
            usepackage{lipsum}
            usepackage{tikz}


            begin{document}



            begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
            begin{tikzpicture}[overlay, remember picture]
            node[text width=0.7*linewidth] at (current page.center)
            {lipsum[2]};
            end{tikzpicture}
            end{adjustbox}


            newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}


            begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
            begin{tikzpicture}[overlay, remember picture]
            node[text width=0.7*linewidth] at (current page.center)
            {lipsum[2]};
            end{tikzpicture}
            end{adjustbox}


            end{document}





            share|improve this answer














            You can put it inside a tikz node with position (current page.center) as follows:



            documentclass{article}
            usepackage{adjustbox}
            usepackage[pass]{geometry}
            usepackage{lipsum}
            usepackage{tikz}


            begin{document}



            begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
            begin{tikzpicture}[overlay, remember picture]
            node[text width=0.7*linewidth] at (current page.center)
            {lipsum[2]};
            end{tikzpicture}
            end{adjustbox}


            newgeometry{left=250pt,top=1cm,bottom=1cm,includefoot}


            begin{adjustbox}{minipage=paperwidth,margin=0pt,center}
            begin{tikzpicture}[overlay, remember picture]
            node[text width=0.7*linewidth] at (current page.center)
            {lipsum[2]};
            end{tikzpicture}
            end{adjustbox}


            end{document}






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 9 at 8:03

























            answered Jun 9 at 2:13









            Mohamed Vall

            766516




            766516























                0














                It is not clear exactly what you are centering on, but you can use the adjustwith command from the changepage package to temporarily adjust margins.



                The command takes two arguments for left and right margin respectively. The value is the amount by which the text block will be REDUCED (so negative values enlarge). The effect is on linewidth not textwidth.



                The below MWE and output together with some reading should explain.



                documentclass{article}
                usepackage[pass]{geometry}
                usepackage{changepage}

                begin{document}

                newgeometry{left=100pt,top=1cm,bottom=1cm,includefoot}

                begin{center}
                Center within margins
                end{center}
                Left
                flushright Right

                newgeometry{left=200pt,top=1cm,bottom=1cm,includefoot}

                begin{center}
                Center within margins
                end{center}
                begin{adjustwidth}{-100pt}{0pt}
                begin{center}
                Center on temporarily adjusted margin
                end{center}
                Left
                flushright Right
                end{adjustwidth}

                newgeometry{left=300pt,top=1cm,bottom=1cm,includefoot}

                begin{center}
                Center within margins
                end{center}
                begin{adjustwidth}{-200pt}{0pt}
                begin{center}
                Center on temporarily adjusted margin
                end{center}
                Text
                flushright Right
                end{adjustwidth}

                newgeometry{left=400pt,top=1cm,bottom=1cm,includefoot}

                begin{center}
                Center within margins
                end{center}
                begin{adjustwidth}{-300pt}{0pt}
                begin{center}
                Center on temporarily adjusted margin
                end{center}
                Text
                flushright Right
                end{adjustwidth}

                end{document}


                enter image description here



                It is possible to automate slightly but depends what you are centering on. Manual use may be easiest when you understand how it works. Obviously if you have different margins on odd and even pages that needs taking into account as well.






                share|improve this answer




























                  0














                  It is not clear exactly what you are centering on, but you can use the adjustwith command from the changepage package to temporarily adjust margins.



                  The command takes two arguments for left and right margin respectively. The value is the amount by which the text block will be REDUCED (so negative values enlarge). The effect is on linewidth not textwidth.



                  The below MWE and output together with some reading should explain.



                  documentclass{article}
                  usepackage[pass]{geometry}
                  usepackage{changepage}

                  begin{document}

                  newgeometry{left=100pt,top=1cm,bottom=1cm,includefoot}

                  begin{center}
                  Center within margins
                  end{center}
                  Left
                  flushright Right

                  newgeometry{left=200pt,top=1cm,bottom=1cm,includefoot}

                  begin{center}
                  Center within margins
                  end{center}
                  begin{adjustwidth}{-100pt}{0pt}
                  begin{center}
                  Center on temporarily adjusted margin
                  end{center}
                  Left
                  flushright Right
                  end{adjustwidth}

                  newgeometry{left=300pt,top=1cm,bottom=1cm,includefoot}

                  begin{center}
                  Center within margins
                  end{center}
                  begin{adjustwidth}{-200pt}{0pt}
                  begin{center}
                  Center on temporarily adjusted margin
                  end{center}
                  Text
                  flushright Right
                  end{adjustwidth}

                  newgeometry{left=400pt,top=1cm,bottom=1cm,includefoot}

                  begin{center}
                  Center within margins
                  end{center}
                  begin{adjustwidth}{-300pt}{0pt}
                  begin{center}
                  Center on temporarily adjusted margin
                  end{center}
                  Text
                  flushright Right
                  end{adjustwidth}

                  end{document}


                  enter image description here



                  It is possible to automate slightly but depends what you are centering on. Manual use may be easiest when you understand how it works. Obviously if you have different margins on odd and even pages that needs taking into account as well.






                  share|improve this answer


























                    0












                    0








                    0






                    It is not clear exactly what you are centering on, but you can use the adjustwith command from the changepage package to temporarily adjust margins.



                    The command takes two arguments for left and right margin respectively. The value is the amount by which the text block will be REDUCED (so negative values enlarge). The effect is on linewidth not textwidth.



                    The below MWE and output together with some reading should explain.



                    documentclass{article}
                    usepackage[pass]{geometry}
                    usepackage{changepage}

                    begin{document}

                    newgeometry{left=100pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    Left
                    flushright Right

                    newgeometry{left=200pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    begin{adjustwidth}{-100pt}{0pt}
                    begin{center}
                    Center on temporarily adjusted margin
                    end{center}
                    Left
                    flushright Right
                    end{adjustwidth}

                    newgeometry{left=300pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    begin{adjustwidth}{-200pt}{0pt}
                    begin{center}
                    Center on temporarily adjusted margin
                    end{center}
                    Text
                    flushright Right
                    end{adjustwidth}

                    newgeometry{left=400pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    begin{adjustwidth}{-300pt}{0pt}
                    begin{center}
                    Center on temporarily adjusted margin
                    end{center}
                    Text
                    flushright Right
                    end{adjustwidth}

                    end{document}


                    enter image description here



                    It is possible to automate slightly but depends what you are centering on. Manual use may be easiest when you understand how it works. Obviously if you have different margins on odd and even pages that needs taking into account as well.






                    share|improve this answer














                    It is not clear exactly what you are centering on, but you can use the adjustwith command from the changepage package to temporarily adjust margins.



                    The command takes two arguments for left and right margin respectively. The value is the amount by which the text block will be REDUCED (so negative values enlarge). The effect is on linewidth not textwidth.



                    The below MWE and output together with some reading should explain.



                    documentclass{article}
                    usepackage[pass]{geometry}
                    usepackage{changepage}

                    begin{document}

                    newgeometry{left=100pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    Left
                    flushright Right

                    newgeometry{left=200pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    begin{adjustwidth}{-100pt}{0pt}
                    begin{center}
                    Center on temporarily adjusted margin
                    end{center}
                    Left
                    flushright Right
                    end{adjustwidth}

                    newgeometry{left=300pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    begin{adjustwidth}{-200pt}{0pt}
                    begin{center}
                    Center on temporarily adjusted margin
                    end{center}
                    Text
                    flushright Right
                    end{adjustwidth}

                    newgeometry{left=400pt,top=1cm,bottom=1cm,includefoot}

                    begin{center}
                    Center within margins
                    end{center}
                    begin{adjustwidth}{-300pt}{0pt}
                    begin{center}
                    Center on temporarily adjusted margin
                    end{center}
                    Text
                    flushright Right
                    end{adjustwidth}

                    end{document}


                    enter image description here



                    It is possible to automate slightly but depends what you are centering on. Manual use may be easiest when you understand how it works. Obviously if you have different margins on odd and even pages that needs taking into account as well.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jun 9 at 14:23

























                    answered Jun 9 at 13:29









                    Aubrey Blumsohn

                    2,5711019




                    2,5711019























                        0














                        If you want to center the box on the page, not the text area, one way to do this is to make it lap into the left text margin of the page. The required dimensions can be read using the layout package.



                        The following code uses the ifoddpage package together with adjustbox to get the right amount.



                        documentclass[twopages]{book}
                        usepackage{ifoddpage}
                        usepackage{adjustbox}
                        usepackage[pass,showframe]{geometry}
                        usepackage{layout}
                        usepackage{lipsum}


                        begin{document}
                        lipsum[1]

                        checkoddpage
                        begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                        lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                        lipsum[2]
                        end{adjustbox}

                        lipsum

                        checkoddpage
                        begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                        lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                        lipsum[2]
                        end{adjustbox}

                        lipsum[1]

                        clearpage
                        layout


                        end{document}


                        enter image description here



                        enter image description here






                        share|improve this answer


























                          0














                          If you want to center the box on the page, not the text area, one way to do this is to make it lap into the left text margin of the page. The required dimensions can be read using the layout package.



                          The following code uses the ifoddpage package together with adjustbox to get the right amount.



                          documentclass[twopages]{book}
                          usepackage{ifoddpage}
                          usepackage{adjustbox}
                          usepackage[pass,showframe]{geometry}
                          usepackage{layout}
                          usepackage{lipsum}


                          begin{document}
                          lipsum[1]

                          checkoddpage
                          begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                          lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                          lipsum[2]
                          end{adjustbox}

                          lipsum

                          checkoddpage
                          begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                          lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                          lipsum[2]
                          end{adjustbox}

                          lipsum[1]

                          clearpage
                          layout


                          end{document}


                          enter image description here



                          enter image description here






                          share|improve this answer
























                            0












                            0








                            0






                            If you want to center the box on the page, not the text area, one way to do this is to make it lap into the left text margin of the page. The required dimensions can be read using the layout package.



                            The following code uses the ifoddpage package together with adjustbox to get the right amount.



                            documentclass[twopages]{book}
                            usepackage{ifoddpage}
                            usepackage{adjustbox}
                            usepackage[pass,showframe]{geometry}
                            usepackage{layout}
                            usepackage{lipsum}


                            begin{document}
                            lipsum[1]

                            checkoddpage
                            begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                            lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                            lipsum[2]
                            end{adjustbox}

                            lipsum

                            checkoddpage
                            begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                            lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                            lipsum[2]
                            end{adjustbox}

                            lipsum[1]

                            clearpage
                            layout


                            end{document}


                            enter image description here



                            enter image description here






                            share|improve this answer












                            If you want to center the box on the page, not the text area, one way to do this is to make it lap into the left text margin of the page. The required dimensions can be read using the layout package.



                            The following code uses the ifoddpage package together with adjustbox to get the right amount.



                            documentclass[twopages]{book}
                            usepackage{ifoddpage}
                            usepackage{adjustbox}
                            usepackage[pass,showframe]{geometry}
                            usepackage{layout}
                            usepackage{lipsum}


                            begin{document}
                            lipsum[1]

                            checkoddpage
                            begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                            lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                            lipsum[2]
                            end{adjustbox}

                            lipsum

                            checkoddpage
                            begin{adjustbox}{minipage=0.95paperwidth,vspace=smallskipamount,frame,
                            lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5Width}}
                            lipsum[2]
                            end{adjustbox}

                            lipsum[1]

                            clearpage
                            layout


                            end{document}


                            enter image description here



                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 16 mins ago









                            Martin Scharrer

                            198k45632813




                            198k45632813






























                                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%2f435633%2fcentering-a-box-independent-of-documents-margin%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

                                Contact image not getting when fetch all contact list from iPhone by CNContact

                                count number of partitions of a set with n elements into k subsets

                                A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks