IMHO the problem is the resulting bounding box of the tikzpicture
not an incompatibility. You could fix this using \useasboundingbox
:
\documentclass{article}
\usepackage{circuitikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{backgrounds}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
\begin{tikzpicture}% circuitikz is also a tikzpicture
% \begin{circuitikz}% but only tikzpicture is externalized.
\draw (0,0) node (N5){}
to [short,o-](2,0)
to[short,*-](4,0)
to[D](4,2)
to[D](4,4)
to[short,-*](2,4) node (N1){}
to[short,-o](0,4) node (O){};
\draw (4,0)
to[short,*-](8,0)
to[D](8,2)
to[D](8,4)
to[short,-*](4,4);
\draw (2,0)
to[Tnpn,n=q2](2,2) node(N2){}
to[Tnpn,n=q1](2,4);
\draw (8,0)
to[short,*-](10,0) node(N4){}
to[Tnpn,n=q4,mirror](10,2)
to[Tnpn,n=q3,mirror](10,4)
to[short,-*](8,4);
\draw
(q1.B) to[short,-o](1,3) node[left]{$Q_1$}
(q2.B) to[short,-o](1,1) node[left]{$Q_2$}
(q3.B) to[short,-o](11,3) node[right]{$Q_3$}
(q4.B) to[short,-o](11,1) node[right]{$Q_4$};
\draw (2,2) to[short,*-*](4,2) to[Telmech=M](8,2) to[short,*-*](10,2) node(N3){};
% adding current
\begin{scope}[on background layer, very thick,decoration = {
markings,
mark = at position 0.05 with {\arrow{>}}}
]
\draw[line width = 3pt, red!40, postaction = {decorate}] (O.north)
-- node[above, red]{$i$} (N1.north east) |- (N3.north west) |-
(N5.north);
\end{scope}
% adding voltage
\draw[line width = 3pt, red!40, ->] (N5) to[out = 150, in = 210]
(O) node[left, red]{$V$};
\useasboundingbox(0,0) rectangle (12,4);% not needed any longer after commenting circuitikz but sometimes useful
% \end{circuitikz}
\end{tikzpicture}
\end{document}
However, if you need a PDF with the picture only, a very simple solution would be to use class standalone
and correct it using option border
:
\documentclass[border={-15mm 3mm 16mm 3mm}]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{backgrounds}
%\usetikzlibrary{external}
%\tikzexternalize
\begin{document}
\begin{tikzpicture}
\begin{circuitikz}
\draw (0,0) node (N5){}
to [short,o-](2,0)
to[short,*-](4,0)
to[D](4,2)
to[D](4,4)
to[short,-*](2,4) node (N1){}
to[short,-o](0,4) node (O){};
\draw (4,0)
to[short,*-](8,0)
to[D](8,2)
to[D](8,4)
to[short,-*](4,4);
\draw (2,0)
to[Tnpn,n=q2](2,2) node(N2){}
to[Tnpn,n=q1](2,4);
\draw (8,0)
to[short,*-](10,0) node(N4){}
to[Tnpn,n=q4,mirror](10,2)
to[Tnpn,n=q3,mirror](10,4)
to[short,-*](8,4);
\draw
(q1.B) to[short,-o](1,3) node[left]{$Q_1$}
(q2.B) to[short,-o](1,1) node[left]{$Q_2$}
(q3.B) to[short,-o](11,3) node[right]{$Q_3$}
(q4.B) to[short,-o](11,1) node[right]{$Q_4$};
\draw (2,2) to[short,*-*](4,2) to[Telmech=M](8,2) to[short,*-*](10,2) node(N3){};
% adding current
\begin{scope}[on background layer, very thick,decoration = {
markings,
mark = at position 0.05 with {\arrow{>}}}
]
\draw[line width = 3pt, red!40, postaction = {decorate}] (O.north)
-- node[above, red]{$i$} (N1.north east) |- (N3.north west) |-
(N5.north);
\end{scope}
% adding voltage
\draw[line width = 3pt, red!40, ->] (N5) to[out = 150, in = 210]
(O) node[left, red]{$V$};
\end{circuitikz}
\end{tikzpicture}
\end{document}
Note: With option tikz
class standalone
does also provide to generate several PDF pages in the same PDF, one for each tikzpicture
. To change the options from page to page, you can use \standaloneconfig
, e.g.,
\standaloneconfig{border={3mm 3mm 3mm 3mm}}
before the corresponding tikzpicture
.
An even simpler suggestion would be to use \documentclass[landscape]{article}
and \pagestyle{empty}
and afterwards use pdfcrop
to cut of the large white margins from the generated PDF. With
pdfcrop --margins 10pt original.pdf
the resulting original-crop.pdf
would be almost the same as shown above.