3

I want to rotate the label of a resistor by 90°, but the alignment is off. How can I use a rotatebox and vertically center the rotated label at the resistor symbol?

MWE result vs. what I want to achieve: the mwe resultmy desired result

MWE:

\documentclass[margin=5mm]{standalone}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{tikz}
\usepackage[european, straightvoltages,americanvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) to[R={\rotatebox{90}{$R=\SI{50}{\ohm}$}}] (0,2);
\end{circuitikz}
\end{document}
1
  • Welcome! @zarko answer is the right one (as ever). But notice that straightvoltage and americanvoltages are conflicting options; in this case, americanvoltages always wins (independently from the order in which you give them, by the way).
    – Rmano
    Oct 30, 2022 at 17:13

1 Answer 1

4

Try the following:

\documentclass[margin=3mm]{standalone}
\usepackage[european, 
            straightvoltages, americanvoltages,
            siunitx]{circuitikz}

\begin{document}
    \begin{circuitikz}
\ctikzset{label/align = rotate}
\draw (0,0) to[R, l=50<\ohm>] (0,2);
    \end{circuitikz}

    \begin{circuitikz}
\draw (0,0) to[R, l=50<\ohm>, label/align = rotate] (0,2);
    \end{circuitikz}

\end{document}

enter image description here

For details see package documentation, subsection 5.1.3 Labels and annotation orientation, page 174 -- 175.

2
  • 1
    Thank you, now the label is centered! Is there any way to rotate the label by 180 degrees? Oct 30, 2022 at 16:51
  • 1
    @MulticolMetallurgist, of course: use a instead of l and change direction of drawing. BTW, answer gives what you ask in question. New problem, please ask new question.
    – Zarko
    Oct 30, 2022 at 17:01

You must log in to answer this question.

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