Drawing boxes in matrices

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












In my document I have defined



newcommandbigzeromakebox(0,0)texthuge0


and using this the following matrix:



beginequationbeginpmatrix
0&1\
1&0&&&&bigzero\
&&0&1\
&&1&0\
&&&&ddots\
&bigzero&&&&0&1\
&&&&&1&0
endpmatrixendequation


How can I draw boxes around the three blocks which build the matrix?










share|improve this question

























    up vote
    4
    down vote

    favorite












    In my document I have defined



    newcommandbigzeromakebox(0,0)texthuge0


    and using this the following matrix:



    beginequationbeginpmatrix
    0&1\
    1&0&&&&bigzero\
    &&0&1\
    &&1&0\
    &&&&ddots\
    &bigzero&&&&0&1\
    &&&&&1&0
    endpmatrixendequation


    How can I draw boxes around the three blocks which build the matrix?










    share|improve this question























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      In my document I have defined



      newcommandbigzeromakebox(0,0)texthuge0


      and using this the following matrix:



      beginequationbeginpmatrix
      0&1\
      1&0&&&&bigzero\
      &&0&1\
      &&1&0\
      &&&&ddots\
      &bigzero&&&&0&1\
      &&&&&1&0
      endpmatrixendequation


      How can I draw boxes around the three blocks which build the matrix?










      share|improve this question













      In my document I have defined



      newcommandbigzeromakebox(0,0)texthuge0


      and using this the following matrix:



      beginequationbeginpmatrix
      0&1\
      1&0&&&&bigzero\
      &&0&1\
      &&1&0\
      &&&&ddots\
      &bigzero&&&&0&1\
      &&&&&1&0
      endpmatrixendequation


      How can I draw boxes around the three blocks which build the matrix?







      math-mode matrices






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 9 at 20:30







      user114179



























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          A solution with basic tools:



          documentclassarticle

          usepackageamsmath
          usepackagehhline
          newcommandbigzeromakebox(0,0)texthuge0
          newcommandfblock[1]beginarray@:cc@:
          hhline#1 \
          hhline
          endarray

          begindocument

          beginequation
          beginpmatrix
          ,fblock0&1\ 1&0 &&\
          &mkern-9mufblock0&1\ 1&0&multicolumn2craisebox3exbigzero \
          &&makebox[0pt]$ ddots $\[-0.5ex]
          multicolumn2craisebox4exbigzero &&fblock0&1\ 1&0,
          endpmatrixendequation

          enddocument


          enter image description here






          share|improve this answer



























            up vote
            6
            down vote













            This is only a fun answer. I am trying out LoopSpace's great update of the tikzmark package, which has now a command in that I was always looking for: tikzmarknode. And it just works. (Yes, using tikz here may be an overkill, as I said, this is just for fun and to learn something new.) EDIT: Moved the brackets away from the boxes, big thanks to @manooooh!



            documentclassarticle
            usepackageamsmath,tikz
            usetikzlibrarytikzmark,fit
            newcommandbigzeromakebox(0,0)texthuge0
            begindocument
            beginequation
            left(~beginmatrix
            tikzmarknode1A0&1\
            1&tikzmarknode1B0&&&&bigzero\
            &&tikzmarknode2A0&1\
            &&1&tikzmarknode2B0\
            &&&&ddots\
            &bigzero&&&&tikzmarknode3A0&1\
            &&&&&1&tikzmarknode3B0
            endmatrix~right)
            begintikzpicture[overlay, remember picture]
            foreach X in 1,2,3
            node[inner sep=1pt,draw,fit=(X A)(X B)];
            endtikzpicture
            endequation
            enddocument


            enter image description here






            share|improve this answer






















            • +1, but I think the boxes are too stick to the braces of the matrix. Maybe using someting like left(;beginmatrix...endmatrix;right) would be ok?
              – manooooh
              Sep 9 at 20:54







            • 1




              @manooooh You are absolutely right. Yet this is really just for fun and to pay tribute to LoopSpace's updated package. In this case, you can easily produce a very simple fbox only solution by placing the 2x2 matrices in fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-)
              – marmot
              Sep 9 at 20:58






            • 1




              @manooooh No, I am now on a promotion tour. Undoubtedly someone else will come and say this is a sledge hammer and it is possible to achieve the same with fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-)
              – marmot
              Sep 9 at 21:08






            • 1




              Very nice, but why is the bottom zero of the middle box misaligned?
              – Max
              2 days ago






            • 2




              The misalignment is actually from the previous line where you have ~~ after the 1 which adds a bit of space after the 1, thus seeming to push the 0 further out due to the centring of the matrix entries.
              – Loop Space
              yesterday










            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f450167%2fdrawing-boxes-in-matrices%23new-answer', 'question_page');

            );

            Post as a guest





























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            A solution with basic tools:



            documentclassarticle

            usepackageamsmath
            usepackagehhline
            newcommandbigzeromakebox(0,0)texthuge0
            newcommandfblock[1]beginarray@:cc@:
            hhline#1 \
            hhline
            endarray

            begindocument

            beginequation
            beginpmatrix
            ,fblock0&1\ 1&0 &&\
            &mkern-9mufblock0&1\ 1&0&multicolumn2craisebox3exbigzero \
            &&makebox[0pt]$ ddots $\[-0.5ex]
            multicolumn2craisebox4exbigzero &&fblock0&1\ 1&0,
            endpmatrixendequation

            enddocument


            enter image description here






            share|improve this answer
























              up vote
              3
              down vote



              accepted










              A solution with basic tools:



              documentclassarticle

              usepackageamsmath
              usepackagehhline
              newcommandbigzeromakebox(0,0)texthuge0
              newcommandfblock[1]beginarray@:cc@:
              hhline#1 \
              hhline
              endarray

              begindocument

              beginequation
              beginpmatrix
              ,fblock0&1\ 1&0 &&\
              &mkern-9mufblock0&1\ 1&0&multicolumn2craisebox3exbigzero \
              &&makebox[0pt]$ ddots $\[-0.5ex]
              multicolumn2craisebox4exbigzero &&fblock0&1\ 1&0,
              endpmatrixendequation

              enddocument


              enter image description here






              share|improve this answer






















                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                A solution with basic tools:



                documentclassarticle

                usepackageamsmath
                usepackagehhline
                newcommandbigzeromakebox(0,0)texthuge0
                newcommandfblock[1]beginarray@:cc@:
                hhline#1 \
                hhline
                endarray

                begindocument

                beginequation
                beginpmatrix
                ,fblock0&1\ 1&0 &&\
                &mkern-9mufblock0&1\ 1&0&multicolumn2craisebox3exbigzero \
                &&makebox[0pt]$ ddots $\[-0.5ex]
                multicolumn2craisebox4exbigzero &&fblock0&1\ 1&0,
                endpmatrixendequation

                enddocument


                enter image description here






                share|improve this answer












                A solution with basic tools:



                documentclassarticle

                usepackageamsmath
                usepackagehhline
                newcommandbigzeromakebox(0,0)texthuge0
                newcommandfblock[1]beginarray@:cc@:
                hhline#1 \
                hhline
                endarray

                begindocument

                beginequation
                beginpmatrix
                ,fblock0&1\ 1&0 &&\
                &mkern-9mufblock0&1\ 1&0&multicolumn2craisebox3exbigzero \
                &&makebox[0pt]$ ddots $\[-0.5ex]
                multicolumn2craisebox4exbigzero &&fblock0&1\ 1&0,
                endpmatrixendequation

                enddocument


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 9 at 21:33









                Bernard

                156k763189




                156k763189




















                    up vote
                    6
                    down vote













                    This is only a fun answer. I am trying out LoopSpace's great update of the tikzmark package, which has now a command in that I was always looking for: tikzmarknode. And it just works. (Yes, using tikz here may be an overkill, as I said, this is just for fun and to learn something new.) EDIT: Moved the brackets away from the boxes, big thanks to @manooooh!



                    documentclassarticle
                    usepackageamsmath,tikz
                    usetikzlibrarytikzmark,fit
                    newcommandbigzeromakebox(0,0)texthuge0
                    begindocument
                    beginequation
                    left(~beginmatrix
                    tikzmarknode1A0&1\
                    1&tikzmarknode1B0&&&&bigzero\
                    &&tikzmarknode2A0&1\
                    &&1&tikzmarknode2B0\
                    &&&&ddots\
                    &bigzero&&&&tikzmarknode3A0&1\
                    &&&&&1&tikzmarknode3B0
                    endmatrix~right)
                    begintikzpicture[overlay, remember picture]
                    foreach X in 1,2,3
                    node[inner sep=1pt,draw,fit=(X A)(X B)];
                    endtikzpicture
                    endequation
                    enddocument


                    enter image description here






                    share|improve this answer






















                    • +1, but I think the boxes are too stick to the braces of the matrix. Maybe using someting like left(;beginmatrix...endmatrix;right) would be ok?
                      – manooooh
                      Sep 9 at 20:54







                    • 1




                      @manooooh You are absolutely right. Yet this is really just for fun and to pay tribute to LoopSpace's updated package. In this case, you can easily produce a very simple fbox only solution by placing the 2x2 matrices in fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-)
                      – marmot
                      Sep 9 at 20:58






                    • 1




                      @manooooh No, I am now on a promotion tour. Undoubtedly someone else will come and say this is a sledge hammer and it is possible to achieve the same with fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-)
                      – marmot
                      Sep 9 at 21:08






                    • 1




                      Very nice, but why is the bottom zero of the middle box misaligned?
                      – Max
                      2 days ago






                    • 2




                      The misalignment is actually from the previous line where you have ~~ after the 1 which adds a bit of space after the 1, thus seeming to push the 0 further out due to the centring of the matrix entries.
                      – Loop Space
                      yesterday














                    up vote
                    6
                    down vote













                    This is only a fun answer. I am trying out LoopSpace's great update of the tikzmark package, which has now a command in that I was always looking for: tikzmarknode. And it just works. (Yes, using tikz here may be an overkill, as I said, this is just for fun and to learn something new.) EDIT: Moved the brackets away from the boxes, big thanks to @manooooh!



                    documentclassarticle
                    usepackageamsmath,tikz
                    usetikzlibrarytikzmark,fit
                    newcommandbigzeromakebox(0,0)texthuge0
                    begindocument
                    beginequation
                    left(~beginmatrix
                    tikzmarknode1A0&1\
                    1&tikzmarknode1B0&&&&bigzero\
                    &&tikzmarknode2A0&1\
                    &&1&tikzmarknode2B0\
                    &&&&ddots\
                    &bigzero&&&&tikzmarknode3A0&1\
                    &&&&&1&tikzmarknode3B0
                    endmatrix~right)
                    begintikzpicture[overlay, remember picture]
                    foreach X in 1,2,3
                    node[inner sep=1pt,draw,fit=(X A)(X B)];
                    endtikzpicture
                    endequation
                    enddocument


                    enter image description here






                    share|improve this answer






















                    • +1, but I think the boxes are too stick to the braces of the matrix. Maybe using someting like left(;beginmatrix...endmatrix;right) would be ok?
                      – manooooh
                      Sep 9 at 20:54







                    • 1




                      @manooooh You are absolutely right. Yet this is really just for fun and to pay tribute to LoopSpace's updated package. In this case, you can easily produce a very simple fbox only solution by placing the 2x2 matrices in fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-)
                      – marmot
                      Sep 9 at 20:58






                    • 1




                      @manooooh No, I am now on a promotion tour. Undoubtedly someone else will come and say this is a sledge hammer and it is possible to achieve the same with fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-)
                      – marmot
                      Sep 9 at 21:08






                    • 1




                      Very nice, but why is the bottom zero of the middle box misaligned?
                      – Max
                      2 days ago






                    • 2




                      The misalignment is actually from the previous line where you have ~~ after the 1 which adds a bit of space after the 1, thus seeming to push the 0 further out due to the centring of the matrix entries.
                      – Loop Space
                      yesterday












                    up vote
                    6
                    down vote










                    up vote
                    6
                    down vote









                    This is only a fun answer. I am trying out LoopSpace's great update of the tikzmark package, which has now a command in that I was always looking for: tikzmarknode. And it just works. (Yes, using tikz here may be an overkill, as I said, this is just for fun and to learn something new.) EDIT: Moved the brackets away from the boxes, big thanks to @manooooh!



                    documentclassarticle
                    usepackageamsmath,tikz
                    usetikzlibrarytikzmark,fit
                    newcommandbigzeromakebox(0,0)texthuge0
                    begindocument
                    beginequation
                    left(~beginmatrix
                    tikzmarknode1A0&1\
                    1&tikzmarknode1B0&&&&bigzero\
                    &&tikzmarknode2A0&1\
                    &&1&tikzmarknode2B0\
                    &&&&ddots\
                    &bigzero&&&&tikzmarknode3A0&1\
                    &&&&&1&tikzmarknode3B0
                    endmatrix~right)
                    begintikzpicture[overlay, remember picture]
                    foreach X in 1,2,3
                    node[inner sep=1pt,draw,fit=(X A)(X B)];
                    endtikzpicture
                    endequation
                    enddocument


                    enter image description here






                    share|improve this answer














                    This is only a fun answer. I am trying out LoopSpace's great update of the tikzmark package, which has now a command in that I was always looking for: tikzmarknode. And it just works. (Yes, using tikz here may be an overkill, as I said, this is just for fun and to learn something new.) EDIT: Moved the brackets away from the boxes, big thanks to @manooooh!



                    documentclassarticle
                    usepackageamsmath,tikz
                    usetikzlibrarytikzmark,fit
                    newcommandbigzeromakebox(0,0)texthuge0
                    begindocument
                    beginequation
                    left(~beginmatrix
                    tikzmarknode1A0&1\
                    1&tikzmarknode1B0&&&&bigzero\
                    &&tikzmarknode2A0&1\
                    &&1&tikzmarknode2B0\
                    &&&&ddots\
                    &bigzero&&&&tikzmarknode3A0&1\
                    &&&&&1&tikzmarknode3B0
                    endmatrix~right)
                    begintikzpicture[overlay, remember picture]
                    foreach X in 1,2,3
                    node[inner sep=1pt,draw,fit=(X A)(X B)];
                    endtikzpicture
                    endequation
                    enddocument


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited yesterday

























                    answered Sep 9 at 20:51









                    marmot

                    56.8k462124




                    56.8k462124











                    • +1, but I think the boxes are too stick to the braces of the matrix. Maybe using someting like left(;beginmatrix...endmatrix;right) would be ok?
                      – manooooh
                      Sep 9 at 20:54







                    • 1




                      @manooooh You are absolutely right. Yet this is really just for fun and to pay tribute to LoopSpace's updated package. In this case, you can easily produce a very simple fbox only solution by placing the 2x2 matrices in fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-)
                      – marmot
                      Sep 9 at 20:58






                    • 1




                      @manooooh No, I am now on a promotion tour. Undoubtedly someone else will come and say this is a sledge hammer and it is possible to achieve the same with fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-)
                      – marmot
                      Sep 9 at 21:08






                    • 1




                      Very nice, but why is the bottom zero of the middle box misaligned?
                      – Max
                      2 days ago






                    • 2




                      The misalignment is actually from the previous line where you have ~~ after the 1 which adds a bit of space after the 1, thus seeming to push the 0 further out due to the centring of the matrix entries.
                      – Loop Space
                      yesterday
















                    • +1, but I think the boxes are too stick to the braces of the matrix. Maybe using someting like left(;beginmatrix...endmatrix;right) would be ok?
                      – manooooh
                      Sep 9 at 20:54







                    • 1




                      @manooooh You are absolutely right. Yet this is really just for fun and to pay tribute to LoopSpace's updated package. In this case, you can easily produce a very simple fbox only solution by placing the 2x2 matrices in fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-)
                      – marmot
                      Sep 9 at 20:58






                    • 1




                      @manooooh No, I am now on a promotion tour. Undoubtedly someone else will come and say this is a sledge hammer and it is possible to achieve the same with fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-)
                      – marmot
                      Sep 9 at 21:08






                    • 1




                      Very nice, but why is the bottom zero of the middle box misaligned?
                      – Max
                      2 days ago






                    • 2




                      The misalignment is actually from the previous line where you have ~~ after the 1 which adds a bit of space after the 1, thus seeming to push the 0 further out due to the centring of the matrix entries.
                      – Loop Space
                      yesterday















                    +1, but I think the boxes are too stick to the braces of the matrix. Maybe using someting like left(;beginmatrix...endmatrix;right) would be ok?
                    – manooooh
                    Sep 9 at 20:54





                    +1, but I think the boxes are too stick to the braces of the matrix. Maybe using someting like left(;beginmatrix...endmatrix;right) would be ok?
                    – manooooh
                    Sep 9 at 20:54





                    1




                    1




                    @manooooh You are absolutely right. Yet this is really just for fun and to pay tribute to LoopSpace's updated package. In this case, you can easily produce a very simple fbox only solution by placing the 2x2 matrices in fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-)
                    – marmot
                    Sep 9 at 20:58




                    @manooooh You are absolutely right. Yet this is really just for fun and to pay tribute to LoopSpace's updated package. In this case, you can easily produce a very simple fbox only solution by placing the 2x2 matrices in fboxes. I was actually not expecting to get any votes for that, just wanted to draw the attention to the updated library such that LoopSpace and I have company when testing it. ;-)
                    – marmot
                    Sep 9 at 20:58




                    1




                    1




                    @manooooh No, I am now on a promotion tour. Undoubtedly someone else will come and say this is a sledge hammer and it is possible to achieve the same with fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-)
                    – marmot
                    Sep 9 at 21:08




                    @manooooh No, I am now on a promotion tour. Undoubtedly someone else will come and say this is a sledge hammer and it is possible to achieve the same with fboxes (which is true in this case, but not when the boxes should become a tiny bit more fancy). ;-)
                    – marmot
                    Sep 9 at 21:08




                    1




                    1




                    Very nice, but why is the bottom zero of the middle box misaligned?
                    – Max
                    2 days ago




                    Very nice, but why is the bottom zero of the middle box misaligned?
                    – Max
                    2 days ago




                    2




                    2




                    The misalignment is actually from the previous line where you have ~~ after the 1 which adds a bit of space after the 1, thus seeming to push the 0 further out due to the centring of the matrix entries.
                    – Loop Space
                    yesterday




                    The misalignment is actually from the previous line where you have ~~ after the 1 which adds a bit of space after the 1, thus seeming to push the 0 further out due to the centring of the matrix entries.
                    – Loop Space
                    yesterday

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f450167%2fdrawing-boxes-in-matrices%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    One-line joke