如何繪製兩個不同的地面

如何繪製兩個不同的地面

我想用三條線繪製地面(見圖a.),但在 中circuitikz,地面與四條線相關聯(見圖b.)。我的問題是,是否可以用三行circuitikz或其他線畫​​出漂亮的地面?

在此輸入影像描述

答案1

ground抑制節點中的第四行並不太困難:

\documentclass{article} 
\usepackage{circuitikz}

\makeatletter
\pgfdeclareshape{ground}{
    \anchor{center}{
        \pgfpointorigin
    }
    \behindforegroundpath{      
        \pgf@circ@res@step=\ctikzvalof{monopoles/ground/width}\pgf@circ@Rlen

        \pgfscope       
            \pgfpathmoveto{\pgfpointorigin}
            \pgfpathlineto{\pgfpoint{0pt}{-\pgf@circ@res@step}}
            \pgfusepath{draw}

            \pgfstartlinewidth=\pgflinewidth
            %\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

            \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{-\pgf@circ@res@step}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}}
            \pgfusepath{draw}

            \pgfsetlinewidth{\pgfstartlinewidth}
            \pgfpathmoveto{\pgfpoint{-.8\pgf@circ@res@step}{-1.2\pgf@circ@res@step}}
            \pgfpathlineto{\pgfpoint{.8\pgf@circ@res@step}{-1.2\pgf@circ@res@step}}
            \pgfpathmoveto{\pgfpoint{-.6\pgf@circ@res@step}{-1.4\pgf@circ@res@step}}
            \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@step}{-1.4\pgf@circ@res@step}}
%           \pgfpathmoveto{\pgfpoint{-.4\pgf@circ@res@step}{-1.6\pgf@circ@res@step}}
%           \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@step}{-1.6\pgf@circ@res@step}}
            \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
            \pgfusepath{draw}


            \pgfsetlinewidth{\pgfstartlinewidth}

        \endpgfscope
    }

}
\makeatother

\begin{document}
\begin{circuitikz}
\draw (0,0) node[ground] (g) {};
\end{circuitikz}
\end{document}

在此輸入影像描述

答案2

人們總是可以使用手動繪製它純的kZ:

\documentclass{article}
\usepackage{subcaption}
\usepackage{tikz}
\begin{document}
\begin{figure}[htbp]
    \centering
    \begin{subfigure}[t]{2cm}
        \centering
        \begin{tikzpicture}
            \draw (0,0)--(0,1) (0,1.2)--(0,2.2);
            \draw[thick] (-.3,1.2)--(.3,1.2) (-.3,1)--(.3,1);
            \draw (-.2,0)--(.2,0) (-.125,-.1)--(.125,-.1) (-.05,-.2)--(.05,-.2);
        \end{tikzpicture}
        \caption{}
    \end{subfigure}
    \begin{subfigure}[t]{2cm}
        \centering
        \begin{tikzpicture}
            \draw (0,0)--(0,1) (0,1.2)--(0,2.2);
            \draw[thick] (-.3,1.2)--(.3,1.2) (-.3,1)--(.3,1);
            \draw (-.2,0)--(.2,0) (-.15,-.1)--(.15,-.1) (-.1,-.2)--(.1,-.2) (-.05,-.3)--(.05,-.3);
        \end{tikzpicture}
        \caption{}
    \end{subfigure}
    \caption{}
    \label{fig:my_label}
\end{figure}
\end{document}

在此輸入影像描述

相關內容