# Tikz flowchart: center text + math in node

I'm trying to draw a flowchart with TikZ. In one of the decision "diamonds", I have both text and a bit of math between $. \node [decision, below of=buildbid, node distance=1.8cm, aspect=8, minimum size=20mm] (evalTotImpact) {$\delta_b\left(b_{\text{cur}},b_{\text{last}}\right)\geq$max?};  Unfortunately, despite using centered in the tikzstyle definitions, the text position seems to be fixed and ends up outside of the block, as can be seen on this picture. It does not happen for other blocks in the flowchart with math... Here is the smallest example I could make: \documentclass[journal]{IEEEtran} \usepackage[cmex10]{amsmath} \usepackage{tikz} \usetikzlibrary{shapes,arrows} \begin{document} \usetikzlibrary{calc} \tikzstyle{decision} = [diamond, draw, fill=white, text width=4em, text centered, node distance=3cm, inner sep=0pt, font=\footnotesize] \tikzstyle{block} = [rectangle, draw, fill=white, text width=6em, text centered, rounded corners, minimum height=6pt, font=\footnotesize] \tikzstyle{line} = [draw, -latex', font=\footnotesize] \begin{figure} \centering \begin{tikzpicture}[node distance = 1.7cm, auto] \footnotesize \tikzset{block/.append style={text width=10em, minimum height=2em}} \node [decision, aspect=8, minimum size=20mm] (evalTotImpact) {$\delta_b\left(b_{\text{cur}},b_{\text{last}}\right)\geq\$max?};
\end{tikzpicture}
\end{figure}

\end{document}

-
Text that is wider than text width and can't be wrapped around to a new line will protrude over the right edge, regardless of align=center or text centered. Do you need all decision nodes in your flow chart to be the same size? If not, you could simply remove the text width key from your style definition, or disable it locally using text width={} in the individual node. If you need to keep the node sizes identical, you could use label=center:<node text> to place the text in the node. –  Jake Nov 15 '12 at 15:59
I don't know what do you really want, but I tell you that the problem comes from de \tikzstyle{decision}...text width=4em, if you change that value you will see that it works well. But as I said, I don't know what do you exactly want. Well, Jake wrote faster (and better) than me. –  Manuel Nov 15 '12 at 16:01
They can be different sizes. I have disabled it locally as you suggested, and that solves it. It seems that I'm not fully understanding the impact of specifying text width. I thought it was directly related to the font width. –  KlaasDC Nov 15 '12 at 16:03
@KlaasDC: text width is used to tell TikZ to pretend that the width of the text in a node is whatever you specify, instead of actually measuring the width of the text. Together with text height and text depth, this can be used to achieve fixed node sizes, unlike minimum height and minimum width, which merely set lower limits: In that case, the text dimensions are still measured and used to increase the node size if necessary. –  Jake Nov 15 '12 at 16:08
@Jake: I see, thank you for the explanation! But (a bit unrelated to the question), what is then the best way to exactly specify font sizes in the node? –  KlaasDC Nov 15 '12 at 16:12

Text that is wider than text width which can't be wrapped around to a new line will protrude over the right edge, regardless of align=center or text centered.
If you don't need all nodes to have the same size, you could simply remove the text width key from your style definition, or disable it locally using text width={} in the individual node. If you need to keep the node sizes identical, you could use label=center:<node text> to place the text in the node.