假设我们有这个非常简单的最小工作示例(MWE)画一条直线:
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\draw[draw=red, line width=5pt] (-10,6) -- (50,6);
\end{tikzpicture}
\end{document}
结果截图:
TikZ
可以看到,线条已经达到了所期望的布局的左右页面边界。
但是,如果我编辑上面的平均能量损失并添加seam allowance
创建第二条(平行)线,左右页面边框将突然增加:
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections,decorations.pathmorphing}
\begin{document}
\tikzset{%
seam/.style={double distance=\seamallowance,draw},%
seam allowance/.store in=\seamallowance,%
seam allowance=5cm,%
}
\begin{tikzpicture}
\draw[seam, draw=red, line width=5pt] (-10,6) -- (50,6);
\end{tikzpicture}
\end{document}
结果截图:
正如你所看到的,左右两侧出现了那些难看的白色空间。
问题:
我该如何避免这种行为,以便新行不会再在侧面产生任何额外的空白?
答案1
边界框计算的背景描述如下tikz:双线发生移动。
Loop Space 的解决方案在这里也有效,但是您需要添加一段线作为路径,以避免当 tikzpicture 突然没有高度时独立变得混乱:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,decorations.pathmorphing}
\makeatletter
\tikzset{
only coordinates are relevant/.is choice,
only coordinates are relevant/.default=true,
only coordinates are relevant/true/.code={%
\tikz@addmode{\pgf@relevantforpicturesizefalse}},
only coordinates are relevant/false/.code={%
\tikz@addmode{\pgf@relevantforpicturesizetrue}}
}
\makeatother
\begin{document}
\tikzset{%
seam/.style={double distance=\seamallowance,draw,},%
seam allowance/.store in=\seamallowance,%
seam allowance=5cm,%
}
\begin{tikzpicture}
\path[seam,line width=5pt] (10,6); %so that the picture has the correct height ...
\draw[seam, draw=red, line width=5pt,only coordinates are relevant] (-10,6) -- (50,6);
\end{tikzpicture}
\end{document}