TikZ: Align array of matrices

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












4















The following code:



documentclass[tikz,border=1mm]standalone

usepackagetikz
usetikzlibrarymatrix, positioning

tikzset
matrixstyle/.style=
matrix of nodes,
nodes=
draw



begindocument
begintikzpicture

matrix (M) [matrixstyle]
.1 & .1 \
.1 & .1 \
;

beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]
matrix (M11) [matrixstyle]
.1 & .0 \
.5 & .0 \
;
matrix (M12) [matrixstyle, right = 0cm of M11]
.2 & .0 \
.3 & .9 \
;
matrix (M21) [matrixstyle, below = 0cm of M11]
.0 & .0 \
.0 & .2 \
;
matrix (M22) [matrixstyle, right = 0cm of M21]
.3 & .0 \
.3 & .9 \
;
endscope

matrix (N) [matrixstyle, left = 1cm of MA.west]
.2 & .2 \
.2 & .2 \
;

endtikzpicture
enddocument


produces the following output:



enter image description here



The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line



beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]



What is the right way to do it? Why does my approach not work?










share|improve this question




























    4















    The following code:



    documentclass[tikz,border=1mm]standalone

    usepackagetikz
    usetikzlibrarymatrix, positioning

    tikzset
    matrixstyle/.style=
    matrix of nodes,
    nodes=
    draw



    begindocument
    begintikzpicture

    matrix (M) [matrixstyle]
    .1 & .1 \
    .1 & .1 \
    ;

    beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]
    matrix (M11) [matrixstyle]
    .1 & .0 \
    .5 & .0 \
    ;
    matrix (M12) [matrixstyle, right = 0cm of M11]
    .2 & .0 \
    .3 & .9 \
    ;
    matrix (M21) [matrixstyle, below = 0cm of M11]
    .0 & .0 \
    .0 & .2 \
    ;
    matrix (M22) [matrixstyle, right = 0cm of M21]
    .3 & .0 \
    .3 & .9 \
    ;
    endscope

    matrix (N) [matrixstyle, left = 1cm of MA.west]
    .2 & .2 \
    .2 & .2 \
    ;

    endtikzpicture
    enddocument


    produces the following output:



    enter image description here



    The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line



    beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]



    What is the right way to do it? Why does my approach not work?










    share|improve this question


























      4












      4








      4


      1






      The following code:



      documentclass[tikz,border=1mm]standalone

      usepackagetikz
      usetikzlibrarymatrix, positioning

      tikzset
      matrixstyle/.style=
      matrix of nodes,
      nodes=
      draw



      begindocument
      begintikzpicture

      matrix (M) [matrixstyle]
      .1 & .1 \
      .1 & .1 \
      ;

      beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]
      matrix (M11) [matrixstyle]
      .1 & .0 \
      .5 & .0 \
      ;
      matrix (M12) [matrixstyle, right = 0cm of M11]
      .2 & .0 \
      .3 & .9 \
      ;
      matrix (M21) [matrixstyle, below = 0cm of M11]
      .0 & .0 \
      .0 & .2 \
      ;
      matrix (M22) [matrixstyle, right = 0cm of M21]
      .3 & .0 \
      .3 & .9 \
      ;
      endscope

      matrix (N) [matrixstyle, left = 1cm of MA.west]
      .2 & .2 \
      .2 & .2 \
      ;

      endtikzpicture
      enddocument


      produces the following output:



      enter image description here



      The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line



      beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]



      What is the right way to do it? Why does my approach not work?










      share|improve this question
















      The following code:



      documentclass[tikz,border=1mm]standalone

      usepackagetikz
      usetikzlibrarymatrix, positioning

      tikzset
      matrixstyle/.style=
      matrix of nodes,
      nodes=
      draw



      begindocument
      begintikzpicture

      matrix (M) [matrixstyle]
      .1 & .1 \
      .1 & .1 \
      ;

      beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]
      matrix (M11) [matrixstyle]
      .1 & .0 \
      .5 & .0 \
      ;
      matrix (M12) [matrixstyle, right = 0cm of M11]
      .2 & .0 \
      .3 & .9 \
      ;
      matrix (M21) [matrixstyle, below = 0cm of M11]
      .0 & .0 \
      .0 & .2 \
      ;
      matrix (M22) [matrixstyle, right = 0cm of M21]
      .3 & .0 \
      .3 & .9 \
      ;
      endscope

      matrix (N) [matrixstyle, left = 1cm of MA.west]
      .2 & .2 \
      .2 & .2 \
      ;

      endtikzpicture
      enddocument


      produces the following output:



      enter image description here



      The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line



      beginscope [local bounding box=MA, shift=(M.west), left = 0cm of M.west]



      What is the right way to do it? Why does my approach not work?







      tikz-pgf






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 11 at 18:35









      Bernard

      168k771195




      168k771195










      asked Jan 11 at 18:27









      SamuelSamuel

      537211




      537211




















          2 Answers
          2






          active

          oldest

          votes


















          5














          like this?



          enter image description here



          matrices you can consider as nodes, so their positioning is with positioning library is straightforward:



          documentclass[tikz,border=1mm]standalone
          usetikzlibrarymatrix, positioning

          begindocument
          begintikzpicture[
          node distance = 1mm and 2mm,
          every matrix/.style = matrix of nodes,
          nodes=draw,
          column sep=-pgflinewidth,
          row sep=-pgflinewidth
          ]
          matrix (m1)

          .2 & .2 \
          .2 & .2 \
          ;
          matrix (m11) [above right=of m1.east]

          .1 & .0 \
          .5 & .0 \
          ;
          matrix (m12) [right=of m11]

          .1 & .1 \
          .1 & .1 \
          ;
          matrix (m21) [below right= of m1.east]

          .0 & .0 \
          .0 & .2 \
          ;
          matrix (m22) [right = of m21]
          .3 & .0 \
          .3 & .9 \
          ;

          matrix (m2) [right = of m1 -| m12.east]

          .2 & .0 \
          .3 & .9 \
          ;
          endtikzpicture
          enddocument





          share|improve this answer

























          • What does right = of m1 -| m12.east mean? Especially the -| part.

            – Samuel
            Jan 12 at 16:21











          • Is it possible to define the four matrices in the middle as a single object that can be moved and resized? I want to resize the four matrices in the middle to have the same size as the matrices on the left and on the right.

            – Samuel
            Jan 12 at 16:27











          • @Samuel, this is new question in which you need to show (by sketch), how you like scale and shift a group of matrices. probably solution require a different solution as is shown in both answers. i think, that both answers perfectly solve the problem described in this question, therefore it is time, that you accept one of them.

            – Zarko
            Jan 13 at 0:21



















          6














          Although not exactly the same, something very similar can be done with some tabular and without TiKZ.



          documentclassarticle

          newcommandmytab[4]%
          begintabular[c]c
          hline
          #1&#2\hline
          #3&#4\hline
          endtabular

          begindocument

          mytab.2.2.2.2
          begintabular[c]cccc
          mytab.1.0.5.2 & mytab.1.1.1.1
          \[.5cm]
          mytab.0.0.0.2 & mytab.3.0.3.9
          endtabular
          mytab.2.0.3.9
          enddocument


          enter image description here



          EDIT: or even better with ytableau package



          documentclassarticle
          usepackageytableau

          newcommandmytab[4]%
          beginytableau
          #1&#2\
          #3&#4\
          endytableau

          begindocument
          ytableausetupcentertableaux

          mytab.2.2.2.2
          begintabular[c]cccc
          mytab.1.0.5.2 & mytab.1.1.1.1
          \[.5cm]
          mytab.0.0.0.2 & mytab.3.0.3.9
          endtabular
          mytab.2.0.3.9
          enddocument


          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%2f469745%2ftikz-align-array-of-matrices%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









            5














            like this?



            enter image description here



            matrices you can consider as nodes, so their positioning is with positioning library is straightforward:



            documentclass[tikz,border=1mm]standalone
            usetikzlibrarymatrix, positioning

            begindocument
            begintikzpicture[
            node distance = 1mm and 2mm,
            every matrix/.style = matrix of nodes,
            nodes=draw,
            column sep=-pgflinewidth,
            row sep=-pgflinewidth
            ]
            matrix (m1)

            .2 & .2 \
            .2 & .2 \
            ;
            matrix (m11) [above right=of m1.east]

            .1 & .0 \
            .5 & .0 \
            ;
            matrix (m12) [right=of m11]

            .1 & .1 \
            .1 & .1 \
            ;
            matrix (m21) [below right= of m1.east]

            .0 & .0 \
            .0 & .2 \
            ;
            matrix (m22) [right = of m21]
            .3 & .0 \
            .3 & .9 \
            ;

            matrix (m2) [right = of m1 -| m12.east]

            .2 & .0 \
            .3 & .9 \
            ;
            endtikzpicture
            enddocument





            share|improve this answer

























            • What does right = of m1 -| m12.east mean? Especially the -| part.

              – Samuel
              Jan 12 at 16:21











            • Is it possible to define the four matrices in the middle as a single object that can be moved and resized? I want to resize the four matrices in the middle to have the same size as the matrices on the left and on the right.

              – Samuel
              Jan 12 at 16:27











            • @Samuel, this is new question in which you need to show (by sketch), how you like scale and shift a group of matrices. probably solution require a different solution as is shown in both answers. i think, that both answers perfectly solve the problem described in this question, therefore it is time, that you accept one of them.

              – Zarko
              Jan 13 at 0:21
















            5














            like this?



            enter image description here



            matrices you can consider as nodes, so their positioning is with positioning library is straightforward:



            documentclass[tikz,border=1mm]standalone
            usetikzlibrarymatrix, positioning

            begindocument
            begintikzpicture[
            node distance = 1mm and 2mm,
            every matrix/.style = matrix of nodes,
            nodes=draw,
            column sep=-pgflinewidth,
            row sep=-pgflinewidth
            ]
            matrix (m1)

            .2 & .2 \
            .2 & .2 \
            ;
            matrix (m11) [above right=of m1.east]

            .1 & .0 \
            .5 & .0 \
            ;
            matrix (m12) [right=of m11]

            .1 & .1 \
            .1 & .1 \
            ;
            matrix (m21) [below right= of m1.east]

            .0 & .0 \
            .0 & .2 \
            ;
            matrix (m22) [right = of m21]
            .3 & .0 \
            .3 & .9 \
            ;

            matrix (m2) [right = of m1 -| m12.east]

            .2 & .0 \
            .3 & .9 \
            ;
            endtikzpicture
            enddocument





            share|improve this answer

























            • What does right = of m1 -| m12.east mean? Especially the -| part.

              – Samuel
              Jan 12 at 16:21











            • Is it possible to define the four matrices in the middle as a single object that can be moved and resized? I want to resize the four matrices in the middle to have the same size as the matrices on the left and on the right.

              – Samuel
              Jan 12 at 16:27











            • @Samuel, this is new question in which you need to show (by sketch), how you like scale and shift a group of matrices. probably solution require a different solution as is shown in both answers. i think, that both answers perfectly solve the problem described in this question, therefore it is time, that you accept one of them.

              – Zarko
              Jan 13 at 0:21














            5












            5








            5







            like this?



            enter image description here



            matrices you can consider as nodes, so their positioning is with positioning library is straightforward:



            documentclass[tikz,border=1mm]standalone
            usetikzlibrarymatrix, positioning

            begindocument
            begintikzpicture[
            node distance = 1mm and 2mm,
            every matrix/.style = matrix of nodes,
            nodes=draw,
            column sep=-pgflinewidth,
            row sep=-pgflinewidth
            ]
            matrix (m1)

            .2 & .2 \
            .2 & .2 \
            ;
            matrix (m11) [above right=of m1.east]

            .1 & .0 \
            .5 & .0 \
            ;
            matrix (m12) [right=of m11]

            .1 & .1 \
            .1 & .1 \
            ;
            matrix (m21) [below right= of m1.east]

            .0 & .0 \
            .0 & .2 \
            ;
            matrix (m22) [right = of m21]
            .3 & .0 \
            .3 & .9 \
            ;

            matrix (m2) [right = of m1 -| m12.east]

            .2 & .0 \
            .3 & .9 \
            ;
            endtikzpicture
            enddocument





            share|improve this answer















            like this?



            enter image description here



            matrices you can consider as nodes, so their positioning is with positioning library is straightforward:



            documentclass[tikz,border=1mm]standalone
            usetikzlibrarymatrix, positioning

            begindocument
            begintikzpicture[
            node distance = 1mm and 2mm,
            every matrix/.style = matrix of nodes,
            nodes=draw,
            column sep=-pgflinewidth,
            row sep=-pgflinewidth
            ]
            matrix (m1)

            .2 & .2 \
            .2 & .2 \
            ;
            matrix (m11) [above right=of m1.east]

            .1 & .0 \
            .5 & .0 \
            ;
            matrix (m12) [right=of m11]

            .1 & .1 \
            .1 & .1 \
            ;
            matrix (m21) [below right= of m1.east]

            .0 & .0 \
            .0 & .2 \
            ;
            matrix (m22) [right = of m21]
            .3 & .0 \
            .3 & .9 \
            ;

            matrix (m2) [right = of m1 -| m12.east]

            .2 & .0 \
            .3 & .9 \
            ;
            endtikzpicture
            enddocument






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 11 at 19:00

























            answered Jan 11 at 18:43









            ZarkoZarko

            123k865161




            123k865161












            • What does right = of m1 -| m12.east mean? Especially the -| part.

              – Samuel
              Jan 12 at 16:21











            • Is it possible to define the four matrices in the middle as a single object that can be moved and resized? I want to resize the four matrices in the middle to have the same size as the matrices on the left and on the right.

              – Samuel
              Jan 12 at 16:27











            • @Samuel, this is new question in which you need to show (by sketch), how you like scale and shift a group of matrices. probably solution require a different solution as is shown in both answers. i think, that both answers perfectly solve the problem described in this question, therefore it is time, that you accept one of them.

              – Zarko
              Jan 13 at 0:21


















            • What does right = of m1 -| m12.east mean? Especially the -| part.

              – Samuel
              Jan 12 at 16:21











            • Is it possible to define the four matrices in the middle as a single object that can be moved and resized? I want to resize the four matrices in the middle to have the same size as the matrices on the left and on the right.

              – Samuel
              Jan 12 at 16:27











            • @Samuel, this is new question in which you need to show (by sketch), how you like scale and shift a group of matrices. probably solution require a different solution as is shown in both answers. i think, that both answers perfectly solve the problem described in this question, therefore it is time, that you accept one of them.

              – Zarko
              Jan 13 at 0:21

















            What does right = of m1 -| m12.east mean? Especially the -| part.

            – Samuel
            Jan 12 at 16:21





            What does right = of m1 -| m12.east mean? Especially the -| part.

            – Samuel
            Jan 12 at 16:21













            Is it possible to define the four matrices in the middle as a single object that can be moved and resized? I want to resize the four matrices in the middle to have the same size as the matrices on the left and on the right.

            – Samuel
            Jan 12 at 16:27





            Is it possible to define the four matrices in the middle as a single object that can be moved and resized? I want to resize the four matrices in the middle to have the same size as the matrices on the left and on the right.

            – Samuel
            Jan 12 at 16:27













            @Samuel, this is new question in which you need to show (by sketch), how you like scale and shift a group of matrices. probably solution require a different solution as is shown in both answers. i think, that both answers perfectly solve the problem described in this question, therefore it is time, that you accept one of them.

            – Zarko
            Jan 13 at 0:21






            @Samuel, this is new question in which you need to show (by sketch), how you like scale and shift a group of matrices. probably solution require a different solution as is shown in both answers. i think, that both answers perfectly solve the problem described in this question, therefore it is time, that you accept one of them.

            – Zarko
            Jan 13 at 0:21












            6














            Although not exactly the same, something very similar can be done with some tabular and without TiKZ.



            documentclassarticle

            newcommandmytab[4]%
            begintabular[c]c
            hline
            #1&#2\hline
            #3&#4\hline
            endtabular

            begindocument

            mytab.2.2.2.2
            begintabular[c]cccc
            mytab.1.0.5.2 & mytab.1.1.1.1
            \[.5cm]
            mytab.0.0.0.2 & mytab.3.0.3.9
            endtabular
            mytab.2.0.3.9
            enddocument


            enter image description here



            EDIT: or even better with ytableau package



            documentclassarticle
            usepackageytableau

            newcommandmytab[4]%
            beginytableau
            #1&#2\
            #3&#4\
            endytableau

            begindocument
            ytableausetupcentertableaux

            mytab.2.2.2.2
            begintabular[c]cccc
            mytab.1.0.5.2 & mytab.1.1.1.1
            \[.5cm]
            mytab.0.0.0.2 & mytab.3.0.3.9
            endtabular
            mytab.2.0.3.9
            enddocument


            enter image description here






            share|improve this answer





























              6














              Although not exactly the same, something very similar can be done with some tabular and without TiKZ.



              documentclassarticle

              newcommandmytab[4]%
              begintabular[c]c
              hline
              #1&#2\hline
              #3&#4\hline
              endtabular

              begindocument

              mytab.2.2.2.2
              begintabular[c]cccc
              mytab.1.0.5.2 & mytab.1.1.1.1
              \[.5cm]
              mytab.0.0.0.2 & mytab.3.0.3.9
              endtabular
              mytab.2.0.3.9
              enddocument


              enter image description here



              EDIT: or even better with ytableau package



              documentclassarticle
              usepackageytableau

              newcommandmytab[4]%
              beginytableau
              #1&#2\
              #3&#4\
              endytableau

              begindocument
              ytableausetupcentertableaux

              mytab.2.2.2.2
              begintabular[c]cccc
              mytab.1.0.5.2 & mytab.1.1.1.1
              \[.5cm]
              mytab.0.0.0.2 & mytab.3.0.3.9
              endtabular
              mytab.2.0.3.9
              enddocument


              enter image description here






              share|improve this answer



























                6












                6








                6







                Although not exactly the same, something very similar can be done with some tabular and without TiKZ.



                documentclassarticle

                newcommandmytab[4]%
                begintabular[c]c
                hline
                #1&#2\hline
                #3&#4\hline
                endtabular

                begindocument

                mytab.2.2.2.2
                begintabular[c]cccc
                mytab.1.0.5.2 & mytab.1.1.1.1
                \[.5cm]
                mytab.0.0.0.2 & mytab.3.0.3.9
                endtabular
                mytab.2.0.3.9
                enddocument


                enter image description here



                EDIT: or even better with ytableau package



                documentclassarticle
                usepackageytableau

                newcommandmytab[4]%
                beginytableau
                #1&#2\
                #3&#4\
                endytableau

                begindocument
                ytableausetupcentertableaux

                mytab.2.2.2.2
                begintabular[c]cccc
                mytab.1.0.5.2 & mytab.1.1.1.1
                \[.5cm]
                mytab.0.0.0.2 & mytab.3.0.3.9
                endtabular
                mytab.2.0.3.9
                enddocument


                enter image description here






                share|improve this answer















                Although not exactly the same, something very similar can be done with some tabular and without TiKZ.



                documentclassarticle

                newcommandmytab[4]%
                begintabular[c]c
                hline
                #1&#2\hline
                #3&#4\hline
                endtabular

                begindocument

                mytab.2.2.2.2
                begintabular[c]cccc
                mytab.1.0.5.2 & mytab.1.1.1.1
                \[.5cm]
                mytab.0.0.0.2 & mytab.3.0.3.9
                endtabular
                mytab.2.0.3.9
                enddocument


                enter image description here



                EDIT: or even better with ytableau package



                documentclassarticle
                usepackageytableau

                newcommandmytab[4]%
                beginytableau
                #1&#2\
                #3&#4\
                endytableau

                begindocument
                ytableausetupcentertableaux

                mytab.2.2.2.2
                begintabular[c]cccc
                mytab.1.0.5.2 & mytab.1.1.1.1
                \[.5cm]
                mytab.0.0.0.2 & mytab.3.0.3.9
                endtabular
                mytab.2.0.3.9
                enddocument


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 11 at 19:44

























                answered Jan 11 at 19:22









                IgnasiIgnasi

                92.7k4166308




                92.7k4166308



























                    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%2f469745%2ftikz-align-array-of-matrices%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

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay