2

I have the following tikz code:

\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}

Which produces the following output:

enter image description here

How do I make it so that the circle containing j is the same diameter as the other circles and doesn't blow up like that?

Thank you!

4

You can use label={...} instead of node text to make the node size independent of the text size.

\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}

enter image description here

In case the circle is too tight for the text, you can impose a slightly larger size on all circles by setting minimum size=1.1em, for example.

| improve this answer | |
  • It would be better to use the positioning library. The below of syntax is deprecated. – cfr Oct 24 '15 at 21:39
  • @cfr -- Yes, but I'm not sure if the OP really needs the old syntax functionality. – AboAmmar Oct 24 '15 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.