非常基础的问题。我正在学习 Tikz 手册来绘制电路。请指导我编译第 547 页给出的示例。Sec47.1.1。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC,positioning,shapes,fit}
\begin{document}
\begin{tikzpicture}[circuit ee IEC,x=3cm,y=2cm,semithick,
every info/.style={font=\footnotesize},
small circuit symbols,
set resistor graphic=var resistor IEC graphic,
set diode graphic=var diode IEC graphic,
set make contact graphic= var make contact IEC graphic]
% Let us start with some contacts:
\foreach \contact/\y in {1/1,2/2,3/3.5,4/4.5,5/5.5}
{
\node [contact] (left contact \contact) at (0,\y) {};
\node [contact] (right contact \contact) at (1,\y) {};
}
\draw (right contact 1) -- (right contact 2) -- (right contact 3)
-- (right contact 4) -- (right contact 5);
\draw (left contact 1) to [diode] ++(down:1)
to [voltage source={near start,
direction info={volt=3}},
resistor={near end,ohm=3}] ++(right:1)
to (right contact 1);
\draw (left contact 1) to [resistor={ohm=4}] (right contact 1);
\draw (left contact 1) to [resistor={ohm=3}] (left contact 2);
\draw (left contact 2) to [voltage source={near start,
direction info={<-,volt=8}},
resistor={ohm=2,near end}] (right contact 2);
\draw (left contact 2) to [resistor={near start,ohm=1},
make contact={near end,info’={[red]$S_1$}}]
(left contact 3);
\draw (left contact 3) to [current direction’={near start,info=$\iota$},
resistor={near end,info={$R=4\Omega$}}]
(right contact 3);
\draw (left contact 4) to [voltage source={near start,
direction info={<-,volt=8}},
resistor={ohm=2,near end}] (right contact 4);
\draw (left contact 3) to [resistor={ohm=1}] (left contact 4);
\draw (left contact 4) to [resistor={ohm=3}] (left contact 5);
\draw (left contact 5) to [resistor={ohm=4}] (right contact 5);
\draw (left contact 5) to [diode] ++(up:1)
to [voltage source={near start,
direction info={volt=3}},
resistor={near end,ohm=3}] ++(right:1)
to (right contact 5);
\end{tikzpicture}
\end{document}
答案1
我猜你是直接从 TikZ 手册中复制粘贴了代码。问题是,这样你就得不到可靠的副本。在你的例子中,两个撇号被错误地复制了。
代替
make contact={near end,info’={[red]$S_1$}}]
经过
make contact={near end,info'={[red]$S_1$}}]
和
\draw (left contact 3) to [current direction’={near start,info=$\iota$},
经过
\draw (left contact 3) to [current direction'={near start,info=$\iota$},
注意不同的单引号(几乎看不见,但字符不同)。