我正在谈论以下 MWE 的问题:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{knots}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In aliquet pretium purus, eget aliquet tortor lobortis ut.
Phasellus tincidunt elementum blandit.
Phasellus quis dui pretium, accumsan ipsum eu, aliquet
\begin{tikzpicture}[baseline=-0.65ex, scale=0.04]
\begin{knot}[clip width=10, end tolerance=1pt]
\strand[semithick] (-5, -5) [in=left, out=right] to (5,5);
\strand[semithick] ( 5, -5) [in=right, out=left] to (-5,5);
\end{knot}
\end{tikzpicture}
magna. Duis sit amet aliquam tellus, ac tempor justo.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In aliquet pretium purus, eget aliquet tortor lobortis ut.
Phasellus tincidunt elementum blandit.
Phasellus quis dui pretium, accumsan ipsum eu, aliquet
\begin{tikzpicture}[baseline=-0.65ex, scale=0.04]
\begin{knot}[clip width=10]
\strand[semithick] (-5, -5) [in=left, out=right] to (5,5);
\strand[semithick] ( 5, -5) [in=right, out=left] to (-5,5);
\end{knot}
\end{tikzpicture}
magna. Duis sit amet aliquam tellus, ac tempor justo.
\end{document}
我希望实现两个目标:首先,交叉点应该可见(如第一段所示),但结点周围没有不必要的空白(如第二段所示)。这可能吗?在我看来,这个问题使用 TikZ 绘制的小结点没有出现交叉点可能相关。
答案1
该knots
软件包的工作原理是在背景颜色中绘制粗线。虽然这些线不可见,但它们确实占用了空间。在第二个版本中,创建间隙的剪切线也会添加到边界框中。因此,一个简单的解决方案是使用\useasboundingbox
TikZ 命令预定义边界框。
\documentclass{article}
%\url{http://tex.stackexchange.com/q/357540/86}
\usepackage{tikz}
\usetikzlibrary{knots}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In aliquet pretium purus, eget aliquet tortor lobortis ut.
Phasellus tincidunt elementum blandit.
Phasellus quis dui pretium, accumsan ipsum eu, aliquet
\begin{tikzpicture}[baseline=-0.65ex, scale=0.04]
\begin{knot}[clip width=10, end tolerance=1pt]
\strand[semithick] (-5, -5) [in=left, out=right] to (5,5);
\strand[semithick] ( 5, -5) [in=right, out=left] to (-5,5);
\end{knot}
\end{tikzpicture}
magna. Duis sit amet aliquam tellus, ac tempor justo.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In aliquet pretium purus, eget aliquet tortor lobortis ut.
Phasellus tincidunt elementum blandit.
Phasellus quis dui pretium, accumsan ipsum eu, aliquet
\begin{tikzpicture}[baseline=-0.65ex, scale=0.04]
\useasboundingbox (-5,-5) rectangle (5,5);
\begin{knot}[clip width=10, end tolerance=1pt]
\strand[semithick] (-5, -5) [in=left, out=right] to (5,5);
\strand[semithick] ( 5, -5) [in=right, out=left] to (-5,5);
\end{knot}
\end{tikzpicture}
magna. Duis sit amet aliquam tellus, ac tempor justo.
\end{document}
这实际上比第一个占用了更多的空间,因此您可能需要稍微增加边界框以匹配它。我把这个留给你自己去尝试。