The tree below is produced by the code beneath it. In the tree, the parent node is slightly out of alignment. You will notice that the edges to its children are asymmetrical: the one on the left is slightly shorter than the one on the right.
I cannot figure out what is causing this—perhaps it is something to do with the use of nodeparts. How can I ensure that the parent node in this tree will be properly positioned to ensure symmetrical edges?
EDIT: Schrödinger's cat provided an answer which reminds me that I would like the solution to preserve the spaces between different levels of the tree in more complex trees, and to keep the separation between a parent and its child constant even if more branches are added.
For example, in the slightly more complex tree below the spacing between parent and children and between siblings is good, but the same asymmetry can be noticed between the root node and its children, and additionally the lowest node on the tree is connected to its parent by a slanted line when I would like it to be a straight vertical line.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart, positioning}
\usepackage{xinttools}
\usepackage{forest}
\def\numname#1{%
\ifcase#1 \or one\or two\or three\or four\or five\or six\or seven\or eight\or nine\or ten\or eleven \or twelve\or thirteen\or fourteen\or fifteen\or sixteen\or seventeen\or eighteen\or nineteen\or twenty\fi%
}
\newcounter{cellnum}
\newcommand{\tape}[1]{%
\setcounter{cellnum}{1}
\xintFor* ##1 in {#1} \do {%
\nodepart[text width=1.5ex, align=center]{\numname{\value{cellnum}}} $##1$%
\stepcounter{cellnum}%
}
\addtocounter{cellnum}{-1}%
}
\begin{document}
\begin{forest}
for tree={
delay={
content={\tape{#1}}
},
rectangle split,
rectangle split horizontal,
rectangle split parts=\value{cellnum},
rectangle split part align=base,
draw,
l sep=6ex,
s sep=2em,
edge path={
\noexpand\path[draw]
([yshift=-2.5ex]!u.children) -- ([yshift=1ex].parent);
},
head/.style n args=2{
tikz={\node[below=0cm of .\numname{#1} south, font=\scriptsize]{$#2$};}
}
}
[111, head={1}{1}
[0111, head={1}{2}]
[111, head={2}{1}]
]
\end{forest}
\end{document}



anchor=parenttofor treesolves this problem, making this probably a duplicate of https://tex.stackexchange.com/questions/508172/children-misalignment-in-forest. I should have searched more thoroughly before asking. – solisoc Feb 21 '20 at 06:59