缩放节点、增加 sep 和坐标,同时保留文本大小

缩放节点、增加 sep 和坐标,同时保留文本大小

我有一幅以1cm为单位的图画。

1厘米单位

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,positioning}
\begin{document}
\begin{tikzpicture}[
  every node/.style = {
    circle,
    very thick,
    inner sep = 0,
    outer sep = 0,
    minimum size = 1cm,
    draw = black,
    scale = 1,
  },
]
\graph[grow right sep = 1cm]{
  1 -> 2 -> 3 -> 4
};
\draw[help lines] (-0.5, -1.5) grid (8, 1.5);
\end{tikzpicture}
\end{document}

我想将其缩放到 0.75 倍,同时保留字体大小(应与文档的其余部分保持一致)。我确实设法获得了所需的输出,但我认为这相当不靠谱,因为我不知道它为什么会起作用。

0.75厘米

% …
\begin{tikzpicture}[scale=0.75,
% …
    minimum size = 0.75cm,
% …
\graph[grow right sep = 5mm]{
% …

特别困扰我的是grow right sep = 5mm,我通过反复试验才得到正确的结果。

答案1

还必须对节点形状进行缩放(通过transform shapes):

\documentclass[border=3.141502, varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,positioning}
\begin{document}
    \begin{tikzpicture}[scale=0.75, transform shape,%x=7.5mm,
every node/.style = {circle, draw, very thick,
                     inner sep = 0, outer sep=0pt,
                     minimum size = 10mm},
                        ]
\graph[grow right sep=10mm]{
  1 -> 2 -> 3 -> 4
};
\draw[help lines] (-0.5,-1.5) grid (8,1.5);
    \end{tikzpicture}

\medskip   
    \begin{tikzpicture}[
every node/.style = {circle, draw, very thick,
                     inner sep = 0, outer sep=0pt,
                     minimum size = 10mm},
                        ]
\graph[grow right sep=10mm]{
  1 -> 2 -> 3 -> 4
};
\draw[help lines] (-0.5,-1.5) grid (8,1.5);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

附录: 不幸的是,这个问题并不完全清楚(至少我是这样)。现在我猜,你喜欢更小的形状、更小的节点距离,但文本字体大小正常。这可以通过相应地改变节点大小、节点距离大小以及(如果你喜欢)帮助线的步长来实现。所有这些更改都在代码中标记为% <---

\documentclass[border=3.141502, varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,positioning}
\begin{document}
    \begin{tikzpicture}[
every node/.style = {circle, draw, very thick,
                     inner sep = 0, outer sep=0pt,
                     minimum size = 7.5mm}, % <---
                        ]
\graph[grow right sep=7.5mm]{               % <---
  1 -> 2 -> 3 -> 4
};
\draw[help lines, step=7.5mm]               % <---
    (-0.5,-1.5) grid (6,1.5);
    \end{tikzpicture}

for comparison with "scaled" image: 
 
    \begin{tikzpicture}[
every node/.style = {circle, draw, very thick,
                     inner sep = 0, outer sep=0pt,
                     minimum size = 10mm},
                        ]
\graph[grow right sep=10mm]{
  1 -> 2 -> 3 -> 4
};
\draw[help lines] (-0.5,-1.5) grid (8,1.5);
% for test of scaling:
    \end{tikzpicture}
\end{document}

在此处输入图片描述

这是您想要的结果吗?如您所见,它无法通过简单的缩放获得。但是,您仍然可以使用第一个解决方案,并在节点中使用更大的字体大小,例如Large在您的案例中。

相关内容