I know that this answer will give me one of that creepy badges... ;-) but we are in Halloween, so why not?
I did a more flexible version of Claudio's ctikz-lx
(to fix some alignment problem in case of long labels) and I think it's my duty to share it. I called it ctikz-ly
.
The packages is here (manual in comments):
\NeedsTeXFormat{LaTeX2e}[1996/06/01]
\ProvidesPackage{ctikz-ly}[2018/10/25 stacked labels for circuitikz]
%
% stacked labels by Romano Giannetti romano@rgtti.com
% heavily based on Claudo Fiandrinos's https://tex.stackexchange.com/a/65792/38080
% \expandafter trick inspired by Matthew Leingang's https://tex.stackexchange.com/a/12272/38080
%
% labels are in a tabular, globally aligned:
% vertically with key ly valign (default c)
% c: center t: top b: bottom
% horizontally with key lx align (default l)
% l: left c: centered r: right
% you can switch sides using ly_=... and ly^=...
% syntax is ly_ = line1 and line2 (same for ly^)
%
\ctikzset{%
ly valign/.store in=\ly@valign, ly valign=c,
ly halign/.store in=\ly@halign, ly halign=l,
}
\ctikzset{ly/.code n args={2}{
\pgfkeys{/tikz/circuitikz/bipole/label/name=%
\bgroup
\setlength{\tabcolsep}{2pt}%
\def\ly@tabu{\tabular[\ly@valign]}%
\expandafter\ly@tabu\expandafter{\ly@halign}%
#1\\ #2%
\endtabular
\egroup
}%
\ctikzsetvalof{bipole/label/unit}{}
\ifpgf@circ@siunitx
\pgf@circ@handleSI{#2}
\ifpgf@circ@siunitx@res
\edef\pgf@temp{\pgf@circ@handleSI@val}
\pgfkeyslet{/tikz/circuitikz/bipole/label/name}{\pgf@temp}
\edef\pgf@temp{\pgf@circ@handleSI@unit}
\pgfkeyslet{/tikz/circuitikz/bipole/label/unit}{\pgf@temp}
\else
\fi
\else
\fi
}}
\ctikzset{ly^/.style args={#1 and #2}{
ly={#1}{#2},
\circuitikzbasekey/bipole/label/position=90 }
}
\ctikzset{ly_/.style args={#1 and #2}{
ly={#1}{#2},
\circuitikzbasekey/bipole/label/position=-90 }
}
\endinput
and a MWE using it, showing several combinations:
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, oldvoltagedirection]{circuitikzgit}
\usepackage{ctikz-ly}
\ctikzset{tripoles/mos style/arrows, bipoles/thickness=1, }
\makeatletter
\makeatother
\begin{document}
\begin{circuitikz}[ american, ]
%
% default is ly halign=l, ly valign=c
%
\begin{scope}[color=blue]
\draw (0,0) to[R, ly_=$R_{CC}$ and \SI{4.7}{k\ohm}, , ly valign=t] (3,0);
\draw (0,0) to[R, ly_=$R_{CC}$ and \SI{4.7}{k\ohm}, , ] (0,3);
\draw (0,0) to[R, ly_=$R_{CC}$ and \SI{4.7}{k\ohm}, ly halign=c, ly valign=b] (-3,0);
\draw (0,0) to[R, ly_=$R_{CC}$ and \SI{4.7}{k\ohm}, ly halign=r, ly valign=c] (0, -3);
\end{scope}
\begin{scope}[xshift=6cm, color=red]
\draw (0,0) to[R, ly^=$R_{CC}$ and \SI{4.7}{k\ohm}, ly halign=c, ly valign=b] (3,0);
\draw (0,0) to[R, ly^=$R_{CC}$ and \SI{4.7}{k\ohm}, ly halign=c, ] (0,3);
\draw (0,0) to[R, ly^=$R_{CC}$ and \SI{4.7}{k\ohm}, , ly valign=t] (-3,0);
\draw (0,0) to[R, ly^=$R_{CC}$ and \SI{4.7}{k\ohm}, ly halign=c, ly valign=t](0, -3);
\end{scope}
\end{circuitikz}
\end{document}
which results in:

\newcommand*{\MyLabel}[3][1cm]{\parbox{#1}{\centering #2 \\ #3}}
, and then use it as ` l_=\MyLabel{$R_1$}{\SI{510}{\ohm}}`.\newcommand*{\tlab}[1]{\parbox{1cm}[b]{\centering #1}}
for labels above the element, however[b]
specification makes problem. Any advice?\documentclass
and the appropriate packages that reproduces the problem, especially on such an old comment. But, I think your issue is that that optional parameter[b]
needs to be before the width specification. So you want\parbox[b]{}...