루프 인덱스에서 Circuitikz 도트를 어떻게 조절할 수 있습니까?

루프 인덱스에서 Circuitikz 도트를 어떻게 조절할 수 있습니까?

루프의 일부 반복에서만 Circuitikz의 접합점을 사용하려고 하는데 실패합니다.

\documentclass[border=6mm]{standalone}
\usepackage[siunitx, american]{circuitikz}
\begin{document}
\usetikzlibrary{calc}
\begin{tikzpicture}[
    font=\sffamily,
    every node/.style = {align=center}
]
\foreach[count=\i] \x in {0,3}
{
    \ifnum\i=1
    \tikzstyle{maybedot} = []
   \else
    \tikzstyle{maybedot} = [-*]
    \fi
     \draw (\x,0) to [R, l_={$R_\i$}, maybedot] (\x, 3) to [short, maybedot](\x,5);
}

     \draw (-2,0) to [R, l_={$R_0$ \\ noloop}, -*] (-2, 3) to [short, -*](-2,5);


\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

R1에는 정확하게 점이 없지만 R2에는 R0과 같은 점이 있기를 원합니다. 어떻게 하면 작동하게 할 수 있나요? (실제 예제는 더 복잡하며 이런 종류의 작업을 수행하면 반복적인 코드를 많이 절약할 수 있습니다.)

답변1

여기서 문제는 오류에서 알 수 있듯이 \tikzset(기존의 최선의 회피 구문을 사용하더라도) 키 /tikz/-*(화살표)를 설정하고 있다는 것입니다.

prova.tex|20 error| Package pgf Error: Unknown arrow tip kind '*'.
prova.tex|20 error| Package pgf Error: Unknown arrow tip kind '*'.

극의 올바른 키는 /tikz/circuitikz/-*이므로 다음과 같이 작동합니다.

\documentclass[border=6mm]{standalone}
\usepackage[siunitx, american, RPvoltages]{circuitikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[
    font=\sffamily,
    every node/.style = {align=center},
    ]
    \foreach[count=\i] \x in {0,3}
    {
        \ifnum\i=1
            \ctikzset{maybedot/.style={}}
        \else
            \ctikzset{maybedot/.style={-*}}
        \fi
        \draw (\x,0) to [R, l_={$R_\i$}, maybedot] (\x, 3) 
            to [short,  maybedot](\x,5);
    }
    \draw (-2,0) to [R, l_={$R_0$ \\ noloop}, -*] (-2, 3) to [short, -*](-2,5);
\end{tikzpicture}
\end{document}

\if루프 에서 여러 가지를 혼합하는 \foreach것은 매우 위험합니다(여기서 문제는 또 다른 문제였지만). \ifthenelse여기서는 스타일 대신 몇 가지 매크로를 사용하겠습니다 .

\documentclass[border=6mm]{standalone}
\usepackage{ifthen}
\usepackage[siunitx, american, RPvoltages]{circuitikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[
    font=\sffamily,
    every node/.style = {align=center},
    ]
    \foreach[count=\i] \x in {0,3}
    {
        \ifthenelse{\i = 1}{\edef\maybedot{}}{\edef\maybedot{-*}}
        \draw (\x,0) to [R, l_={$R_\i$}, \maybedot] (\x, 3) 
            to [short,  \maybedot](\x,5);
    }
    \draw (-2,0) to [R, l_={$R_0$ \\ noloop}, -*] (-2, 3) to [short, -*](-2,5);
\end{tikzpicture}
\end{document}

로드하지 않으려면 ifthen테스트를 수행하십시오.

\ifnum\i=1\edef\maybedot{}\else\edef\maybedot{-*}\fi

또한 작동합니다.

세 가지 가능한 옵션이 있습니다

관련 정보