我用贝塞尔曲线画了一点tikzpicture
,用于文本中。我注意到它有异常多的水平空白,比圆形还要多:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
Lorem
\begin{tikzpicture}
\coordinate (a) at (-1,2);
\draw (0,0) .. controls (a) and ($2*(a -| 0,0)-(a)$) .. (0,0);
\end{tikzpicture}
ipsum
Lorem
\begin{tikzpicture}
\coordinate (a) at (-1,2);
\draw (0,0) circle [radius=0.4cm];
\end{tikzpicture}
ipsum
\end{document}
我认为白色空间来自controls
贝塞尔曲线语法中使用的坐标:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
Lorem
\begin{tikzpicture}
\coordinate (a) at (-1,2);
\draw (0,0) .. controls (a) and ($2*(a -| 0,0)-(a)$) .. (0,0);
\node[red] at (a) {$\cdot$};
\node[red] at ($2*(a -| 0,0)-(a)$) {$\cdot$};
\end{tikzpicture}
ipsum
\end{document}
但是,仅向圆形图片添加坐标并不能提供额外的空白!这是怎么回事?我该如何避免这种情况?
答案1
基于当我“弯曲”边缘时,Tikz 使用哪种类型的曲线?,您的示例代码可以更改为:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing,shapes.misc}
\tikzset{
show control points/.style={
decoration={show path construction, curveto code={
\draw [blue, dashed]
(\tikzinputsegmentfirst) -- (\tikzinputsegmentsupporta)
node [at end, cross out, draw, solid, red, inner sep=2pt]{};
\draw [blue, dashed]
(\tikzinputsegmentsupportb) -- (\tikzinputsegmentlast)
node [at start, cross out, draw, solid, red, inner sep=2pt]{};
}
},
postaction=decorate
},
}
\begin{document}
Lorem
\begin{tikzpicture}
\coordinate (a) at (-1,2);
\draw[show control points] (0,0) .. controls (a) and ($2*(a -| 0,0)-(a)$) .. (0,0);
\end{tikzpicture}
ipsum
Lorem
\begin{tikzpicture}
\coordinate (a) at (-1,2);
\draw[show control points] (0,0) circle [radius=0.4cm];
\end{tikzpicture}
ipsum
\end{document}
这表明贝塞尔控制点如下:
请注意,TikZ 图形的边界框包含所有控制点。您可以使用以下方法\useasboundingbox
修复此问题:
Lorem
\begin{tikzpicture}
\coordinate (a) at (-1,2);
\useasboundingbox (-.2,0) rectangle (.2,1.5);
\draw[show control points] (0,0) .. controls (a) and ($2*(a -| 0,0)-(a)$) .. (0,0);
\end{tikzpicture}
ipsum
得出的结果是: