# Center text node

I currently have the following TikZ code:

\documentclass{scrbook}

\usepackage{tikz}

\begin{document}

\tikzset{
tlstartyear/.style={
name=tlstartyear,
above=5pt,
inner xsep=0pt,
anchor=base west,
}
}

\tikz{
\fill [blue] (0,0)
++(3em,0pt)
node [tlstartyear] {Some text}
node {$\bullet$};
}

\end{document}


which (thanks to Jake) produces:

How can I center the text with the node?

I've tried playing with align=center, align=flush center, right and left, without success...

-
Maybe the horizontal-alignment tag is appropriate. – lockstep Sep 29 '11 at 20:20
Yes indeed @lockstep, thanks. – ℝaphink Sep 29 '11 at 20:21

Change anchor=base west to anchor=base in \tikzset. Or, if you want to preserve the base west anchor in \tikzset for other nodes, use node [tlstartyear,anchor=base] {Some text}.

-
Ah, thanks! I can only upvote your answer in 3 hours (max votes reached for today). – ℝaphink Sep 29 '11 at 20:23

It seems that if you simply remove the anchor=base west things just work:

\tikzset{
tlstartyear/.style={
name=tlstartyear,
above=5pt,
inner xsep=0pt,
%anchor=base west,
}
}


In the original solution, I had replaced above=5pt with above. As @Gonzalo pointed out, this has nothing to do with horizontal alignment. To me it looks better if you replace above=5pt, with just above, but that is subjective, so have reverted that back in the code above. The image shown is with using the above option without a length.

-
In the original code the anchor is set to base west, not simply base (in fact, removing west and using only base gives the desired horizontal alignment). I don't see why changing above=5pt to above has anything to do with the horizontal alignment. – Gonzalo Medina Sep 29 '11 at 20:41
@Gonzalo: You are absolutely correct. I normally just use above without the option length so that is what I tried and it looked better to me. Will add this as a comment. – Peter Grill Sep 29 '11 at 20:47