I need to draw PQ-trees in LaTeX.
Make all the numbers in the same level at the bottom like the figure above.
Thank you !
I put my existing latex code here:
\documentclass[tikz,convert=false]{minimal}
\usepackage{forest}
\usetikzlibrary{shapes.geometric,patterns}
\usetikzlibrary{arrows.meta, angles}
\forestset{
*|/.style={
parent anchor=south,
for descendants={
edge path={
\noexpand\path[\forestoption{edge}]
(!u.parent anchor-|.child anchor) -- (.child anchor)\forestoption{edge label};
}
}
},
normal width/.initial=.5cm,
normal height/.initial=.3cm,
every forest node/.style={
draw,
minimum width=\pgfkeysvalueof{/forest/normal width},
minimum height=\pgfkeysvalueof{/forest/normal height},
inner sep=+0pt,
anchor=south,
},
rect/.style={
every forest node,
shape=rectangle,
minimum width=(#1)*(\pgfkeysvalueof{/forest/normal width})+(#1+1)*(\forestove{s sep})-(#1)*(\pgfkeysvalueof{/pgf/outer xsep}),
},
rect/.default=3,
ellipse/.style={
every forest node,
shape=ellipse,
minimum width=(#1)*(\pgfkeysvalueof{/forest/normal width})+(#1+1)*(\forestove{s sep})-(#1)*(\pgfkeysvalueof{/pgf/outer xsep}),
},
ellipse/.default=3,
patt/.style args={#1:#2}{
node options={
/tikz/path picture={
\pgfsetfillpattern{north east lines}{black}
\pgfpathrectanglecorners
{\pgfpointlineattime{#1}
{\pgfpointanchor{path picture bounding box}{north west}}
{\pgfpointanchor{path picture bounding box}{north east}}}
{\pgfpointlineattime{#2}
{\pgfpointanchor{path picture bounding box}{south west}}
{\pgfpointanchor{path picture bounding box}{south east}}}
\pgfusepath{fill}
}
}
},
patt/.default=0:1
}
\begin{document}
\begin{forest} for tree={child anchor=north}
[,ellipse=18,*|
[1]
[2]
[3]
[,ellipse=6,*|
[4]
[5]
[6]
[7]
[8]
[9]
]
[10]
[11]
[12]
[, ellipse=6 , *|
[13]
[14]
[15]
[16]
[17]
[18]
]
]
\end{forest}
\end{document}
The result of my code is like this:
The figure I expect is like this:
All the numbers are in the same level at the bottom even if there are more nodes.
It will be better if we can control the size of the nodes and numbers of the pq tree to make the figure more beautiful.Beautiful I don't think the size of my pq tree is very proper.
(After that I will try to generate it automatically everytime by python code myself)
Thank you!
fork down
style in TikZ isn't what you need, if you want to stay with plain TikZ for some reason.