I want to draw tree diagram with Asymptote. But have some problems.

I searched and found 2 hints on the web. http://asymptote.sourceforge.net/FAQ/section4.html http://asymptote.sourceforge.net/doc/Frames-and-pictures.html

Using theese tips, and tried to box and trees.



frame f1;
label(f1, "$\mathbb{N} \models A(0)$", Draw);
add(f1, (0, 5))

frame f2;
label(f2, "$\mathbb{N} \models A(1)$", Draw);
add(f2, (0, 4));

draw(f1 -- f2);

But this doesn't work. Last draw(f1 -- f2); command is wrong.

draw commands need coordinate. But this method is... not smart (for me).

I want to connect 2 boxes. How Can I connect 2 objects?

I found drawtree module in the official tutorials PDF, but it looks difficult to use flexibly(is tree's shape changeable?).

If there is a way of easily using drawtree module, would you tell that?


  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Seamus Feb 11 '16 at 10:00
  • 1
    I find the graph theory module good for this kind of thing. Documentation could be better, but the functionality works for me. github.com/taoari/asy-graphtheory – Jim Hefferon Feb 11 '16 at 12:40
  • Links are good! – kogemochi Feb 18 '16 at 7:24

The following code works as a standalone asymptote script. I haven't used the drawtree module so I can't help you with that. In my code, I am not using frames. Instead, each label is drawn in the default picture.


pair p1 = (0, 5);
pair p2 = (0, 4);


label("$\mathbb{N} \models A(0)$", p1, FillDraw(white, black));
label("$\mathbb{N} \models A(1)$", p2, FillDraw(white, black));

enter image description here

  • Your method is simple and useful! Thank you!But I have an another problem. – kogemochi Feb 17 '16 at 10:59
  • When I change draw(p1--p2) to draw(p1--p2, arrow=Arrow), arrow is not displayed. If the second label is not present, the arrow can be seen. Do you have a solution? – kogemochi Feb 17 '16 at 11:09
  • @kogemochi: The line extends to the middle of the label, so the arrow head is filled over when the label is drawn. The easiest solution might be to use MidArrow instead. – James Feb 17 '16 at 13:44
  • Getting your hint, searched further, draw(p1--p2, arrow=Arrow(position=0.945)) was found. It looks nice for me. Options are difficult... – kogemochi Feb 18 '16 at 7:17

Since alternative methodologies are generally acceptable, I cannot resist providing a forest solution.

math content puts the content of all nodes in maths mode, avoiding the need for $...$. draw draws a border around each node in the tree.

The nodes are automatically connected: parent to child for each parent-child relationship. (Use <node content>, no edge for exceptions.) I've specified l sep to match the unit defined in the original code. This is the minimum distance between levels of the tree. (5cm is a lot.)

forest does not need explicit coordinates. It will automatically format the tree.

\documentclass[tikz, border=10pt, multi]{standalone}
  for tree={
    math content,
    l sep=50mm,
  [\mathbb{N} \models A(0)
    [\mathbb{N} \models A(1)]

alternative solution

To alter the appearance of the tree is very easy. You just alter the preamble of the forest environment.

For example,

   for tree={
    edge={blue, thick, <->},
    math content,
    l sep=50mm,


altered tree

while the specification for the tree itself remains identical

  [\mathbb{N} \models A(0)
    [\mathbb{N} \models A(1)]
  • I didn't know well about tikz. Thank you. – kogemochi Feb 17 '16 at 11:29

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.