2

I have created the following picture using tikz:

\tikzset{
    graphnode/.style={
      draw,fill,
      circle,
      minimum size=0.7mm,
      inner sep=0
    },
}

\begin{tikzpicture}[every node/.style={graphnode}]

  \node (b)[label=left:$b$] at (0,0) {};
  \node (g)[label=right:$g$] at (4,0) {};
  \node (r)[label=above:$r$] at (2,3.4641) {};

  \node[label=below:$v$] (n1) at (1.5,0.8) {};
  \node[label=below:$u$] (n2) at (3,0.5) {};
  \node[label=above right:$w$] (n3) at (2.1,2) {};

  \draw(r.center) -- (g.center) -- (b.center) -- cycle;

  \draw (n1.center) -- (b);
  \draw (n2.center) -- (b);
  \draw (n3.center) -- (b);

  \draw (n1.center) -- (n2.center);
  \draw (n2.center) -- (g);
  \draw (n3) -- (g);

  \draw (n1.center) -- (n3.center);
  \draw (n2.center) -- (n3.center);
  \draw (n3.center) -- (r);

\end{tikzpicture}

The problem is that the two labels b and g are not properly aligned. How can I align them without changing the node positions?

2

One possibility is to use a math strut:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\tikzset{
    graphnode/.style={
      draw,fill,
      circle,
      minimum size=0.7mm,
      inner sep=0
    },
}

\begin{tikzpicture}[every node/.style={graphnode}]

  \node (b)[label=left:$\mathstrut b$] at (0,0) {};
  \node (g)[label=right:$\mathstrut g$] at (4,0) {};
  \node (r)[label=above:$r$] at (2,3.4641) {};

  \node[label=below:$v$] (n1) at (1.5,0.8) {};
  \node[label=below:$u$] (n2) at (3,0.5) {};
  \node[label=above right:$w$] (n3) at (2.1,2) {};

  \draw(r.center) -- (g.center) -- (b.center) -- cycle;

  \draw (n1.center) -- (b);
  \draw (n2.center) -- (b);
  \draw (n3.center) -- (b);

  \draw (n1.center) -- (n2.center);
  \draw (n2.center) -- (g);
  \draw (n3) -- (g);

  \draw (n1.center) -- (n3.center);
  \draw (n2.center) -- (n3.center);
  \draw (n3.center) -- (r);

\end{tikzpicture}

\end{document}

enter image description here

  • Well, I used an old fashioned phantom instead, but it comes down to the same end. – hfhc2 Sep 10 '13 at 20:46

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.