1

I've stumbled over something I consider strange behavior in circuitikz.

The label distance for a bipole (in this case a lamp) seems to depend on whether the component is drawn from left to right (R) or right to left (L): From right to left, a label below is closer to the component, and a label above farther away, compared to when drawn from left to right.

\documentclass{article}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}
\draw (1,0) to [lamp, l=R] ++(1,0)
            to [lamp, l_=R] ++(1,0);
\draw (4,0) to [lamp, l=L] ++(-1,0);
\draw (1,0) to [lamp, l_=L] ++(-1,0);
\end{circuitikz}

\end{document}

enter image description here

Is this a bug? Does anyone know how to fix this (locally in my code or in general)?

1 Answer 1

1

It is because the upper and lower positions are not equidistant, and when you purposely draw a reversed circuit, you will get the reverted positions, if you draw according to the syntax you will not have problems.

Probably they are not equidistant because the separation must be relative to the text box, that when the text has characters with descender, it separates more, for that reason to compensate, the separation is lower than the below label. What visually should be appropriate for the programmer, but when the direction is inverted should be commuted distances, but that does not happen.

How to fix this, is acustomize package issue, or redefine it, but to be something that happens outside the syntax because I think that for that reason there are direction modifiers such as mirror and invert.

RESULT:

enter image description here

CODE:

\documentclass[border=20pt]{standalone}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}
%Normal sintaxis
\draw[color=blue] (0,0) 
    to [lamp, l=Sup-Lg,i_=i] ++(1.5,0)
    to [lamp, l=Sup-Rg,i=i] ++(1.5,0)
    to [lamp, l_=Inf-Rg,i=i] ++(1.5,0)
    to [lamp, l_=Inf-Lg,i=i] ++(1.5,0)
    to [short] ++(0,2)
    to [lamp, l=Sup-Lg,i=i] ++(-1.5,0)
    to [lamp, l=Sup-Rg,i=i] ++(-1.5,0)
    to [lamp, l_=Inf-Rg,i=i,invert] ++(-1.5,0) %invert command change symbol direction, has no effect in lamp
    to [lamp, l_=Inf-Lg,i=i] ++(-1.5,0);

%Bad sintaxis, that not define a circuit
\draw[color=blue] (1.5,-2)
    to [lamp, l=Sup-Rg,i=i] ++(1.5,0)
    to [lamp, l_=Inf-Lg,i=i] ++(1.5,0);
\draw[color=red] (6,-2)
    to [lamp, l=Sup-Rg,i=i] ++(-1.5,0);
\draw[color=green] (1.5,-2)
    to [lamp, l_=Inf-Lg,i=i] ++(-1.5,0);

%Revision draws
\draw[|-|,orange,thick] (1.2,0) -- ++(0,0.55) node[midway,right=-2pt]{\scriptsize 0.55};
\draw[|-|,orange,thick] (3.8,0) -- ++(0,-0.6) node[midway,right=4pt]{\scriptsize 0.6};
\draw[|-|,orange,thick] (1.2,2) -- ++(0,0.6) node[midway,right=-2pt]{\scriptsize 0.6};
\draw[|-|,orange,thick] (5.5,2) -- ++(0,-0.55) node[midway,right=4pt]{\scriptsize 0.55};

\draw[|-|,orange,thick] (1.2,-2) -- ++(0,0.6) node[midway,right=-2pt]{\scriptsize 0.6};
\draw[|-|,blue,thick] (5.5,-2) -- ++(0,-0.55) node[midway,right=4pt]{\scriptsize 0.55};

\draw[->,orange,thick] (.5,-.5) -- ++(2,0) node[midway,below=-2pt]{\scriptsize normal};
\draw[->,orange,thick] (3.5,.5) -- ++(2,0) node[midway,above=-2pt]{\scriptsize normal};
\draw[->,orange,thick] (2.5,-2) -- ++(1,0) node[midway,above=-2pt]{\scriptsize normal};
\draw[<-,orange,thick] (5,-1.5) -- ++(1,0) node[midway,above=-2pt]{\scriptsize reverse};
\draw[<-,orange,thick] (0.5,-2.5) -- ++(1,0) node[midway,below=-2pt]{\scriptsize reverse};
\draw[<-,orange,thick] (0.5,1.5) -- ++(2,0) node[midway,below=-2pt]{\scriptsize reverse};
\draw[<-,orange,thick] (3.5,2.5) -- ++(2,0) node[midway,above=-2pt]{\scriptsize reverse};

%finally with diodes:
\draw[color=blue](0,-4)
    to [D*,l=Sup-Lg,i=i] ++(1.5,0)
    to [D*,l=Sup-Rg,i=i,invert] ++(1.5,0) % invert has effect, but not in current.
    to [D*,l_=Inf-Lg,i<=i,invert] ++(1.5,0) % i<, is used to change the current.
    to [D*,l_=Inf-Lg,i=i] ++(1.5,0);

\draw[color=blue](1.5,-6)
    to [D*,l=Sup-Lg,i=i] ++(1.5,0)
    to [D*,l_=Inf-Rg,i=i] ++(1.5,0);
\draw[color=green](1.5,-6)
    to [D*,l_=Inf-Lg,i=i] ++(-1.5,0);
\draw[color=red](6,-6)
    to [D*,l=Sup-Lg,i=i] ++(-1.5,0);

\end{circuitikz}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .