TeX - LaTeX Asked on May 17, 2021
I have this tree:
That was created with this code:
begin{figure}[h]
centering
begin{tikzpicture}
node[circle,draw]{}
child{
node[circle,draw]{a}
}
child[missing]{};
end{tikzpicture}
end{figure}
How do I increase the size of the root circle so that, even when empty, it looks like the bottom circle? Or is there a better way to create these trees?
With use of the forest
package:
documentclass[margin=3mm]{standalone}
usepackage{forest}
begin{document}
begin{forest}
for tree = {circle,
draw,
minimum size=1.1em,
inner sep=2pt,
font=small,
l sep=9mm,
s sep=6mm
}
[
[a]
[, coordinate, no edge]
]
end{forest}
end{document}
Correct answer by Zarko on May 17, 2021
Welcome to the TeX.SE community. I will use, as a fast solution an hack, putting into node[circle,draw]{...}
a phantom character: phantom{small a}
.
documentclass[a4paper,12pt]{article}
usepackage{tikz}
usepackage{graphicx}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}
node[circle,draw]{phantom{small a}}
child{
node[circle,draw]{a}
}
child[missing]{};
end{tikzpicture}
end{figure}
end{document}
Answered by Sebastiano on May 17, 2021
You can simply define the size of the tree nodes to have a minimum. Since it's likely that the majority of your nodes will also be drawn as circles, and you may have more than one tree that looks like this, it makes sense to create a global style for re-use including all of those parameters.
If you're drawing a lot of trees, I would strongly recommend switching to forest
. The base TikZ tree drawing tools are really not very usable: their syntax is very clunky and they do no automatic node packing.
documentclass[a4paper,12pt]{article}
usepackage{tikz}
tikzset{my tree/.style={every node/.style={draw,circle,minimum size=1.5em}}}begin{document}
begin{tikzpicture}[my tree]
node{}
child{
node{a}
}
child[missing]{};
end{tikzpicture}
end{document}
Answered by Alan Munn on May 17, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP