![`node distance=#1` 在 TikZ 3.0 下似乎无效](https://linux22.com/image/284499/%60node%20distance%3D%231%60%20%E5%9C%A8%20TikZ%203.0%20%E4%B8%8B%E4%BC%BC%E4%B9%8E%E6%97%A0%E6%95%88.png)
我在升级之前没有遇到这个问题(注意node distance=5in
):
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows}
\tikzset{
node distance=3cm,
graph vertex/.style={
circle,
draw,
minimum size=7.5mm,
},
graph directed edge/.style={
>=stealth,
->,
semithick,
},
}
\begin{document}
\begin{tikzpicture}[node distance=5in]
\foreach \posx/\posy/\name in {
1/3/A,
0/3/B,
2/3/C,
3/3/D,
1/2/E,
3/2/F,
0/1/G,
2/1/H,
1/0/I,
3/1/J}
\node[graph vertex] (\name) at ((\posx,\posy) {\name};
\foreach \source/\sink in {A/C,A/H,B/A,B/G,C/D,D/F,E/A,E/I,F/J,G/I,H/F,H/G,I/H,J/C}
\path[graph directed edge] (\source) edge (\sink);
\end{tikzpicture}
\end{document}
答案1
节点距离控制物体相对于彼此放置时的自动距离。简单的例子;
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[every node/.append style={circle,draw,inner sep=1pt}]
\node[] (A) {A};
\node[left=of A] (B) {B};
\begin{scope}[node distance=2cm]
\node[right=of A] (C) {C};
\end{scope}
\begin{scope}[node distance=1mm]
\node[above=of A] (D) {D};
\end{scope}
\end{tikzpicture}
\end{document}
关于您的scale
问题,它是图片或节点键,因此必须在正确的上下文中读取。只有,
\tikzset{scale=3}
不会调用任何东西,因为每个 tikzpicture 环境都需要在初始化期间读取它。如果我理解你的评论正确的话,你可以将此类规范放在键中every picture
。使用句柄/.prefix style
可以在个别情况下覆盖它,例如,
\documentclass{article}
\usepackage{tikz}
\tikzset{every picture/.prefix style={scale=3}} % For every tikz picture
\begin{document}
\begin{tikzpicture}[] %scale=3
\draw (0,0) -- (1,0);
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5]% Overrides the key on this one since those keys are prefixed
%Now the scale is 1.5!!! Transformations are cumulative
\draw (0,0) -- (1,0);
\end{tikzpicture}
\begin{tikzpicture}[reset cm,scale=0.5]% Overrides the key on this one since those keys are prefixed
%Now the scale is 0.5!!! We reset the transformation
\draw (0,0) -- (1,0);
\end{tikzpicture}
\end{document}
适用于你的例子
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows}
\tikzset{%node distance=3cm,
graph vertex/.style={
circle,
draw,
minimum size=7.5mm,
},
graph directed edge/.style={
>=stealth,
->,
semithick,
},
every picture/.prefix style={scale=3}
}
\begin{document}
\begin{tikzpicture}[]
\foreach \posx/\posy/\name in {
1/3/A,
0/3/B,
2/3/C,
3/3/D,
1/2/E,
3/2/F,
0/1/G,
2/1/H,
1/0/I,
3/1/J}
\node[graph vertex] (\name) at ((\posx,\posy) {\name};
\foreach \source/\sink in {A/C,A/H,B/A,B/G,C/D,D/F,E/A,E/I,F/J,G/I,H/F,H/G,I/H,J/C}
\path[graph directed edge] (\source) edge (\sink);
\end{tikzpicture}
\end{document}
如果您还希望将转换应用于节点,则需要将transform shape
键放在样式中或明确地放在节点选项中。