Problem mit Subfigure und Circuitikz

Oct 25 2020

Ich habe ein Problem, wenn ich eine Schaltung in eine Subfigur einfügen möchte . Das Problem ist auf ">" und "<", denn wenn ich diese ausziehe, funktioniert der Code!

Ich verwende die folgenden Pakete:

\usepackage{subfigure}

Code:

\begin{figure}[h]
    \centering
    \subfigure[circuit]{
    \begin{circuitikz}[scale=0.75,transform shape]
        \draw   (0,0) coordinate (base)
                (base)  to [R,l=$R_2$]  ++ (0,-3) node[ground]{}
                (base)  to [R,l_=$R_1$] ++ (0,3)
                        to [short,-*]           ++ (2.5,0) coordinate (cole);
        \draw   (base)  to [open]   ++ (2.5,0) node[npn](Q){}
                (base)  to [short,*-, f < = $I_B$]     (Q.B)
                %HERE THE PROBLEM! ("f < =")
                (Q.E)   to [R,l=$R_E$]      ++ (0,-2.25) node [ground]{}
                (Q.C)   to [R,l_=$R_C$] (cole);
        \draw   (cole)  to [short]  ++ (3,0) 
                        to [battery,l=$V_{CC}$]     ++ (0,-6) node[ground]{};
    \end{circuitikz}
    }

\end{figure}

Der Fehler ist:

Argument of \language@active@arg< has an extra }. }

Wenn ich das Paket "Subcaption" setze, ist der Fehler:

Package subcaption Error: This package can't be used in cooperation(subcaption) with the subfigure package. \subcaption@CheckCompatibility

Danke im Voraus!!

Antworten

3 Zarko Oct 25 2020 at 02:00

Sie haben zwei verschiedene Probleme, eines ist die Verwendung eines veralteten Pakets, das andere ist das Schreiben von Schreib- / Syntaxfehlern (das durch die Antwort von @rmano behoben wird). Lassen Sie mich feststellen, dass Sie in Ihrem speziellen Fall bisher keine Probleme mit der Verwendung eines veralteten Pakets haben.

Zunächst haben Sie zwei Möglichkeiten:

  • Verwendung der subfigure:
\documentclass{article}
\usepackage[siunitx, nooldvoltagedirection]{circuitikz}
\usepackage{subfig} % <---

\begin{document}
    \begin{figure}
\subfloat[ subfloat caprion, if needed] 
{
\begin{circuitikz}
\draw   (0,0)   coordinate (aux1)
                to [R=$R_1$]    ++  (0,-3)  coordinate (base)
                to [short,*-,f< = $I_B$]    ++  (2,0)   node[right,npn](Q){}
        (base)  to [R=$R_2$]    ++  (0,-3)  coordinate (aux2)   node [ground]{}
        (aux1)  to [short,*-]   (aux1 -| Q.C)
                to [R=$R_C$]    (Q.C)
        (Q.E)   to [R=$R_E$]    (Q.E |- aux2)  node [ground]{}
(aux1 -| Q.C)   to [short,*-]   ++ (2,0)    coordinate (aux3)
                to [battery,l=$V_{CC}$] (aux3 |- aux2)  node[ground]{};
\end{circuitikz}
}
\caption{Main caption}
    \end{figure}
\end{document}

  • Verwendung der subcaption
\documentclass{article}
\usepackage[siunitx, nooldvoltagedirection]{circuitikz}
\usepackage{subcaption} % <---

\begin{document}
    \begin{figure}
\begin{subfigure}{\linewidth}
    \centering
\draw   (0,0)   coordinate (aux1)
                to [R=$R_1$]    ++  (0,-3)  coordinate (base)
                to [short,*-,f< = $I_B$]    ++  (2,0)   node[right,npn](Q){}
        (base)  to [R=$R_2$]    ++  (0,-3)  coordinate (aux2)   node [ground]{}
        (aux1)  to [short,*-]   (aux1 -| Q.C)
                to [R=$R_C$]    (Q.C)
        (Q.E)   to [R=$R_E$]    (Q.E |- aux2)  node [ground]{}
(aux1 -| Q.C)   to [short,*-]   ++ (2,0)    coordinate (aux3)
                to [battery,l=$V_{CC}$] (aux3 |- aux2)  node[ground]{};
\end{circuitikz}
    \caption{sub figure caption, if needed}
\end{subfigure}
\caption{Main caption}
    \end{figure}
\end{document}

Wo ist dieser besondere Fall der gleiche wie zuvor? Für den Bildcode wird Code aus der @ rmano-Antwort (+1) verwendet.

3 Rmano Oct 25 2020 at 01:10

Der Fehler ist:

Package pgfkeys Error: I do not know the key '/tikz/f <', to which you passed '$I_B$', and I am going to ignore it. Perhaps you misspelled it.

Beachten Sie, dass der Ti k Z-Parser denkt, dass Sie den Schlüssel verwendet haben f <, und dass er ihn nicht erkennt.

Wenn Sie es in den echten Schlüssel ändern f<(kein Leerzeichen), funktioniert es.

\documentclass[border=10pt]{standalone}
\usepackage[siunitx, nooldvoltagedirection]{circuitikz}
\begin{document}
\begin{circuitikz}[scale=0.75,transform shape]
    \draw   (0,0) coordinate (base)
    (base)  to [R,l=$R_2$]  ++ (0,-3) node[ground]{}
    (base)  to [R,l_=$R_1$] ++ (0,3)
    to [short,-*]           ++ (2.5,0) coordinate (cole);
    \draw   (base)  to [open]   ++ (2.5,0) node[npn](Q){}
    (base)  to [short,*-, f< = $I_B$]     (Q.B)
    %HERE THE PROBLEM! ("f < =") is a different key than "f<="
    (Q.E)   to [R,l=$R_E$]      ++ (0,-2.25) node [ground]{}
    (Q.C)   to [R,l_=$R_C$] (cole);
    \draw   (cole)  to [short]  ++ (3,0) 
    to [battery,l=$V_{CC}$]     ++ (0,-6) node[ground]{};
\end{circuitikz}
\end{document}