Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to make 12 nodes with same sized circles. Currently, the radius of a circle for single digit number and two digit numbers are different. Let r1 be the radius for single digit numbers. Let r2' be the radius for two digit numbers. How can I make all numbers to have circles with radius r1?

            \documentclass[11pt]{article}

            \usepackage{tikz}
            \usepackage[graphics, tightpage, active]{preview}
            \setlength{\PreviewBorder}{2pt}
            \PreviewEnvironment{tikzpicture}

             \usepackage{graphicx}
             \usepackage{subfigure}
             \usepackage{amsmath}
             \usepackage{amsfonts}

             \usepackage{tikz}
             \usetikzlibrary{positioning}

            \begin{document}
                \begin{tikzpicture}[scale=1.5]
                \begin{scope}[auto, every node/.style={draw,circle},node distance=2cm]
                % the vertices
                \node(v1) at (0,0){1};
                \node[above=of v1](v2){2};
                \node[above=of v2](v3){3};
                \node[right=of v1](v4){4};
                \node[above=of v4](v5){5};
                \node[above=of v5](v6){6};
                \node[right=of v4](v7){7};
                \node[above=of v7](v8){8};
                \node[above=of v8](v9){9};
                \node[right=of v7](v10){10};
                \node[above=of v10](v11){11};
                \node[above=of v11](v12){12};

                \draw (v1)--(v2)
                (v2)--(v3)
                (v1)--(v4)
                (v2)--(v5)
                (v3)--(v6)
                (v4)--(v7)
                (v5)--(v8)
                (v6)--(v9)
                (v7)--(v10)
                (v8)--(v11)
                (v9)--(v12)
                (v10)--(v11)
                (v11)--(v12);


                \end{scope}
                \end{tikzpicture}
            \end{document}
share|improve this question
    
Clarification: You want the bigger nodes to have the same radius as the smaller ones? Is r1 actually given or do you want to get that from the small nodes? –  Qrrbrbirlbel Jul 17 '13 at 22:22

3 Answers 3

you can specify a minimum size in style and if necessary restrict inner sep

 \documentclass[11pt,tikz,border=2pt]{standalone}
    \usetikzlibrary{positioning}
    \begin{document}
     \begin{tikzpicture}[scale=1.5]
      \begin{scope}[auto, every node/.style={draw,circle,minimum size=2em,inner sep=1},node distance=2cm]
        % the vertices
        \node(v1) at (0,0){1};
        \node[above=of v1] (v2) {2};
        \node[above=of v2] (v3) {3};
        \node[right=of v1] (v4) {4};
        \node[above=of v4] (v5) {5};
        \node[above=of v5] (v6) {6};
        \node[right=of v4] (v7) {7};
        \node[above=of v7] (v8) {8};
        \node[above=of v8] (v9) {9};
        \node[right=of v7 ,] (v10) {10};
        \node[above=of v10] (v11) {11};
        \node[above=of v11,] (v12) {12};
      \end{scope}
     \end{tikzpicture}
    \end{document}

enter image description here

share|improve this answer

The easiest way would be to use an invisible digit in the node and a label placed at the center with the actual text.

Code

\documentclass[11pt,tikz,border=2pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
 \begin{tikzpicture}[scale=1.5]
  \begin{scope}[auto, every node/.style={draw,circle},node distance=2cm]
    % the vertices
    \node(v1) at (0,0){1};
    \node[above=of v1] (v2) {2};
    \node[above=of v2] (v3) {3};
    \node[right=of v1] (v4) {4};
    \node[above=of v4] (v5) {5};
    \node[above=of v5] (v6) {6};
    \node[right=of v4] (v7) {7};
    \node[above=of v7] (v8) {8};
    \node[above=of v8] (v9) {9};
    \node[right=of v7 , label=center:10] (v10) {\phantom{0}};
    \node[above=of v10, label=center:11] (v11) {\phantom{0}};
    \node[above=of v11, label=center:12] (v12) {\phantom{0}};
  \end{scope}
 \end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
As all digits have the same height you can also simply use \clap{} on the label text, like \node[above=of v11] (v12) {\clap{12}}; –  Tom Bombadil Jul 18 '13 at 2:58
    
@TomBombadil Which definition of \clap do you use? The width of a single digit is still needed: \def\clap#1{\makebox[\widthof{0}]{#1}}. \clap from mathtools doesn’t give the best results. (In both cases, I added \fboxes around the text of nodes 9 to 12.) –  Qrrbrbirlbel Jul 18 '13 at 3:22

I guess the easiest way is to make use of /tikz/minimum size

Just replace this line

\begin{scope}[auto, every node/.style={draw,circle},node distance=2cm]

with this

\begin{scope}[auto, every node/.style={draw,circle,minimum size=1cm},node distance=2cm]
share|improve this answer
    
...and of course inner sep as pointed out by @rpapa –  sheß Jul 17 '13 at 22:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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