1

I'm trying to insert a circuit that I've drawn using circuitikz in a wrapfigure environment, but it gives me some error and it doesn't display the circuit.

Here is a MWE:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{wrapfig}

\usepackage{siunitx}
\usepackage[siunitx]{circuitikz}
\usetikzlibrary{calc,patterns,angles,quotes,intersections,babel,positioning,arrows}

%Galvanometer and rotation ob circuit objects code
\ctikzset{bipoles/galvanometer/height/.initial=.60}
\ctikzset{bipoles/galvanometer/width/.initial=.60}

\ctikzset{bipoles/galvanometer/arrow rotate/.initial=0,
rotation/.style={bipoles/galvanometer/arrow rotate=#1},
}

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/galvanometer/height}}{galvanometer}{\ctikzvalof{bipoles/galvanometer/height}}{\ctikzvalof{bipoles/galvanometer/width}}{
    \def\pgf@circ@temp{right}
    \ifx\tikz@res@label@pos\pgf@circ@temp
        \pgf@circ@res@step=-1.2\pgf@circ@res@up
    \else
        \def\pgf@circ@temp{below}
        \ifx\tikz@res@label@pos\pgf@circ@temp
            \pgf@circ@res@step=-1.2\pgf@circ@res@up
        \else
            \pgf@circ@res@step=1.2\pgf@circ@res@up
        \fi
    \fi

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}       
    \pgfpointorigin \pgf@circ@res@other =  \pgf@x  \advance \pgf@circ@res@other by -\pgf@circ@res@up
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@zero}}
    \pgfusepath{draw}

    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

        \pgfscope
            \pgfpathcircle{\pgfpointorigin}{1.0\pgf@circ@res@up}
            \pgfusepath{draw}       
        \endpgfscope    

    \pgftransformrotate{\ctikzvalof{bipoles/galvanometer/arrow rotate}}% <= magic line
    \pgfsetlinewidth{\pgfstartlinewidth}

    \pgfsetarrowsend{latex}
    \pgfpathmoveto{\pgfpoint{0.7\pgf@circ@res@up}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{0.7\pgf@circ@res@down}{\pgf@circ@res@zero}}
    \pgfusepath{draw}
    \pgfsetarrowsend{}

}

\def\pgf@circ@galvanometer@path#1{\pgf@circ@bipole@path{galvanometer}{#1}}
\compattikzset{galvanometer/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@galvanometer@path}}

\makeatother

\title{Esperimenti di Elettromagnetismo}
\author{Serra Edoardo, Classe V}
\date{August 2018}

\begin{document}

\maketitle

\section*{L'esperimento di Faraday-Neumann-Lenz}
\begin{wrapfigure}[l]{0.55\textwidth}
\begin{circuitikz}
\draw (0,-0.1) to[sinusoidal voltage source] (0,2)
    to[switch] (2,2);
    \draw (3,2) node[transformer] {}
    (0,-0.1) -- (2,-0.1);
    \draw (4.05,-0.1) -- (6.05,-0.1) to[galvanometer, rotation=90] (6.05,2) -- (4.05,2);
\end{circuitikz}
\end{wrapfigure}

%some text
In questo esperimento si riproduce, con strumentazione moderna, l'esperienza di Faraday, descrivendo il risultato mediante l'equazione del moto degli elettroni nel solenoide secondario. L'immagine raffigura il circuito ideale preso in esame: un anello di materiale ferromagnetico, di riluttanza magnetica trascurabile, i cui estremi sono avvolti da due solenoidi, considerabili ideali, di pari densità lineare. Nel circuito primario, il generatore, con resistenza trascurabile, produce una corrente elettrica alternata e, nel circuito secondario, è presente un galvanometro considerabile ideale. Per la legge di FNL, chiudendo il circuito, si genere, nel solenoide secondario, una forza elettromotrice, che genera un campo magnetico indotto di verso opposto a quello del solenoide primario.

\end{document}

I think that the problem lies in the galvanometer and rotation code, because another circuit that I've drown (without a galvanometer or any rotation in it) and inserted in a wrapfigure environment works just fine.

Here is where I've taken the code for the galvanometer and rotating stuff: How to place and rotate a Galvanometer using Circuitikz

Thank you for your help.

3
  • 2
    Replace [l] with {l} in wrapfigure. – John Kormylo Sep 5 '18 at 13:53
  • It worked, it was a dumb spelling error, thank you a lot. – Edoardo Serra Sep 5 '18 at 14:07
  • 4
    I'm voting to close this question as off-topic because it has been answered in the comments. – Rmano Jul 5 '19 at 8:00