# [Tex/LaTex] Common baseline in TikZ and Mathmode

math-modetikz-pgf

Possible Duplicate:
How to align a series of TikZ pictures at the baseline

I want to mix my formulas with some TikZ graphics. For example:

\documentclass{article}
\usepackage{tikz}
\begin{document}
$$n\cdot \tikz[baseline]\node [minimum height=2em,draw=black] {m}; \cdot \tikz[baseline]\node [draw=black] {a}; \cdot b$$
\end{document}


This generates the following output:

However, the baseline from Tikz doesn't fit with that from the equation. You see, the m is deeper than the n and the dot is anywhere above it.

How can I make all the text on one common baseline?

The baseline for the box is the bottom of the box. The default behavior is to align to the baseline:

\tikz \node [minimum height=2em,draw=black] {$m$};


\documentclass{article}
\usepackage{tikz}
\begin{document}
$$n\cdot \tikz \node [minimum height=2em,draw=black] {m}; \cdot \tikz \node [draw=black] {a}; \cdot b$$
\end{document}


If you want to align the text at the baseline, then as per Jake's suggetsion you need to add anchor=base:

\documentclass{article}
\usepackage{tikz}
\begin{document}
$$n\cdot \tikz [anchor=base, baseline] \node [minimum height=2em,draw=black] {m}; \cdot \tikz [anchor=base, baseline] \node [draw=black] {a}; \cdot b$$
\end{document}