This source code works as desired
\usepackage{siunitx} \usepackage{amsmath} \usepackage{circuitikz}
\newcommand{\marknode}[2][45]{%
\node[circle, draw, red, inner sep=1pt, pin={[red,
font=\tiny]#1:#2}] at (#2.center) {}; }
\begin{document}
\begin{figure}[h]
\centering
\begin{circuitikz}
\def\dx{2}
\def\dy{2}
\draw (0,0) node[ground,name=gnd] {}
(gnd) ++(0,\dy) coordinate(a) to[american voltage source,a2=$V_\textsc{s}$ and $\qty{10}{V}$, a2 halign=c,name=Vs] (gnd);
\draw
(a) to[R,l2=$R_1$ and \qty{1}{k\ohm},l2 halign=c,label distance=5pt,name=R1] ++(\dx,0) coordinate(b)
(b) to[C,name=C1,
l2=$C_1$ and \qty{1}{\micro F},l2 halign=c] (b|-gnd)
(b|-gnd) to[short] (gnd)
;
\marknode{R1label}
\draw (R1label) ++(0,1) node[] {$\times$};
% \marknode{Vslabel}
\end{circuitikz} \caption{Test circuit}
\label{fig:test-circuit}
\end{figure}
\end{document}
and produces this result:
However, when I remove the comment symbol in the line with \marknode{Vslabel}
, I get a LaTeX error
--- TeX said ---
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.26 \node (R1label) +
+(0,1) {$\times$};
--- HELP ---
No help available
Strangely, this error refers to the coordinate (R1label), which previously worked fine. It does not refer to the newly referenced coordinate (Vslabel). Despite this error, though, I get the following output:
Notice that the label Vslabel
appears at the top of the ground symbol, not at the center of the $V_\textsc{s}$ symbol. In contrast, the label for $R_1$ appears exactly where I expect it to appear.
It appears that labels for voltage sources are not handled correctly. Is this true? Or is there some other explanation?