[Tex/LaTex] Change direction of voltage source arrow in circuitikz

circuitikz

\documentclass[a4paper,12pt, DIV=15]{scrartcl}
% Zeichnen
\usepackage{tikz}
\usepackage{circuitikz}

\begin{document}
    \begin{circuitikz}[european, scale=1]
        \draw
            (0,0) to [voltage source, v=$\underline{U}_{in}$]
            (0,2)
        ;
    \end{circuitikz}
\end{document}

outputOfCode

How do I change the direction of the arrow without changing coordinates?

Best Answer

To determine the direction of the arrow, the package takes into account how the path has been set up.

In the current case you draw the path from (0,0) towards (0,2) hence the arrow points to the last coordinate. To have it in the other direction, thus you may want to use:

\draw
    (0,2) to [voltage source, v=$\underline{U}_{in}$]
    (0,0)
;

This leads to:

enter image description here

If you want to keep the label and the arrow on the left side, you may want to use v_ syntax

\draw
    (0,2) to [voltage source, v_=$\underline{U}_{in}$]
    (0,0)
;

The result:

enter image description here

After the comment from the package author, here it follows an example which shows how to use the different syntax the package provides:

\documentclass[border=10pt]{standalone}
\usepackage{circuitikz} 
\begin{document}
\begin{circuitikz} 
\draw
    (0,0) to [voltage source, v^<=$\underline{U}_{in}$]
    (0,2)
;
\end{circuitikz}
\quad
\begin{circuitikz}
\draw
    (0,0) to [voltage source, v_<=$\underline{U}_{in}$]
    (0,2)
;
\end{circuitikz}
\quad
\begin{circuitikz}
\draw
    (0,0) to [voltage source, v^>=$\underline{U}_{in}$]
    (0,2)
;
\end{circuitikz}
\quad
\begin{circuitikz}
\draw
    (0,0) to [voltage source, v_>=$\underline{U}_{in}$]
    (0,2)
;
\end{circuitikz}
\end{document}

The result:

enter image description here