When making boxed nodes in TikZ, a common requirement is that the nodes be of equal size. Because TikZ automatically adjusts the size of nodes to fit the contents of the node, this is usually done by setting a minimum size for the nodes, and setting the inner sep
to 0.
How can I do the same thing for the parts of multipart nodes? As the following example shows, setting a minimum size for a multipart node only sets the height (as described in the manual). So how do I make each part be the same size as my non-split nodes?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usepackage[margin=1in]{geometry}
\parindent=0pt
\begin{document}
\tikzset{
every node/.style={draw, minimum size=4ex,inner sep=0pt},
split/.style={rectangle split, rectangle split parts=2,draw,inner sep=0ex,
rectangle split horizontal,rectangle split part align=base,minimum size=4ex}}
\begin{tikzpicture}
\node at (0,0) {A} ;
\node at (1,0) {a} ;
\node at (2,0) {X} ;
\node at (3,0) {j} ;
\node at (4,0) {};
\node[split] at (5,0) {};
\node[split] at (6,0) {X\nodepart{two}j};
\end{tikzpicture}
\end{document}
Best Answer
I updated my answer with the idea from Caramdir's comment. This method is used in the tutorial "Diagrams as Simple Graphs" of the pgfmanual.
Update With
text width=4ex
it's better to use Polgab'method :align=center
instead of\hfil ...\hfil