上下文
考虑这个简单的tikz
图表
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary[positioning]
\begin{document}
\begin{tikzpicture}[auto, node distance=1cm and 4cm]
\node[circle, draw] (1) {1};
\node[circle, draw] (2) [above right=of 1] {2};
\node[circle, draw] (3) [below right=of 1] {3};
\node[circle, draw] (4) [below left=of 3] {4};
\node[circle, draw] (5) [below right=of 4] {5};
\node[circle, draw] (6) [right=of 3] {6};
\node[circle, draw] (7) [right=of 6] {7};
\draw (1) to node {} (2)
(1) to node {} (3)
(1) to node {} (5)
(4) to node {} (2)
(4) to node {} (3)
(4) to node {} (5)
(2) to node {} (6)
(3) to node {} (6)
(5) to node {} (6)
(6) to node {} (7);
\end{tikzpicture}
\end{document}
问题
因为node distance=1cm and 4cm
将所有列之间的间距设置为4cm
。我想更改节点和所在的列间距6
,7
而不2cm
更改其他列之间的间距。
答案1
这只是一个题外话,正确答案包含在muzimuzhi 的评论。您可以使用matrix of nodes
并设置column sep
和row sep
以满足您的要求。tikz-cd
可以使打孔这样的矩阵变得特别简单。
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[column sep=6em,/tikz/column 3/.style={column sep=3em},
cells={nodes={circle,draw}},arrows=dash]
& 2\\
1\arrow[ur]\arrow[dr]\arrow[dddr]\\
& 3 & 6 \arrow[uul]\arrow[l]\arrow[ddl]\arrow[r]& 7\\
4\arrow[uuur]\arrow[ur]\arrow[dr]\\
& 5\\
\end{tikzcd}
\end{document}