我有以下 tikz 代码:
\tikzstyle{city} = [draw, fill=white!20, circle, node distance=0.5cm]
\begin{tikzpicture}[baseline={(current bounding box.center)},node distance=0.7cm]
\node [city] (S) {};
\node [coordinate,right of=city] (S1) {};
\node [city,above of=S1] (j1) {$j$};
\node [city,above of=j1] (i1) {};
\node [city,below of=S1] (k1) {};
\end{tikzpicture}
输出结果如下:
我怎样才能使包含它的圆j
与其他圆的直径相同并且不会像那样爆炸?
谢谢你!
答案1
您可以使用label={...}
代替节点文本,使节点大小独立于文本大小。
\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\tikzstyle{city} = [draw, fill=white!20, circle, node distance=0.5cm]
\begin{tikzpicture}[baseline={(current bounding box.center)},node distance=0.7cm]
\node [city] (S) {};
\node [coordinate,right of=S] (S1) {};
\node [city,above of=S1, label=center:$j$] (j1) {};
\node [city,above of=j1] (i1) {};
\node [city,below of=S1] (k1) {};
\end{tikzpicture}
\bigskip
\tikzstyle{city} = [draw, fill=white!20, circle,minimum size=1.1em, node distance=0.5cm]
\begin{tikzpicture}[baseline={(current bounding box.center)},node distance=0.7cm]
\node [city] (S) {};
\node [coordinate,right of=S] (S1) {};
\node [city,above of=S1, label=center:$j$] (j1) {};
\node [city,above of=j1] (i1) {};
\node [city,below of=S1] (k1) {};
\end{tikzpicture}
\end{document}
如果圆圈对于文本来说太紧,您可以通过设置来使所有圆圈的尺寸稍微大一些minimum size=1.1em
。