在块方案中,我喜欢添加一个带有调用形状的节点,其中包含电子电路的详细信息。使用 circutikz 包可以轻松绘制此电子电路。以下是我为实现这一目标所做的尝试:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning,%
shapes,shapes.callouts%
}
\usepackage{fouriernc}
\usepackage[scaled=0.83]{helvet}
\usepackage[scaled=0.82]{luximono}
\usepackage{marvosym,pifont}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%---------------------------------------------------------------%
\usepackage[european,siunitx]{circuitikz}
\usepackage{siunitx}
\sisetup{detect-family,
color = teal!40!black}
%---------------------------------------------------------------%
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (4,0);
\draw (1,-0.1) -- (1,0.1);
\draw (2,-0.1) -- (2,0.1);
\draw (3,-0.1) -- (3,0.1);
\draw[ultra thick,*-*] (a) -- (b);
\node[shape=rectangle callout,
draw, rounded corners,
callout pointer width=3.3 mm,
callout pointer shorten=-2mm,
font=\sffamily\footnotesize,
align=center,
callout absolute pointer={(b)},
scale=0.5] at ([xshift=19mm,yshift=3mm] b)
{termination circuit\\
\begin{circuitikz}[sharp corners]
\draw[ultra thick, blue] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, blue] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw (0,3) node[right] {\SI{+5}{V}}
to [R=$R_s$,o-] (0,+1) node[right] {A}
to [R=$R_k$,*-*] (0,-1) node[right] {B}
to [R=$R_s$, -o] (0,-3)
node[right] {\SI{0}{V}};
\end{circuitikz}
};
\node[shape=rectangle callout,
draw, rounded corners,
callout pointer width=3.3 mm,
callout pointer shorten=-2mm,
font=\sffamily\footnotesize,
align=center,
callout absolute pointer={(a)},
scale=0.5] at ([xshift=-19mm,yshift=3mm] a)
{termination circuit\\
\begin{circuitikz}[sharp corners]
\draw[ultra thick, blue] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, blue] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw (0,3) node[right] {\SI{+5}{V}}
to [R=$R_s$,o-] (0,+1) node[right] {A}
to [R=$R_k$,*-*] (0,-1) node[right] {B}
to [R=$R_s$, -o] (0,-3)
node[right] {\SI{0}{V}};
\end{circuitikz}
};
\end{tikzpicture}
\end{document}
问题:
- 为什么两个节点不一样(正如我所料);
positioning
如果我使用库提供的节点可能性进行定位,为什么会收到错误“未知函数‘南(在东南)’ ?\node[shape=rectangle callout, draw, rounded corners, callout pointer width=3.3 mm, callout pointer shorten=-2mm, font=\sffamily\footnotesize, align=center, callout absolute pointer={(a)}, scale=0.5, 左上=-19mm 和 3mm 的 a] {节点内容};
编辑:我稍微纠正了一下我的序言,我错误地使用了两次 \usepackage{circuitikz}。第二个应该siunitx
添加设置。我喜欢使用 sans sheriff 字体的电阻标签,但这并没有发生。我不知道为什么不行,但这不是这个问题(另一个问题)。
答案1
circuitikz
您正在节点内使用。circuitikz
环境只不过是tikzpicture
伪装的环境。tikzpicture
在节点内使用node
不是一个好主意,它会导致奇怪的事情。您可以改用节点box
。我创建了\mycircuita
和\mycircuitb
框(带有 0 和 20V)并将它们用于调出节点内。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning,%
shapes,shapes.callouts%
}
\usepackage{fouriernc}
\usepackage[scaled=0.83]{helvet}
\usepackage[scaled=0.82]{luximono}
\usepackage{marvosym,pifont}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%---------------------------------------------------------------%
\usepackage[european,siunitx]{circuitikz}
\usepackage{circuitikz}
%---------------------------------------------------------------%
\newsavebox{\mycircuita}
\sbox{\mycircuita}{%
\begin{circuitikz}[sharp corners]
\draw[ultra thick, blue] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, blue] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw (0,3) node[right] {\SI{+5}{V}}
to [R=$R_s$,o-] (0,+1) node[right] {A}
to [R=$R_k$,*-*] (0,-1) node[right] {B}
to [R=$R_s$, -o] (0,-3)
node[right] {\SI{0}{V}};
\end{circuitikz}
}
\newsavebox{\mycircuitb}
\sbox{\mycircuitb}{%
\begin{circuitikz}[sharp corners]
\draw[ultra thick, blue] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.25*pi:-0.75*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, red] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{+1*sin(2*\x r)});
\draw[ultra thick, blue] plot[smooth,domain=-0.75*pi:-1.25*pi, samples=36] (0.25*pi+\x,{-1*sin(2*\x r)});
\draw (0,3) node[right] {\SI{+5}{V}}
to [R=$R_s$,o-] (0,+1) node[right] {A}
to [R=$R_k$,*-*] (0,-1) node[right] {B}
to [R=$R_s$, -o] (0,-3)
node[right] {\SI{20}{V}};
\end{circuitikz}
}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (4,0);
\draw (1,-0.1) -- (1,0.1);
\draw (2,-0.1) -- (2,0.1);
\draw (3,-0.1) -- (3,0.1);
\draw[ultra thick,*-*] (a) -- (b);
\node[shape=rectangle callout,
draw, rounded corners,
callout pointer width=3.3 mm,
callout pointer shorten=-2mm,
font=\sffamily\footnotesize,
align=center,
callout absolute pointer={(b)},
scale=0.5] at ([xshift=19mm,yshift=3mm] b)
{termination circuit\\
\usebox{\mycircuita}
};
\node[shape=rectangle callout,
draw, rounded corners,
callout pointer width=3.3 mm,
callout pointer shorten=-2mm,
font=\sffamily\footnotesize,
align=center,
callout absolute pointer={(a)},
scale=0.5] at ([xshift=-19mm,yshift=3mm] a)
{termination circuit\\
\usebox{\mycircuitb}
};
\end{tikzpicture}
\end{document}
另外,您也可以使用pic
设施,tikz
但在这种情况下使用box
更简单。