1

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:

enter image description here

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:

enter image description here

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?

0

1 Answer 1

1

You are not defining any label for Vs: you are using annotations (with a2=...). So there is no label to refer to...

You can use labels (and move them the other side with l_=... or l^=...) or use Vsannotation to point to the text:


\documentclass{article}
\usepackage{a4wide}

\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{Vsannotation} %%%%<<<<<<<<<<< here
    \end{circuitikz} \caption{Test circuit}
    \label{fig:test-circuit}
\end{figure}
\end{document}
\end{document}

enter image description here

2
  • Thanks for that clarification. That now seems clear from the manual, but somehow I didn't grasp it yesterday. Commented Nov 21, 2023 at 14:38
  • @CharlesB.Cameron If this solves your problem, please accept the answer! thanks!
    – Rmano
    Commented Nov 22, 2023 at 9:42

You must log in to answer this question.

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