![家谱“出错”](https://linux22.com/image/311694/%E5%AE%B6%E8%B0%B1%E2%80%9C%E5%87%BA%E9%94%99%E2%80%9D.png)
尝试制作一棵简单的树,但当我完成时,我意识到我完全走错了路……如果能得到一些帮助,尝试以“正确”的方式制作它,我将不胜感激。哦,还要圈出最后的 5/3
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{calc,trees,positioning,arrows,fit,shapes,decorations.markings}
\begin{document}
\begin{tikzpicture}
\matrix(m)[matrix of math nodes,column sep=0.5cm,row sep=0.3cm,]{
& & & \dfrac{1}{1} & & & \\
& \dfrac{1}{2} & & & & \dfrac{2}{1} & \\
\dfrac{1}{3} & & \dfrac{3}{2} & & \dfrac{2}{3} & & \dfrac{3}{1} \\
\vdots & & \vdots & & & \dfrac{5}{3} & \vdots \\
};
\draw[->]
(m-1-4)edge(m-2-2)
(m-1-4)edge(m-2-6)
(m-2-2)edge(m-3-1)
(m-2-2)edge(m-3-3)
(m-2-6)edge(m-3-5)
(m-2-6)edge(m-3-7)
(m-3-5)edge(m-4-6);
\end{tikzpicture}
\end{document}
答案1
可以forest
轻松改变树的生长方式。它有一个reversed
选项。
\documentclass{standalone}
\usepackage{forest}
\usepackage{amsmath}
\usepackage{etex}
\begin{document}
\begin{forest}
for tree={edge = ->, reversed}
[$\dfrac{1}{1}$
[$\dfrac{1}{2}$
[$\dfrac{1}{3}$[\vdots]]
[$\dfrac{3}{2}$[\vdots]]]
[$\dfrac{2}{1}$
[$\dfrac{2}{3}$[,phantom][$\dfrac{5}{3}$, draw, circle]]
[$\dfrac{3}{1}$[\vdots]]]]
\end{forest}
\end{document}