TITLE: How to draw knots with Latex? 
QUESTION [38 upvotes]: I am writing an exam for my students, and the topic is intro knots theory. I have no idea how to put knots into the file, but I know many MO users who can draw amazing diagrams in their papers. 
Can someone please provide some hints on what can be used, preferably with some example codes? I do not need complicated diagrams, just some simple knots and links with few crossings. Thanks in advance.

REPLY [2 votes]: You can draw knots with metapost:
\documentclass{article}
\usepackage{mpgraphics}
\begin{document}
    \begin{mpdisplay}
      for i=0 step 1 until 360:
        pair P;
        P = 2cm* (sind(2*i), cosd(3*i));
        fill fullcircle scaled 4mm shifted P withcolor white;
        draw fullcircle scaled 4mm shifted P;
      endfor;
      picture p;
      p:=nullpicture;
      for i=-180 step 1 until 180:
        pair P;
        P = 2cm* (sind(2*i), cosd(3*i));
        addto p contour fullcircle scaled 4mm shifted P withcolor white;
        addto p doublepath fullcircle scaled 4mm shifted P
          withpen pencircle scaled .5bp;
      endfor;
      clip p to (.5cm,2.5cm) -- (.5cm,1.5cm)--
                (-.5cm,1.5cm) -- (-.5cm,2.5cm)--cycle;
      draw p;
    \end{mpdisplay}
    \end{document}

or use pst-knot package (using postscript).