是否可以定位circuitikz
节点(例如相对于另一个节点的天线)?例如:
\documentclass[border=1mm,
preview]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{positioning}
\begin{document}
%%%% circuit-positioning
\begin{circuitikz}[node distance=0pt]
\node (bs) [draw,align=center] {base\\station};
\node (a1) [rxantenna] at (bs.east) {};
\node (u1) [draw,align=center,
below right =3mm and 55mm of bs] {user\\1};
\node (a2) [txantenna,left=of u1.west, xscale=-1] {};
\end{circuitikz}
\end{document}
我txanntena
收到错误:
软件包 PGF 数学错误:未知函数‘east’(在‘east’中)
是否仅可能像在 MWE 中那样定位rxantena
?
答案1
当您说 时right=<dimension> of <wherever>
,TikZ 使用方向和<wherever>
以及您正在构建的形状的相关锚点。因此right=of bs.east
使用east
的锚点bs
和west
正在构建的形状的锚点。
这意味着正在构造的形状必须具有合适的锚点,例如,west
但这并不是有效节点形状的必要条件。建议所有节点形状都定义一个center
锚点,但即使这样也不是严格要求的。
这里的问题是,所讨论的天线没有锚点west
或east
。以下是来自的定义circuitikz
:
\pgfdeclareshape{txantenna}{
\anchor{center}{\pgfpointorigin}
\savedanchor{\northeast}{
\pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen
\pgf@x=5\pgf@circ@res@step%-0.5\pgflinewidth
\pgf@y=6\pgf@circ@res@step
}
\anchor{text}{
\northeast
\pgf@x=\ctikzvalof{monopoles/txantenna/label/xanchor}\pgf@x
\pgf@y=\ctikzvalof{monopoles/txantenna/label/yanchor}\pgf@y
}
\behindforegroundpath{
\pgfstartlinewidth=\pgflinewidth
\pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{4\pgf@circ@res@step}{0pt}}
\pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{0pt}}
}
\behindforegroundpath{
\pgfstartlinewidth=\pgflinewidth
\pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{4\pgf@circ@res@step}{0pt}}
\pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{0pt}}
\pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfusepath{draw}
\pgfscope
\pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{5\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{4\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{3\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfusepath{draw}
\endpgfscope
\pgfpathmoveto{\pgfpoint{5.5\pgf@circ@res@step}{6\pgf@circ@res@step}}
% \pgfpatharc{60}{-60}{\pgf@circ@res@step and \pgf@circ@res@step}
\pgfpatharc{30}{-30}{2\pgf@circ@res@step} \pgfpathmoveto{\pgfpoint{6\pgf@circ@res@step}{6.25\pgf@circ@res@step}}
\pgfpatharc{30}{-30}{2.5\pgf@circ@res@step}
\pgfpathmoveto{\pgfpoint{6.5\pgf@circ@res@step}{6.5\pgf@circ@res@step}}
\pgfpatharc{30}{-30}{3\pgf@circ@res@step}
\pgfpathmoveto{\pgfpoint{7\pgf@circ@res@step}{6.75\pgf@circ@res@step}}
\pgfpatharc{30}{-30}{3.5\pgf@circ@res@step}
\pgfpathmoveto{\pgfpoint{7.5\pgf@circ@res@step}{7\pgf@circ@res@step}}
\pgfpatharc{30}{-30}{4\pgf@circ@res@step}
\pgfusepath{draw}
\pgfsetlinewidth{\pgfstartlinewidth}
}
}
\pgfdeclareshape{rxantenna}{
\anchor{center}{\pgfpointorigin}
\savedanchor{\northeast}{
\pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen
\pgf@x=5\pgf@circ@res@step%-0.5\pgflinewidth
\pgf@y=6\pgf@circ@res@step
}
\anchor{text}{
\northeast
\pgf@x=\ctikzvalof{monopoles/rxantenna/label/xanchor}\pgf@x
\pgf@y=\ctikzvalof{monopoles/rxantenna/label/yanchor}\pgf@y
}
\behindforegroundpath{
\pgfstartlinewidth=\pgflinewidth
\pgf@circ@res@step=\ctikzvalof{monopoles/rxantenna/width}\pgf@circ@Rlen
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{4\pgf@circ@res@step}{0pt}}
\pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{0pt}}
\pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfusepath{draw}
\pgfscope
\pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{5\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{4\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{3\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfusepath{draw}
\endpgfscope
\pgfpathmoveto{\pgfpoint{6\pgf@circ@res@step}{7\pgf@circ@res@step}}
% \pgfpatharc{60}{-60}{\pgf@circ@res@step and \pgf@circ@res@step}
\pgfpatharc{150}{210}{4\pgf@circ@res@step} \pgfpathmoveto{\pgfpoint{6.5\pgf@circ@res@step}{6.75\pgf@circ@res@step}}
\pgfpatharc{150}{210}{3.5\pgf@circ@res@step}
\pgfpathmoveto{\pgfpoint{7\pgf@circ@res@step}{6.5\pgf@circ@res@step}}
\pgfpatharc{150}{210}{3\pgf@circ@res@step}
\pgfpathmoveto{\pgfpoint{7.5\pgf@circ@res@step}{6.25\pgf@circ@res@step}}
\pgfpatharc{150}{210}{2.5\pgf@circ@res@step}
\pgfpathmoveto{\pgfpoint{8\pgf@circ@res@step}{6\pgf@circ@res@step}}
\pgfpatharc{150}{210}{2\pgf@circ@res@step}
\pgfusepath{draw}
\pgfsetlinewidth{\pgfstartlinewidth}
}
}
可以看出,这些形状仅定义了center
和text
。因此,不能使用依赖于其他锚点的定位。