2

The following code produces a 3x3 matrix (upper left corner) and an 2x2 array of 3x3 matrices:

enter image description here

How can I reduce the size of the matrix array such that it has the same size as the matrix M? I tried scale=0.5 which had no effect. I want to reduce the size only of the matrix array and not of the entire TikZ picture.

\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 & .0  \\
            .0 & .2 & .8 \\
            .2 & .0 & .8 \\
        };

        \begin{scope} [shift={(M.south)}, below = 0cm of M.south]
            \matrix (M11) [matrixstyle]{
                .1 & .1 & .0  \\
                .0 & .5 & .0 \\
                .3 & .0 & .0 \\
            };
            \matrix (M12) [matrixstyle, right = 0cm of M11]{
                .3 & .2 & .0  \\
                .0 & .3 & .9 \\
                .2 & .1 & .0 \\
            };
            \matrix (M21) [matrixstyle, below = 0cm of M11]{
                .0 & .0 & .0  \\
                .0 & .0 & .2 \\
                .0 & .0 & .2 \\
            };
            \matrix (M22) [matrixstyle, right = 0cm of M21]{
                .9 & .3 & .0  \\
                .0 & .3 & .9 \\
                .5 & .0 & .8 \\
            };
        \end{scope}

    \end{tikzpicture}
\end{document}
4

You could use scale = <scale> and every node/.style = {scale = <scale>} ... whether this is a good idea is a whole different question

\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 & .0  \\
            .0 & .2 & .8 \\
            .2 & .0 & .8 \\
        };

        \begin{scope} [shift={([xshift = -11pt]M.south)}, below = 0cm of M.south, scale = 0.47, every node/.style = {scale = 0.47}]
            \matrix (M11) [matrixstyle]{
                .1 & .1 & .0  \\
                .0 & .5 & .0 \\
                .3 & .0 & .0 \\
            };
            \matrix (M12) [matrixstyle, right = -6pt of M11]{
                .3 & .2 & .0  \\
                .0 & .3 & .9 \\
                .2 & .1 & .0 \\
            };
            \matrix (M21) [matrixstyle, below = -6pt of M11]{
                .0 & .0 & .0  \\
                .0 & .0 & .2 \\
                .0 & .0 & .2 \\
            };
            \matrix (M22) [matrixstyle, right = -6pt of M21]{
                .9 & .3 & .0  \\
                .0 & .3 & .9 \\
                .5 & .0 & .8 \\
            };
        \end{scope}

    \end{tikzpicture}
\end{document}

enter image description here

  • Why do I need [xshift = -11pt]? Is there an exact solution, which does the centering automatically? – Samuel Jan 11 at 18:07

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.