
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}