# TikZ vertical alignment of circled text

I have an issue with the vertical alignment of circled text with TikZ. This basic code causes the problem I have.

  \texttt{some text here =}
\tikz[remember picture] \node[draw,ellipse,fill=none,thick] (code) {\texttt{other text}};


The problem is that the displayed text 'some text here=' is not vertically aligned with the displayed text 'other text'. I read about anchors in the documentation and they looked promising, but I've been unable to get them to work for me so far. Perhaps I could do this by making the left hand side a node, but I don't think that should be necessary? Any suggestions would be much appreciated!

-
You should add to the \tikz options baseline=-0.825ex: that should fix the problem. – Claudio Fiandrino Aug 18 '12 at 13:53
Thanks Claudio! Worked a treat. – John Pirie Aug 18 '12 at 13:57

Use the base of the node for the baseline option:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}

\texttt{some text here =}
\tikz[remember picture,baseline=(code.base)] \node[draw,ellipse,fill=none,thick] (code) {\texttt{other text}};

\end{document}


Edited by Claudio Fiandrino

This is a possible alternative:

\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}
\texttt{some text here = \tikz[baseline=-0.825ex] \node[draw,ellipse,fill=none,thick] (code) {other text};}
\end{document}


Notice that if you insert the tikz code inside the first texttt you can skip the command inside the node since it is automatically rendered in typewriter.

-
I've added the alternative present in my previous answer; hope you don't mind. :) – Claudio Fiandrino Aug 18 '12 at 14:37
@ClaudioFiandrino not at all. :-) – Gonzalo Medina Aug 18 '12 at 14:45
 \texttt{some text here =}
\tikz[remember picture,baseline]
\node[draw,ellipse,fill=none,thick,anchor=base] (code) {\texttt{other text}};

-