CircuiTikz border intrusion
These are just workarounds. I do not think that there is a simple universal solution. You may either shorten the orange line (but this requires you to know the line width of the circle) or draw it on the background. Further alternatives include using an inverse clip.
\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[]{circuitikz}
\usetikzlibrary{backgrounds}
\begin{document}
\section*{Workarounds}
\subsection*{Shorten}
\begin{center}
\begin{circuitikz}[rotate=90,scale=1.5,transform shape]
\draw (-3,-4) node[dcvsourceshape,rotate=90,
label={[label distance=0.25cm]-45:5 V}](Vi){};
\draw[color=orange,shorten <=0.4pt] (Vi.right) -- ++(0,1);
\end{circuitikz}
\end{center}
\subsection*{Use layers}
\begin{center}
\begin{circuitikz}[rotate=90,scale=1.5,transform shape]
\draw (-3,-4) node[dcvsourceshape,rotate=90,
label={[label distance=0.25cm]-45:5 V}](Vi){};
\begin{scope}[on background layer]
\draw[color=orange] (Vi.right) -- ++(0,1);
\end{scope}
\end{circuitikz}
\end{center}
\end{document}
If you use the to
syntax, you can do this:
\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[siunitx, RPvoltages]{circuitikzgit}
\begin{document}
\begin{center}
\begin{circuitikz}[rotate=90,scale=1.5,transform shape]
\draw[color=orange] (0,0) to[dcvsource, color=black, name=A] ++(0,2);
\node [right] at(A.south) {\SI{5}{V}};
\end{circuitikz}
\end{center}
\end{document}
...and by the way, your example discovered a bug --- if I use
to[dcvsource, color=black, l_=\SI{5}{V}]
I have a divide-by-zero error, which is caused by the global rotate
. Now, circuitikz
is not tested with rotations, so strictly is not a bug, but I'll dig into it.
If anybody feels like to help, here is the bug report: https://github.com/circuitikz/circuitikz/issues/344
The better way to rotate a scale a circuitikz
environment is to put it in a box and rotate with rotatebox
:
\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[siunitx, RPvoltages]{circuitikzgit}
\begin{document}
\begin{center}
\rotatebox{90}{%
\begin{circuitikz}[scale=1.5,transform shape]
\draw[color=orange] (0,0)
to[dcvsource, color=black, l_={\color{black}\SI{5}{V}}]
++(0,2);
\end{circuitikz}}
\end{center}
\end{document}