1

With this simple circuit

\documentclass{article}

\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}[xscale=-1]
% this xscale must be specified also in the opamp

\draw
(0,0) to [R,l^=$R_1$,-*] (3,0)
;

\end{circuitikz}
\end{document}

the resistor is drawn with an horizontal line over it. If I remove the xscale=-1 option, it is correctly drawn instead.

Is this a bug? Can be fixed in any way?

1
  • Not necessarily nice, but not a bug: just the way circuitikz works. What is the use case for specifying xscale=-1 globally? Normally it's just used for those components that need it. Mar 26, 2015 at 21:58

1 Answer 1

1

Not necessarily nice, but not a bug: just the way circuitikz works. Normally xscale=-1 is not used globally but only used for those components that need it (for example to orient op amps and transistors).

If you really need to set xscale=-1 globally, you can revert it for individual components by applying the same scaling again. Note that if you place this key after the component key, you must provide the full key path /tikz/xscale here to escape circuitikz's key namespace:

\documentclass{standalone}

\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}[xscale=-1]
% this xscale must be specified also in the opamp

\draw
(0,1) to [xscale=-1,R,l=$R_1$,-*] (3,1)
% or
(0,0) to [R,/tikz/xscale=-1,l^=$R_1$,-*] (3,0)
;

\end{circuitikz}
\end{document}

enter image description here

Edit: Aha! Now, it becomes clear what you are actually doing. :-)

Another way to show a "mirrored" version of a circuit is to use x=-1cm (or the opposite of whatever your global x setting is—the default is x=1cm). This allows you to use the same code to show a mirrored circuit, without adding extra xscale keys everywhere.

However, this will affect label positions, because you're changing the direction the component is drawn, and the label positions are relative to this direction. You'll need to swap ^ for _ and vice versa anytime a component is drawn along the mirrored axis (here, the x-axis). Labels for components along the non-mirrored axis (here, the y-axis) are not affected and do not need to be changed.

So, depending on your circuit and how picky you are about label positions, this method may or may not result in fewer changes to the code than the first method:

\documentclass{standalone}
\usepackage[american,siunitx]{circuitikz}

\begin{document}
\begin{circuitikz} 
\begin{scope}
  \draw (0,0)
  to[V=1<\volt>] ++(0,2)
  to[R=$R_1$,-*] ++(2,0)
;\end{scope}
\begin{scope}[shift={(5,0)},x=-1cm] % add x=-1cm here and shift to move the mirrored version
  \draw (0,0)
  to[V=1<\volt>] ++(0,2)
  to[R,l_=$R_1$,-*] ++(2,0) % swap label position here; otherwise identical code within the scopes
;\end{scope}
\end{circuitikz}
\end{document}

enter image description here

3
  • Thank you for your explanation. Your example is perfectly related to my answer and is correct. I would like anyway to point out that it won't work if you have a circuit alongside of $R_1$. In that case, in addition to what you explained, it is necessary to change the sign of the x extreme values of the component. So, if you have (3,0) to [R,/tikz/xscale=-1,l^=$R_2$,-*] (6,0) the draw will be correct only if you put (-3,0) to [R,/tikz/xscale=-1,l^=$R_2$,-*] (-6,0).
    – BowPark
    Mar 27, 2015 at 10:05
  • 1
    Of course; because what xscale=1 is doing is reversing the entire coordinate system: if you have other components, you have to make the relative positions correct. I'll ask again: what is the intent of specifying xscale=-1 globally? It shouldn't be needed. If I know what you're trying to do, I might be able to address the problem rather than the symptoms. Mar 27, 2015 at 10:59
  • It was due to the necessity to draw both a circuit and his symmetrical with just (or almost) the same code. Your answer was very useful and the correction of the coordinates, at least in a simple circuit, is not a hard work.
    – BowPark
    Mar 27, 2015 at 11:26

You must log in to answer this question.

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