1

Is it possible to have a circuit as a theorem-definition box, using circuits.ee.IEC or something similar (e.g. CircuiTikZ)?

I want:

  • to have a text inside the circuit,
  • the circuit's width fixed at 0.8\textwidth and
  • the circuit's height as long as it takes to include all the text,

like this:

enter image description here

I can't understand the coding, because the manual is in french. I have also made a code for starting.

\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}

Thanks in advanced!

2
  • Looks like fun! Tcolorbox could be a winner for this :) – cmhughes Jul 6 '19 at 18:49
  • @cmhughes , so is it possible to do it with tcolorbox? How can I do it? – Kώστας Κούδας Jul 6 '19 at 20:51
5

Here's a solution using tcolorbox

enter image description here

You can tweak the positions as you see fit; this version breaks across pages. See tcolorbox documentation for more details.

% 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}
4
  • (+1) Very clever :) – M. Al Jumaily Jul 6 '19 at 23:00
  • @cmhughes , thanks for your answer! I 'm trying to understand your code. 1) I changed semithick to ultra thick, and \footnotesize to normalsize and nothing happens. 2) I can't find how to start with ground and not with line. – Kώστας Κούδας Jul 7 '19 at 7:07
  • 1
    @KώσταςΚούδας I've updated to use scope which addresses your first point. For your second point, if you change near start to at start I think that should get you close :) – cmhughes Jul 7 '19 at 7:36
  • @cmhughes thanks a lot!!! – Kώστας Κούδας Jul 7 '19 at 9:35
1

Or you could just put the theorem into a node. I added a minipage in anticipation of problems with the theorem environment. Otherwise you could simply specify [text width].

Note that labels are not included in the components anchors like (B1.south). Labels are implemented a separate unnamed nodes.

\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}
1
  • thanks a lot! I also prefer the tcolorbox solution, rather than tikz (although I understand it better), because it has problems with long texts. The text goes out of ground limits. – Kώστας Κούδας Jul 8 '19 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.