[Tex/LaTex] Scaling inside a TikZ matrix does not work

scalingtikz-pgf

I'm having some difficulty at scaling a TikZ draw inside a matrix:

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=.5]
    \matrix [yshift=2cm]{
       \draw (0,0)--(0.2,1)--(1,1.2)--(1.2,0)--(0,0);&
       \node{Some text that should not be scaled};\\
    };

    \draw (0,0)--(0.2,1)--(1,1.2)--(1.2,0)--(0,0);
    \end{tikzpicture}

 \end{document}

enter image description here

As you can see the same picture is scaled outside the matrix but not inside. I can't use the scalebox or resizebox methods because there is some text in my original picture that should not be scaled, as it happens by default when you scale via the TikZ own option.

So, why the draw does not scale inside the matrix? Is there some way I can make it scale without scaling the text too?

Best Answer

This is one of those grey areas about cell picture issues. One not-super-clean solution is to set the transformation yourself.

\documentclass[margin=5pt,tikz]{standalone}
\begin{document}

    \begin{tikzpicture}[scale=.5]
    \pgfgettransform\mytrafo
    \matrix [yshift=2cm,execute at begin cell=\pgfsettransform\mytrafo]{
       \draw (0,0)--(0.2cm,1cm)--(1cm,1.2cm)--(1.2cm,0)--cycle;&
       \node{Some text that should not be scaled};\\
    };

    \draw (0,0)--(0.2,1)--(1,1.2)--(1.2,0)--(0,0);
    \end{tikzpicture}

 \end{document}

enter image description here

Related Question