Crossings not appearing for small knots drawn using TikZ

The problem is most likely due to the fact that your crossings are too close to the ends of two strands, making them fail the "end tolerance" distance test. More on this below.


The knots package does some complicated stuff to try to ensure that it gets all possible intersections. Sometimes, this is over complicated so there are options to turn off some of the more extensive routines - and some aren't enabled by default. To make yours work, you need to add the option ignore endpoint intersections=false option to the knot environment.

Note that you mustn't have a space between the \begin{knot} and the start of the optional environment.

\documentclass{article}
%\url{http://tex.stackexchange.com/q/217719/86}
\usepackage{tikz}
\usetikzlibrary{knots}
\begin{document}
\begin{tikzpicture}[domain=-2:2, scale=0.3]
\begin{knot}[
  clip width=4,
  ignore endpoint intersections=false,
]
\strand (0,2) to [out=down, in=down, looseness=1.8] (1.5,0);
\strand (1.5,0) to [out=up, in=up, looseness=1.8] (0,-2);
\end{knot}
\draw[dashed] (0,0) circle (2cm);
\end{tikzpicture}
\end{document}

Note that in investigating what was going on here, I uncovered a bug or two in the library and updated the version on github.

Update: 2014-12-15 One thing that was puzzling me here was as to why this particular crossing was being affected by the test involved in ignore endpoint intersections since this isn't an endpoint and I thought I'd planned the knot code so that this would never become an endpoint (which can happen as paths get split into pieces). In short, the endpoint test ignores crossings that are considered too close to the ends of strands. The alternative solution in the comments gave the game away. The scale=0.3 makes the diagram so small that just about every point inside it is within the default tolerance of the endpoints of the strands (note that because the path is split in to two strands, there is an endpoint at (1.5,0). Note also that it is possible to use a single strand here using the key consider self intersections but this still has the end point issue.). The solution above works by switching off the "are we close to the end of a strand?" test. An alternative is to make the test more rigorous by decreasing the tolerance. Fortunately, I thought of that when I wrote the original package (though had forgotten it since!) and there is a key end tolerance=<dimen> to refine the test. Thus:

\begin{tikzpicture}[domain=-2:2, scale=.3]
\begin{knot}[
  clip width=4,
  end tolerance=1pt,
]
\strand (0,2) to [out=down, in=down, looseness=1.8]
(1.5,0);
\strand (1.5,0) to [out=up, in=up, looseness=1.8]
(0,-2);
\end{knot}
\draw[dashed] (0,0) circle (2cm);
\end{tikzpicture}

also works.


This works but I have no idea why:

\documentclass[tikz, border=5pt, mult, varwidth]{standalone}
\usetikzlibrary{knots}
\begin{document}
  \begin{tikzpicture}[domain=-2:2, scale=0.3]
    \begin{knot} [clip width=4]
      \strand (0,2) to [out=down, in=down, looseness=1.8] (1.5,0);
      \strand (1.5,0) to [out=up, in=up, looseness=1.8] (0,-2);
      \strand (1.5,0) to [out=up, in=up, looseness=1.8] (0,-2);
    \end{knot}
    \draw[dashed] (0,0) circle (2cm);
  \end{tikzpicture}
\end{document}

knotted

Alternatively, use the knot=colour and knot gap=factor styles:

\documentclass[tikz, border=5pt, mult, varwidth]{standalone}
\usetikzlibrary{knots}
\begin{document}
  \begin{tikzpicture}[domain=-2:2, scale=0.3, knot gap=7]
      \draw [knot=black] (0,2) to [out=down, in=down, looseness=1.8] (1.5,0) ;
      \draw [knot=black] (1.5,0) to [out=up, in=up, looseness=1.8] (0,-2);
    \draw[dashed] (0,0) circle (2cm);
  \end{tikzpicture}
\end{document}

knotted again