I have a problem in TikZ with the vertical alignment of text inside nodes.
With a very minimal example like this:
\usetikzlibrary{arrows,positioning,shapes.geometric}
\begin{tikzpicture}[%
->,
thick, shorten >=1pt,
>=latex,
node distance=7mm,
noname/.style={%
rectangle, rounded corners=9pt,
text width=11em,
text centered,
minimum height=3em,
draw=black!50,fill=black!20
}
]
\node[noname] (configload) {Loads config};
\node[noname] (varsdec) [right=of configload] {New variables};
\path (configload) edge node {} (varsdec);
\end{tikzpicture}
I get this diagram:
which has the text wrongly aligned because of the letter g
in the first box. It can be seen better if we cut this diagram, showing only text:
Which is the parameter I have to set in order to align the text correctly?
Best Answer
This situation is described in Section 5.1 Styling the Nodes of the pgfmanual; one possible solution is to explicitly declare
height
anddepth
for the nodes:Here I add an image showing that now the baseline of the text is aligned:
The red line showing the alignment was obtained by adding
to the example code above.