tikzpicture 내에서 스케일링이 TikZ-pic에 영향을 미치도록 하려면 어떻게 해야 합니까?

tikzpicture 내에서 스케일링이 TikZ-pic에 영향을 미치도록 하려면 어떻게 해야 합니까?

TikZ 사진에 "전역 크기 조정"을 적용하고 싶습니다. 이는 환경 내에 정의된 모든 사진에도 영향을 미칩니다 tikzpicture. MWE:

\documentclass[tikz, border=2mm]{standalone}
\begin{document}
    \begin{tikzpicture}[scale=0.5]    
        \draw [green] (0,0) rectangle (10,10);
        \tikzset{square/.pic={\draw [red] (0,0) rectangle (10,10);}}
        \draw (0,0) pic {square};
    \end{tikzpicture}
\end{document}

에서 정의된 빨간색 사각형 square이 안에 그려진 녹색 사각형과 맞지 않는 이유는 무엇입니까 tikzpicture? 스케일링을 전역적으로 적용하여 그 안에 정의된 모든 사진에 영향을 미치도록 하려면 어떻게 해야 합니까? 나는 pic손으로 모든 스케일링을 피하고 싶습니다 .

여기에 이미지 설명을 입력하세요

답변1

transform shape당신의 친구입니다. 일반적으로 노드(및 분명히 사진)와 같은 항목은 크기가 조정되지 않습니다. 를 사용하면 transform shape이를 시행할 수 있습니다. 이는 텍스트의 크기도 조정합니다.

\documentclass[tikz, border=2mm]{standalone}
\begin{document}
    \begin{tikzpicture}[scale=0.5, transform shape] % <--- Here!  
        \draw [green] (0,0) rectangle (10,10);
        \tikzset{square/.pic={\draw [red] (0,0) rectangle node[midway, transform shape = false] { Foo } (10,10);}} % note the inserted, not transformed text node
        \draw (0,0) pic {square};
    \end{tikzpicture}
\end{document}

관련 정보