I am trying to draw a factor tree for my elementary students like this.
What are the possible ways / packages to do it efficiently?
I am trying to draw a factor tree for my elementary students like this.
What are the possible ways / packages to do it efficiently?
The context of use the showed image is not entirely clear, so see if the following image is what you after.
The MWE, which produce it, is:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc, chains,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 7mm and 0mm,
start chain = going right,
inner sep=1pt
]
\foreach \i [count=\j] in {5,x,x,x}
\node (n\j) [on chain] {$\i$};
\node (n0) [above = of $(n1)!0.5!(n4)$] {$5x^3$};
\foreach \i in {1,2,3,4}
\draw[-{Straight Barb[scale=0.8]}] (n0) -- (n\i);
\end{tikzpicture}
\end{document}
Edit:
or draw it as tree by use of the forest package:
\documentclass[border=3.141592]{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{forest}
for tree = {
inner sep = 1pt,
math content,
edge = -{Straight Barb[scale=0.8]},
l sep=11pt,
s sep=1pt,
}
[5x^3 [5][x][x][x]]
\end{forest}
\end{document}
A simple code with pstricks:
\documentclass{article}
\usepackage{pst-node, multido}
\begin{document}
\[ \begin{array}{c}
\rnode{C}{5x^3} \\ \\
\rnode{F0}{5}\, \Rnode{F1}{x}\, \Rnode{F2}{x}\, \Rnode{F3}{x}
\end{array}
\psset{nodesep=2pt, linewidth=0.5pt, arrowinset=0.2, linejoin=1}
\multido{\i =0+1}{4}{\ncline{->}{C}{F\i}} \]%
\end{document}