4

How could I avoid the wire being drawn over the pin like this?

enter image description here

I just scaled the circuit over 1 (scale=1.5), and know some wires overlap some elements. You can see at the above image that the orange wire is drawn over the voltage source.

Here is an example where this happens, zoom in a little bit.

\documentclass[a4paper,12pt]{article}

\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[]{circuitikzgit}

\begin{document}

\begin{center}
    \begin{circuitikz}[rotate=90,scale=1.5,transform shape]
    \draw (-3,-4) node[dcvsourceshape,rotate=90,label={[label distance=0.25cm]-45:\tt 5 V}](Vi){};
    \draw[color=orange] (Vi.right) -- ++(0,1);
    \end{circuitikz}
\end{center}    

\end{document}

As you can see I have used the last release of CircuiTikz, this is were you can get it.

ElSabio
  • 361
  • This code is up to 240 lines, but I will edit the question and add some code where this particular conection between the wire and the voltage source happens. Thanks. – ElSabio Jan 07 '20 at 22:24
  • 2
    yeez where are my manners? of course I am willing to write right now some MWE. On its way it is. – ElSabio Jan 07 '20 at 22:30
  • 2
    You can work around the problem using \draw[color=orange,shorten <=0.4pt] (Vi.right) -- ++(0,1);. I do not believe that this problem can be completely solved. Yes, one could place the anchors differently. But then there would be small gaps showing up because the contour of the circle is curved. The only thing that I could think of is some inverse clip or drawing the orange line on the background layer. None of these will be easy to implement in a fully automatic way. –  Jan 08 '20 at 00:39

3 Answers3

3

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}

enter image description here

2

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}

enter image description here

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

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125
0

Not an answer, but why does the line width decrease with the background layer?

enter image description here

ElSabio
  • 361