TransWikia.com

Knot gap disappears in a very small TikZ picture with knots library

TeX - LaTeX Asked on December 31, 2021

I am trying to imitate a fancy break, but using three interlocked circles. Unfortunately, the knot gap disappears, whether I scale the TikZ picture down, or draw it of an already small size. Is it possible to preserve a visible knot gap in this scenario?

documentclass{memoir}
usepackage{tikz}
usetikzlibrary{knots}

begin{document}

defrings{
begin{tikzpicture}[knot gap=0.1pt]
begin{knot}[
    %draft mode=crossings ,
%    clip width=3,
    flip crossing/.list={1,3},
    ]
    strand [line width=0.7pt, black] (0,0) ellipse (3.2pt and 2.2pt);%circle (1.0cm);
    strand [line width=0.7pt, black] (4pt,0) ellipse (3.2pt and 2.2pt);%circle (1.0cm);
    strand [line width=0.7pt, black] (8pt,0) ellipse (3.2pt and 2.2pt);%circle (1.0cm);
end{knot}
end{tikzpicture} 
}

fancybreak{rings}

defringsA{
begin{tikzpicture}[scale=0.1,knot gap=8pt]
begin{knot}[
    %draft mode=crossings ,
    clip width=3,
    flip crossing/.list={1,3},
    ]
    strand [line width=0.7pt, black] (0,0) ellipse (1.2 and 0.8);%circle (1.0cm);
    strand [line width=0.7pt, black] (1.5,0) ellipse (1.2 and 0.8);%circle (1.0cm);
    strand [line width=0.7pt, black] (3,0) ellipse (1.2 and 0.8);%circle (1.0cm);
end{knot}
end{tikzpicture} 
}

fancybreak{ringsA}

fancybreak{***}

end{document}

enter image description here

2 Answers

So I'm learning stuff about my own package here ...

I didn't really consider that people would use the knots library to draw really small diagrams so although it is possible to do so, I appear to have not made it all that easy! In particular, it appears that I put a few things in which are relevant here but didn't bother documenting them!

There are a variety of factors that come into play when the knots library redraws a crossing. The over-path is redrawn twice, once thickly at the background colour to cut out the under-path and then again redrawn as the path. Both of these are clipped by circles so that they only render near the crossing, but the radii of the circles are slightly different so that the over-path blends nicely with the existing path. By default, the over-path is clipped to a circle of 2pt bigger than the wipe-out path, and this is maintained when the clip radius is changed. This is normally not a problem because 2pt is usually small enough to be unnoticeable, but when the diagram is so small that 2pt is significant then it needs changing. This is possible, but isn't documented: there is a key clip draw radius which overrides the radius of the clip circle for the over-path.

The other place that small dimensions come in is where intersections occur near to end points of a path. This can be triggered by false intersections so there is a key that says "if an intersection is within this distance of an end point, ignore it as it is probably false". Again, this is set to something small but on a diagram this small then it needs to be even smaller.

Lastly, these dimensions don't respect any scaling on the tikzpicture so need to be viewed as being absolute dimensions rather than relative. That's why the various settings are the same for both your pictures below.

Incidentally, if using these frequently in your document then I would store then in a box and reuse that box. This saves repeating all the computation effort.

documentclass{memoir}
%url{https://tex.stackexchange.com/q/554924/86}
usepackage{tikz}
usetikzlibrary{knots}

begin{document}

defrings{
begin{tikzpicture}
begin{knot}[
    clip radius=1.8pt,
    clip draw radius=1.9pt,
    end tolerance=2pt,
    clip width=3,
    flip crossing/.list={1,3},
    ]
    strand [line width=0.7pt, black] (0,0) ellipse (3.2pt and 2.2pt);%circle (1.0cm);
    strand [line width=0.7pt, black] (4pt,0) ellipse (3.2pt and 2.2pt);%circle (1.0cm);
    strand [line width=0.7pt, black] (8pt,0) ellipse (3.2pt and 2.2pt);%circle (1.0cm);
end{knot}
end{tikzpicture} 
}

fancybreak{rings}

defringsA{
begin{tikzpicture}[scale=0.1]
begin{knot}[
    clip radius=1.8pt,
    clip draw radius=1.9pt,
    end tolerance=2pt,
    flip crossing/.list={1,3},
    ]
    strand [line width=0.7pt, black] (0,0) ellipse (1.2 and 0.8);%circle (1.0cm);
    strand [line width=0.7pt, black] (1.5,0) ellipse (1.2 and 0.8);%circle (1.0cm);
    strand [line width=0.7pt, black] (3,0) ellipse (1.2 and 0.8);%circle (1.0cm);
end{knot}
end{tikzpicture} 
}

fancybreak{ringsA}

fancybreak{***}

end{document}

Linked rings as very small diagrams

Answered by Andrew Stacey on December 31, 2021

It looks like a resolution/rounding issue kicking in at the 40% scaling factor.

As a temp workaround, export the knots as a standalone pdf, then includegraphics it (using the graphicx package) with the scale= option as a fancybreak.

knots

I tried different clip and flip crossing settings for experimentation.

The standalone:

documentclass[border=6pt]{standalone}
usepackage{tikz}
usetikzlibrary{knots}


newcommandringsA{
begin{tikzpicture}[scale=1,knot gap=8pt]
begin{knot}[
    %draft mode=crossings ,
    clip width=15,
    flip crossing/.list={2,3},
    ]
    strand [line width=0.7pt, black] (0,0) ellipse (1.2 and 0.8);%circle (1.0cm);
    strand [line width=0.7pt, black] (1.5,0) ellipse (1.2 and 0.8);%circle (1.0cm);
    strand [line width=0.7pt, black] (3,0) ellipse (1.2 and 0.8);%circle (1.0cm);
end{knot}
end{tikzpicture} 
}
begin{document}


ringsA

end{document}

The include:

documentclass{memoir}
usepackage{graphicx}
begin{document}
fancybreak{includegraphics[scale=0.1]{knots_scaledA}}%filename from previous step
fancybreak{***}
end{document}

Answered by Cicada on December 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP