使用 with 时,fit 库似乎缺少了一点transform shape
:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}[]
\node[draw] (a) at (0,0) {A};
\node[draw] (b) at (1,1) {B};
\node[draw] (c) at (-1,1) {C};
\node[draw, red, fit =(a) (b) (c)]{};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.7, transform shape]
\node[draw] (a) at (0,0) {A};
\node[draw] (b) at (1,1) {B};
\node[draw] (c) at (-1,1) {C};
\node[draw, red, fit =(a) (b) (c)]{};
\end{tikzpicture}
\end{document}
结果(版本 3.0.1a,随 Ubuntu 18.04LTS 一起提供)
这是正常的吗?除了手动调整外,还有什么办法可以避免这种情况吗inner sep
?
答案1
最终该问题已在版本中得到修复3.1.3
,并得到了正确的行为。
然而,问题似乎如果你使用,就会回来rotate
,正如所注意到的@薛定谔的猫在评论中(现已删除):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}[]
\node[draw] (a) at (0,0) {A};
\node[draw] (b) at (1,1) {B};
\node[draw] (c) at (-1,1) {C};
\node[draw, red, fit =(a) (b) (c), inner sep=0pt]{};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.7, rotate=45, transform shape]
\node[draw] (a) at (0,0) {A};
\node[draw] (b) at (1,1) {B};
\node[draw] (c) at (-1,1) {C};
\node[draw, red, fit =(a) (b) (c), inner sep=0pt]{};
\end{tikzpicture}
\end{document}
...尽管这是意料之中的,因为手册指出fit
只考虑了北、南、东和西锚点。此行为可以通过以下方法修复:
\node[draw, red, fit =(a) (b) (c)
(a.north west) (a.south west) (a.south east) (a.north east)
(b.north west) (b.south west) (b.south east) (b.north east)
(c.north west) (c.south west) (c.south east) (c.north east),
inner sep=0pt]{};
这使: