尝试使用 tikzpicture 的缩放选项,发现有些图片可以使用,有些则不行。我不知道为什么。
这是 MWE
以下是代码
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fit}
\usepackage[margin=1in]{geometry}
\tikzstyle{block} = [rectangle, draw=red, text centered, rounded corners, minimum height=1cm]
\begin{document}
\noindent\fbox{\begin{tikzpicture}[scale=3]
\node [block, minimum width=2in] at (0,0) (A) {text};
\node [block, below =of A] (B) {more test};
\draw[->] (A)--(B);
\end{tikzpicture}
}
And
\noindent\fbox{\begin{tikzpicture}[scale=1]
\node [block, minimum width=2in] at (0,0) (A) {text};
\node [block, below =of A] (B) {more test};
\draw[->] (A)--(B);
\end{tikzpicture}
}
\noindent\fbox{\begin{tikzpicture}[scale=3]
\draw (0,0) -- (1,1);
\end{tikzpicture}
}
\noindent\fbox{\begin{tikzpicture}[scale=1]
\draw (0,0) -- (1,1);
\end{tikzpicture}
}
\end{document}
为什么第二个可以,第一个就不行?我一直以为整个图片都会缩放。
TL 2023
答案1
如果您想缩放节点,您还需要提供该transform shape
选项(旋转也是如此,irc):
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fit}
\usepackage[margin=1in]{geometry}
\tikzstyle{block} = [rectangle, draw=red, text centered, rounded corners, minimum height=1cm]
\begin{document}
\noindent\fbox{\begin{tikzpicture}[scale=3, transform shape]
\node [block, minimum width=2in] at (0,0) (A) {text};
\node [block, below =of A] (B) {more test};
\draw[->] (A)--(B);
\end{tikzpicture}
}
And
\noindent\fbox{\begin{tikzpicture}[scale=1]
\node [block, minimum width=2in] at (0,0) (A) {text};
\node [block, below =of A] (B) {more test};
\draw[->] (A)--(B);
\end{tikzpicture}
}
\noindent\fbox{\begin{tikzpicture}[scale=3]
\draw (0,0) -- (1,1);
\end{tikzpicture}
}
\noindent\fbox{\begin{tikzpicture}[scale=1]
\draw (0,0) -- (1,1);
\end{tikzpicture}
}
\end{document}