TikZ: Align array of matrices












4















The following code:



documentclass[tikz,border=1mm]{standalone}

usepackage{tikz}
usetikzlibrary{matrix, positioning}

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

begin{document}
begin{tikzpicture}

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

begin{scope} [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 \
};
end{scope}

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

end{tikzpicture}
end{document}


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



begin{scope} [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}

    usepackage{tikz}
    usetikzlibrary{matrix, positioning}

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

    begin{document}
    begin{tikzpicture}

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

    begin{scope} [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 \
    };
    end{scope}

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

    end{tikzpicture}
    end{document}


    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



    begin{scope} [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


      0






      The following code:



      documentclass[tikz,border=1mm]{standalone}

      usepackage{tikz}
      usetikzlibrary{matrix, positioning}

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

      begin{document}
      begin{tikzpicture}

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

      begin{scope} [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 \
      };
      end{scope}

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

      end{tikzpicture}
      end{document}


      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



      begin{scope} [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}

      usepackage{tikz}
      usetikzlibrary{matrix, positioning}

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

      begin{document}
      begin{tikzpicture}

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

      begin{scope} [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 \
      };
      end{scope}

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

      end{tikzpicture}
      end{document}


      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



      begin{scope} [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 2 hours ago









      Bernard

      167k769194




      167k769194










      asked 2 hours ago









      SamuelSamuel

      521211




      521211






















          2 Answers
          2






          active

          oldest

          votes


















          4














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



          documentclass{article}

          newcommand{mytab}[4]{%
          begin{tabular}[c]{|c|c|}
          hline
          #1&#2\hline
          #3&#4\hline
          end{tabular}}

          begin{document}

          mytab{.2}{.2}{.2}{.2}
          begin{tabular}[c]{cccc}
          mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
          \[.5cm]
          mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
          end{tabular}
          mytab{.2}{.0}{.3}{.9}
          end{document}


          enter image description here



          EDIT: or even better with ytableau package



          documentclass{article}
          usepackage{ytableau}

          newcommand{mytab}[4]{%
          begin{ytableau}
          #1&#2\
          #3&#4\
          end{ytableau}}

          begin{document}
          ytableausetup{centertableaux}

          mytab{.2}{.2}{.2}{.2}
          begin{tabular}[c]{cccc}
          mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
          \[.5cm]
          mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
          end{tabular}
          mytab{.2}{.0}{.3}{.9}
          end{document}


          enter image description here






          share|improve this answer

































            3














            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}
            usetikzlibrary{matrix, positioning}

            begin{document}
            begin{tikzpicture}[
            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 \
            };
            end{tikzpicture}
            end{document}





            share|improve this answer

























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "85"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%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









              4














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



              documentclass{article}

              newcommand{mytab}[4]{%
              begin{tabular}[c]{|c|c|}
              hline
              #1&#2\hline
              #3&#4\hline
              end{tabular}}

              begin{document}

              mytab{.2}{.2}{.2}{.2}
              begin{tabular}[c]{cccc}
              mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
              \[.5cm]
              mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
              end{tabular}
              mytab{.2}{.0}{.3}{.9}
              end{document}


              enter image description here



              EDIT: or even better with ytableau package



              documentclass{article}
              usepackage{ytableau}

              newcommand{mytab}[4]{%
              begin{ytableau}
              #1&#2\
              #3&#4\
              end{ytableau}}

              begin{document}
              ytableausetup{centertableaux}

              mytab{.2}{.2}{.2}{.2}
              begin{tabular}[c]{cccc}
              mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
              \[.5cm]
              mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
              end{tabular}
              mytab{.2}{.0}{.3}{.9}
              end{document}


              enter image description here






              share|improve this answer






























                4














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



                documentclass{article}

                newcommand{mytab}[4]{%
                begin{tabular}[c]{|c|c|}
                hline
                #1&#2\hline
                #3&#4\hline
                end{tabular}}

                begin{document}

                mytab{.2}{.2}{.2}{.2}
                begin{tabular}[c]{cccc}
                mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
                \[.5cm]
                mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
                end{tabular}
                mytab{.2}{.0}{.3}{.9}
                end{document}


                enter image description here



                EDIT: or even better with ytableau package



                documentclass{article}
                usepackage{ytableau}

                newcommand{mytab}[4]{%
                begin{ytableau}
                #1&#2\
                #3&#4\
                end{ytableau}}

                begin{document}
                ytableausetup{centertableaux}

                mytab{.2}{.2}{.2}{.2}
                begin{tabular}[c]{cccc}
                mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
                \[.5cm]
                mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
                end{tabular}
                mytab{.2}{.0}{.3}{.9}
                end{document}


                enter image description here






                share|improve this answer




























                  4












                  4








                  4







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



                  documentclass{article}

                  newcommand{mytab}[4]{%
                  begin{tabular}[c]{|c|c|}
                  hline
                  #1&#2\hline
                  #3&#4\hline
                  end{tabular}}

                  begin{document}

                  mytab{.2}{.2}{.2}{.2}
                  begin{tabular}[c]{cccc}
                  mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
                  \[.5cm]
                  mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
                  end{tabular}
                  mytab{.2}{.0}{.3}{.9}
                  end{document}


                  enter image description here



                  EDIT: or even better with ytableau package



                  documentclass{article}
                  usepackage{ytableau}

                  newcommand{mytab}[4]{%
                  begin{ytableau}
                  #1&#2\
                  #3&#4\
                  end{ytableau}}

                  begin{document}
                  ytableausetup{centertableaux}

                  mytab{.2}{.2}{.2}{.2}
                  begin{tabular}[c]{cccc}
                  mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
                  \[.5cm]
                  mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
                  end{tabular}
                  mytab{.2}{.0}{.3}{.9}
                  end{document}


                  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.



                  documentclass{article}

                  newcommand{mytab}[4]{%
                  begin{tabular}[c]{|c|c|}
                  hline
                  #1&#2\hline
                  #3&#4\hline
                  end{tabular}}

                  begin{document}

                  mytab{.2}{.2}{.2}{.2}
                  begin{tabular}[c]{cccc}
                  mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
                  \[.5cm]
                  mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
                  end{tabular}
                  mytab{.2}{.0}{.3}{.9}
                  end{document}


                  enter image description here



                  EDIT: or even better with ytableau package



                  documentclass{article}
                  usepackage{ytableau}

                  newcommand{mytab}[4]{%
                  begin{ytableau}
                  #1&#2\
                  #3&#4\
                  end{ytableau}}

                  begin{document}
                  ytableausetup{centertableaux}

                  mytab{.2}{.2}{.2}{.2}
                  begin{tabular}[c]{cccc}
                  mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
                  \[.5cm]
                  mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
                  end{tabular}
                  mytab{.2}{.0}{.3}{.9}
                  end{document}


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 51 mins ago

























                  answered 1 hour ago









                  IgnasiIgnasi

                  91.9k4166305




                  91.9k4166305























                      3














                      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}
                      usetikzlibrary{matrix, positioning}

                      begin{document}
                      begin{tikzpicture}[
                      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 \
                      };
                      end{tikzpicture}
                      end{document}





                      share|improve this answer






























                        3














                        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}
                        usetikzlibrary{matrix, positioning}

                        begin{document}
                        begin{tikzpicture}[
                        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 \
                        };
                        end{tikzpicture}
                        end{document}





                        share|improve this answer




























                          3












                          3








                          3







                          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}
                          usetikzlibrary{matrix, positioning}

                          begin{document}
                          begin{tikzpicture}[
                          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 \
                          };
                          end{tikzpicture}
                          end{document}





                          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}
                          usetikzlibrary{matrix, positioning}

                          begin{document}
                          begin{tikzpicture}[
                          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 \
                          };
                          end{tikzpicture}
                          end{document}






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 1 hour ago

























                          answered 1 hour ago









                          ZarkoZarko

                          122k865158




                          122k865158






























                              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

                              Liste der Baudenkmale in Friedland (Mecklenburg)

                              Single-Malt-Whisky

                              Czorneboh