2

Trying to make a simple tree, but when I finished I realized I'd gone about it totally the wrong way... Would appreciate some help trying to make this the "correct" way. Oh, and also to circle the last 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}

enter image description here

3
  • 1
    You could have a look at the "Making trees grow" section of the TikZ manual. There is a child path action which is better suited to construct trees than using \matrix + edges.
    – Bordaigorl
    May 19, 2015 at 9:26
  • Is this helpful? tex.stackexchange.com/q/106895/4778
    – Alenanno
    May 19, 2015 at 9:51
  • For a second, I thought you were from West Virginia (this is an attempt at American regional humor). May 19, 2015 at 10:20

1 Answer 1

2

With forest it's easy to change how the tree grows. It has a reversed option.

\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}

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.