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 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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
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

 
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.