如果这个问题的答案显而易见,请原谅我。我读过 TikZ 手册,通常人们会用 cycle 来解决这个问题,但 cycle 在电路库中表现得很奇怪。
当我有一条有分叉的电路时,我必须分两步绘制分叉部分。问题是第二条路径实际上从未接触过我所引用的节点上的路径。
这是我的最小工作示例:
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows,circuits.ee.IEC,positioning}
\begin{document}
\begin{tikzpicture}[circuit ee IEC,x=2cm,y=1.5cm,
every info/.style={font=\footnotesize},
small circuit symbols,
set inductor graphic=var inductor IEC graphic,
set diode graphic=var diode IEC graphic,
set make contact graphic= var make contact IEC graphic]
\foreach \contact/\x in {0/0,2/3}
{
\node [contact] (upper contact \contact) at (\x,4) {};
\node [contact] (lower contact \contact) at (\x,0) {};
}
\draw (upper contact 0) to [current direction={near start,info=$I_1$},resistor={info={$\text{R}_1$}},inductor={near end,info={$\text{jX}_1$}}] (upper contact 2);
\draw (upper contact 2) to[inductor={info={$\text{jX}_2$}}] (5,4)
to[resistor={info={$\frac{\text{R}_2}{\text{s}}$}}] (5,0)
to (lower contact 2)
to ++(0,1) node (lower fork) {}
-- ++(-1,0) to[resistor={info={$\text{R}_\text{m}$}}] ++(0,2)
to ++(1,0) node (upper fork) {}
to (upper contact 2);
\draw (upper fork) -- ++(1,0)
to[inductor={info={$\text{jX}_\text{m}$}}] ++(0,-2)
to (lower fork);
\end{tikzpicture}
\end{document}
我可以在现有的线条上画线,并在下降过程中做和上升过程中相同的事情,但就像这个帖子,这似乎只是一个临时解决方案。解决这个问题的正确方法是什么?真的存在“正确方法”吗?
答案1
指定坐标时,不要使用空的\node
s,而要使用\coordinate (<name>)
(或,等效地, )。空节点仍包含一些由and\node [coordinate] (<name>) {}
引起的空白,因此您的线无法正确连接。inner sep
outer sep
在您的代码中,该行
to ++(0,1) node (lower fork) {}
可以替换为
to ++(0,1) coordinate (lower fork)
或者
to ++(0,1) node [coordinate] (lower fork) {}
或者
to ++(0,1) node [inner sep=0pt, outer sep=-\pgflinewidth] (lower fork) {}
我推荐第一个版本。
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows,circuits.ee.IEC,positioning}
\begin{document}
\begin{tikzpicture}[circuit ee IEC,x=2cm,y=1.5cm,
every info/.style={font=\footnotesize},
small circuit symbols,
set inductor graphic=var inductor IEC graphic,
set diode graphic=var diode IEC graphic,
set make contact graphic= var make contact IEC graphic]
\foreach \contact/\x in {0/0,2/3}
{
\node [contact] (upper contact \contact) at (\x,4) {};
\node [contact] (lower contact \contact) at (\x,0) {};
}
\draw (upper contact 0) to [current direction={near start,info=$I_1$},resistor={info={$\text{R}_1$}},inductor={near end,info={$\text{jX}_1$}}] (upper contact 2);
\draw (upper contact 2) to[inductor={info={$\text{jX}_2$}}] (5,4)
to[resistor={info={$\frac{\text{R}_2}{\text{s}}$}}] (5,0)
to (lower contact 2)
to ++(0,1) coordinate (lower fork)
-- ++(-1,0) to[resistor={info={$\text{R}_\text{m}$}}] ++(0,2)
to ++(1,0) coordinate (upper fork)
to (upper contact 2);
\draw (upper fork) -- ++(1,0)
to[inductor={info={$\text{jX}_\text{m}$}}] ++(0,-2)
to (lower fork);
\end{tikzpicture}
\end{document}