如何绘制两个不同的地面

如何绘制两个不同的地面

我想用三条线绘制一个背景(见图 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

总是可以使用以下方法手动绘制纯的Z:

\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}

在此处输入图片描述

相关内容