电路作为定理盒子

电路作为定理盒子

是否可以使用电路作为定理定义框,circuits.ee.IEC或类似的东西(例如CircuiTikZ)?

我想:

  • 在电路内部放置文本,
  • 电路的宽度固定0.8\textwidth
  • 电路的高度与包含所有文本的长度相同,

像这样:

在此处输入图片描述

我看不懂代码,因为手动的是法语。我还制作了一个启动代码。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\begin{document}
\begin{center}
    \begin{tikzpicture}[circuit ee IEC,semithick,
    every info/.style={font=\footnotesize},
    small circuit symbols,
    set resistor graphic=var resistor IEC graphic]
    \draw (0,0) to [ground={near start, rotate=180}] (0,1)
    to [inductor={direction info={info=$L$},info'=$5H$}] (0,3)
    to [break contact={info=$\delta$}] (2,3)
    to [battery={info={[yshift=-1em]+\quad -},info'={$ 120V $}}] (3,3)
    to [resistor={direction info={info=$R$}, info'=$3\Omega$}] (6,3)
    to [capacitor={info'=$C$, info=$3F$}] (6,1)
    to [ground={near end}] (6,0);
        \end{tikzpicture}
\end{center}
\end{document}

先谢谢了!

答案1

这是一个使用的解决方案tcolorbox

在此处输入图片描述

您可以根据需要调整位置;此版本跨页显示。请参阅tcolorbox 文档更多细节。

% arara: pdflatex
\documentclass{article}
\usepackage[many]{tcolorbox}

\usetikzlibrary{circuits.ee.IEC}
\usepackage{lipsum}
\newtcolorbox{circuitbox}{%
    enhanced jigsaw, breakable, % allow page breaks
    frame hidden, % hide the default frame
    overlay={%
    \begin{scope}[circuit ee IEC,ultra thick,
    every info/.style={font=\normalsize},
    small circuit symbols,
    set resistor graphic=var resistor IEC graphic]
      \draw
        % left line
        (frame.south west) to [ground={near start, rotate=180}] (frame.west)
        to [inductor={direction info={info=$L$},info'=$5H$}] (frame.north west)
        % top line
        to [break contact={info=$\delta$}] (frame.120)
        to [battery={info={[yshift=-1em]+\quad -},info={$ 120V $}}] (frame.north)
        % right line
        to [resistor={direction info={info=$R$}, info=$3\Omega$}] (frame.north east)
        to [capacitor={info'=$C$, info=$3F$}] (frame.east)
        to [ground={near end}] (frame.south east);
    \end{scope}
    },
    % paragraph skips obeyed within tcolorbox
    parbox=false,
}
\begin{document}
\begin{circuitbox}
    \lipsum[1]
\end{circuitbox}
\begin{circuitbox}
    \lipsum
\end{circuitbox}
\end{document}

答案2

或者您可以将定理放入节点中。我添加了一个小页面以应对定理环境的问题。否则,您可以简单地指定[text width]

请注意,标签不包含在组件锚点中,如(B1.south)。标签是通过单独的未命名节点实现的。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\begin{document}
\begin{center}
    \begin{tikzpicture}[circuit ee IEC,semithick,
    every info/.style={font=\footnotesize},
    small circuit symbols,
    set resistor graphic=var resistor IEC graphic]
    \draw (0,0) to [ground={near start, rotate=180}] (0,1)
    to [inductor={direction info={info=$L$},info'=$5H$}] (0,3)
    to [break contact={info=$\delta$}] (2,3)
    to [battery={info={[yshift=-1em]+\quad -},info'={$ 120V $},name=B1}] (3,3)
    to [resistor={direction info={info=$R$}, info'=$3\Omega$}] (6,3)
    to [capacitor={info'=$C$, info=$3F$}] (6,1)
    to [ground={near end}] (6,0);
    \node[below=\baselineskip] at (current bounding box.center |- B1.south) {\begin{minipage}{4.5cm}
      There really isn't much room in here, so you might want to increase the dimensions 
      of the circuit.
    \end{minipage}};
    \end{tikzpicture}
\end{center}
\end{document}

相关内容