我是 LaTeX 的初学者,正在尝试将其用于工业文档。我正在尝试制作一个小电路来说明一个观点。
然而,我想:
- 添加某种图例,例如“Rc:收缩阻力”。由于文本太长,我觉得应该将其放在侧面,而不是直接放在图表中。我找不到正确的方法。
- 此外,我想在图表的西侧和东侧添加一个文字,可能是垂直的,分别标明“引脚侧”和“插座侧”。
- 我试图用蓝色突出显示“半线圈”电阻,但只有文本是蓝色,而不是电阻本身......可以改进吗?
- 有没有办法使代码更优雅,更灵活/可重用(避免通过使用
foreach
或其他方法手动放置所有维度)? - 当然,欢迎任何其他提示或改进/澄清建议...
这是 MWE
\documentclass[a4paper, oneside,11pt, english]{scrreprt}
\usepackage{tikz}
\usepackage[siunitx]{circuitikz} %------------
\ctikzset{bipoles/length=3em}
\begin{document}
\begin{figure}[H]
\centering
\begin{circuitikz}[scale =1]
\draw [ultra thick] (0,-5)-- (0,2);
\draw (0,1) to[R=Rc] (2,1);
\draw [blue] (2,1) to [R=R half coil] (3,0);
\draw (3,0) to [R=Rc] (6,0);
\draw [blue] (2,-1) to[R=R half coil] (3,0);
\draw (0,-1) to[R=Rc] (2,-1);
\draw [blue](2,-1) to [R=R half coil] (3,-2);
\draw (3,-2) to[R=Rc] (6,-2);
\draw [blue] (2,-3) to[R=R half coil] (3,-2);
\draw (0,-3) to[R=Rc] (2,-3);
\draw [blue] (2,-3) to[R=R half coil] (3,-4);
\draw (3,-4) to[R=Rc] (6,-4);
\draw [ultra thick] (6,-5) -- (6,2);
\end{circuitikz}
\caption{electrical model of a canted coil power contact element}
\end{figure}
\end{document}
答案1
您可以使用(矩形)节点来放置图例。
再次,您可以使用节点添加文本。
您可以将
color=blue
选项传递给电阻器:\draw (2,1) to [R=R h.c.,color=blue] (3,0)
您可以使用
\foreach
,但我认为它在这种特殊情况下并没有太大的贡献。为了避免使用
color=blue
五次(或更多次),我使用了scope
带有选项的。在电路中我使用了
R h.c.
来R half coil
增加可读性,并解释了图例中的含义。
这是您的代码的修改版本:
\documentclass[a4paper, oneside,11pt, english]{scrreprt}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[siunitx]{circuitikz}
\ctikzset{bipoles/length=3em}
\begin{document}
\begin{figure}[H]
\centering
\begin{circuitikz}[scale =1]
% the side lines
\draw [ultra thick] (0,-5)-- (0,2);
\draw [ultra thick] (6,-5) -- (6,2);
% the black resistors
\draw (0,1) to[R=Rc] (2,1);
\draw (3,0) to [R=Rc] (6,0);
\draw (0,-1) to[R=Rc] (2,-1);
\draw (3,-2) to[R=Rc] (6,-2);
\draw (0,-3) to[R=Rc] (2,-3);
\draw (3,-4) to[R=Rc] (6,-4);
% the blue resistors
\begin{scope}[color=blue]
\draw (2,1) to [R=R h.c.] (3,0);
\draw (2,-1) to[R=R h.c.] (3,0);
\draw (2,-1) to [R=R h.c.] (3,-2);
\draw (2,-3) to[R=R h.c.] (3,-2);
\draw (2,-3) to[R=R h.c.] (3,-4);
\end{scope}
% the side messages
\node [anchor=south,rotate=90] at (current bounding box.west) {Pin side};
\node [anchor=north,rotate=90] at (current bounding box.east) {Socket side};
% the legend
\node [rectangle,draw,text width=3cm,align=left] at ( $ (current bounding box.center) + (6,0) $ ) {Rc: constriction resistance \\ R h.c.: R half coil};
\end{circuitikz}
\caption{electrical model of a canted coil power contact element}
\end{figure}
\end{document}