为什么 fit 不能缩放?(tikz)

为什么 fit 不能缩放?(tikz)

我对 TikZ 中的 fit 库有疑问。

当我缩放图形(使用 tikz scale 命令)时,适合框却不适合!

这是为什么?我能改变它吗?

例子:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}

\begin{tikzpicture}[state/.style={circle,draw,thick,loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick] coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick] coordinate (bl) ();

\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}


\begin{tikzpicture}[scale=2,state/.style={circle,draw,thick,loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick] coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick] coordinate (bl) ();

\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}

\end{document}

输出

答案1

transform shape添加缩放框和形状的选项:

\begin{tikzpicture}[scale=2,transform shape,
    state/.style={circle,draw,thick,loop above,inner sep=0,minimum width=10}]

替代文本

答案2

没有 的可能性transform shape。你可以使用 x=2cm y=2cm 进行缩放

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}

\begin{tikzpicture}[state/.style={circle,draw,thick,loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick] coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick] coordinate (bl) ();

\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}


\begin{tikzpicture}[x=2cm,y=2cm,state/.style={circle,draw,thick,loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick] coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick] coordinate (bl) ();

\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}

\end{document}  

在此处输入图片描述

相关内容