为什么 tikz 节点有时会偏离中心?

为什么 tikz 节点有时会偏离中心?
\documentclass[tikz]{standalone}
\usepackage{pgfcore}
\usepackage{pgfkeys}
\usetikzlibrary{
  positioning,
  circuits.ee,
  circuits.ee.IEC,
}
\begin{document}
\begin{tikzpicture}[circuit ee IEC,
                    set resistor graphic=var resistor IEC graphic,
                    set diode graphic=var diode IEC graphic,
                    set make contact graphic= var make contact IEC graphic]
  \node[voltage source] (s) {};
  \node[coordinate] (r) [right=30mm of s] {};
  \node[coordinate] (l) [right=20mm of r] {};
  \node[coordinate] (c) [right=20mm of l] {};
  \node (out) [right=10mm of c] {out};
  \node[ground] (g) [below=10mm of c, point down] {};
  \path
      (s) edge [resistor={info=R}] (r)
      (r) edge [inductor={info=L}] (l)
      (l) edge [capacitor={info=C}] (c)
      (c) edge (g)
      (c) edge (out);
\end{tikzpicture}
\end{document}

生成:

偏离中心地面

答案1

使用anchor=west地面节点的选项末端的解决方案是:

\documentclass[tikz, margin=3mm]{standalone}
\usepackage{pgfcore}
\usepackage{pgfkeys}
\usetikzlibrary{
  positioning,
  circuits.ee,
  circuits.ee.IEC,
}
\begin{document}
\begin{tikzpicture}[circuit ee IEC,
                    set resistor graphic=var resistor IEC graphic,
                    set diode graphic=var diode IEC graphic,
                    set make contact graphic= var make contact IEC graphic]
  \node[voltage source] (s) {};
  \node[coordinate] (r) [right=30mm of s] {};
  \node[coordinate] (l) [right=20mm of r] {};
  \node[coordinate] (c) [right=20mm of l] {};
  \node (out) [right=10mm of c] {out};
  \node[ground] (g) [below=10mm of c, point down, anchor=west] {};
  \path
      (s) edge [resistor={info=R}] (r)
      (r) edge [inductor={info=L}] (l)
      (l) edge [capacitor={info=C}] (c)
      (c) edge (g)
      (c) edge (out);
\end{tikzpicture}
\end{document}

在此处输入图片描述

为了进行比较,请参见使用 ciruitikz包绘制的此方案:

\documentclass[margin=3mm]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{positioning}
\begin{document}
    \begin{tikzpicture}[american inductors]
\draw   (0,0)   to  [V]         (2,0) 
                to  [R=R]       (4,0)
                to  [L=L]       (6,0)
                to  [C=C]       (8,0)   coordinate (c)
                to  [short,-o]  (9,0)   node[right] {out}
        (c)     to  [short,*-] +(0,-1)  node[ground] {};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容