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

not centered

How can I center the text with the node?

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

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

2 Answers 2

up vote 7 down vote accepted

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

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

enter image description here

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

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.