Asymptote diagrams from a problem statement

Last updated 29 October 2026

Asymptote is a vector graphics language for technical drawings, widely used for geometry figures in LaTeX documents and on mathematics forums. Every figure makegeodiagrams.com makes is drawn by Asymptote from the problem's statement, and the Asymptote source is one of the downloads: you get the code that drew the figure, not an approximation of it. The SVG, PDF and PNG files are Asymptote's own output from that same source.

What the code looks like

The source is cleaned for reading before you see it, and it compiles to the same figure: arcs and angle marks are written with Asymptote's own arc(), and nothing else in the drawing changes. Its shape is always the same:

A small figure, in this shape (a triangle with a cevian and the lengths the problem names):

// Figure
// Asymptote code from makegeodiagrams.com
import geometry;
size(7cm);
defaultpen(fontsize(14pt));

// Pens
pen pointpen  = black + linewidth(4);    // points
pen labelpen  = black + fontsize(14pt);  // point labels
pen segpen    = black + linewidth(0.7);  // segments
pen polypen   = black + linewidth(0.7);  // polygon sides
pen regionpen = rgb(0.976,0.976,0.976);  // shading inside polygons

// Points
pair A = (0, 0);
pair B = (-0.117395, -1.370528);
pair C = (2.199198, -1.370528);
pair D = (0.473683, -1.370528);  // point

// Shading (drawn first, so every line stays on top)
fill(A--B--C--cycle, regionpen);

// Polygons
draw(A--B--C--cycle, polypen);

// Segments, rays and arcs
draw(A--D, segpen);

// Dots
dot(A, pointpen);
dot(B, pointpen);
dot(C, pointpen);
dot(D, pointpen);

// Labels
label("$A$", A + (-0.144156, 0.038627), labelpen);
label("$B$", B + (-0.144156, -0.038627), labelpen);
label("$C$", C + (0.144156, -0.038627), labelpen);
label("$D$", D + (0, -0.142216), labelpen);

Compiling it

Save the code as figure.asy and run Asymptote (free software; apt install asymptote on Debian and Ubuntu, brew install asymptote on a Mac, part of TeX Live elsewhere):

asy -f pdf figure.asy            # figure.pdf
asy -f svg figure.asy            # figure.svg (needs dvisvgm, which TeX Live has)
asy -f png -render=4 figure.asy  # figure.png

Because the code is the figure's own source, the output is the figure you saw on the site: the same points, the same labels in the same places, the same pens.

In a LaTeX document

Two ways, both standard Asymptote practice.

As a picture. Compile to PDF as above and include it with \includegraphics{figure.pdf} (the graphicx package). The labels are TeX mathematics set in Computer Modern, so they match a document in the default fonts; the figure's printed size is the size(…cm) of the source, which you can change before compiling — lines, points and labels keep their printed size, only the drawing grows or shrinks.

Inside the document. With \usepackage{asymptote}, put the code between \begin{asy} and \end{asy} where the figure goes, then run pdflatex, asy on the document-*.asy files LaTeX wrote, and pdflatex again. The figure is then typeset with the document's own fonts and settings. A book with many figures keeps each one's source where it is used, and a change in the text and a change in a figure are edited in one place.

Editing the code

Because the points are variables, additions are one line each: draw(A--D, segpen); draws a new segment, dot(M, pointpen); a new point, draw(circle(O, abs(O - A)), circpen); a circle through A about O. A pen is changed where it is defined — linewidth(1.2), dashed, rgb(0.2, 0.4, 0.8) — and every statement that uses it follows. A label is moved by changing the offset after its point, or removed by deleting its line.

Often it is quicker to make the change on the site and copy the source again: Effects switches the figure to Grayscale for a black-and-white book, the chat adds an object in words, Edit design changes any line, label or mark by hand, and the source you copy is always the source of the version you are looking at.

Where to find it

In the chat, the Asy code button under the figure opens the source with a copy button, and the download menu's SVG, PDF and PNG are compiled from the same source. The Asymptote source comes with the Personal and Pro plans; the plans page has the details, and the questions page answers what else is often asked.