如何在电路中绘制虚线框?

如何在电路中绘制虚线框?

以下是我尝试过的。

\documentclass[12pt,letterpaper]{article}
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}

\usepackage{tikz}  % for drawing pictures
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{arrows.meta}


\usepackage[siunitx]{circuitikz} % circuit package and  include electrical units in our labels

\begin{document}

\begin{figure}[H]
\centering
\begin{circuitikz}[american,]
\ctikzset{tripoles/mos style/arrows}
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
%\path (0,0) -- (2,0); % bounding box

\draw 
(-3,9)  -- (3,9) node[label=right: $V_{dd} \SI{}{}$] {}

(2,4) to [resistor, a^ = $R_{D2}$] (2,1)

(-2,9) to [resistor, a^ = $R_{D1}$] (-2,5.5)

(-2,3.5) to [resistor, a^ = $R_{S}$] (-2,1.5)

(-2,1.5) to (-2,1) node[ground](GND){} 

(-2,4.5) -- (-2,3.5)


(2,9) -- (2,6.5)
(2,6) node[pmos] (M2) {$M_2$} 
%(0,5) node[anchor=east] {$V_{bias}$}[short, o-] to (M2.gate) node[] {}
%(M2.source) node[] {} -- (M1.drain) node[] {}
(M2.drain) node[right] {} -- (2,4) to  [short, *-o, name=S] ++ (2,0) node[right]{$V_{out}$}
(2,1) node[ground](GND){}


(-2,5) node[nmos] (M1) {$M_1$}
(-4,5)  [short, o-]  node[left]{$V_{in}$} to (M1.gate) ;

\draw (-2,4)[short, *-] to [resistor, a^ = $R_{F}$] (2,4);

\draw     (-2,6) to [short,l_=${X}$, *-] (1,6);

     
%\draw  [short, -](5,1) to  [short, *-*, name=S] ++(3,0)node[right]{$V_{out}$};

%\draw  [short, *-] (-2,0) to [resistor, a = $R_2$] (-2,-3);   

%\draw (5,6) to (5,4) node[nmos] (M2) {$M_2$} (5,3) to (5,1);
   

   
   
\end{circuitikz}
\caption{Voltage-Voltage Feedback} \label{fig:volt_volt_loop}
\end{figure}

\end{document}

我从上面的乳胶中得到了这个。

在此处输入图片描述

但是,我不知道如何绘制如下所示的虚线框和文本标签(反馈网络)。

在此处输入图片描述

答案1

这是使用绝对坐标绘制封闭路径的一种方法。使用(某些)相对坐标也更容易制定和修改。

要点:

  • 绘制帮助网格,以便更好地查看您的坐标
  • 使用绘制封闭路径cycle
  • 添加一个名为的样式dbx来格式化框的虚线轮廓
  • 其他一些小的变化,参见% <<<

结果

\documentclass[12pt,letterpaper]{article}
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}

\usepackage{tikz}  % for drawing pictures
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{arrows.meta}


\usepackage[siunitx]{circuitikz} % circuit package and  include electrical units in our labels

\begin{document}

\begin{figure}[]
 \centering
 \begin{circuitikz}[american,
    dbx/.style={dashed, draw}, % <<<
 ]
    \ctikzset{tripoles/mos style/arrows}
    \def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
    %\path (0,0) -- (2,0); % bounding box
    
    \draw 
    (-3,9)  -- (3,9) node[label=right: $V_{dd} \SI{}{}$] {}
    
    (2,4) to [resistor, a^ = $R_{D2}$] (2,1)
    
    (-2,9) to [resistor, a^ = $R_{D1}$] (-2,5.5)
    
    (-2,3.5) to [resistor, a^ = $R_{S}$] (-2,1.5)
    
    (-2,1.5) to (-2,1) node[ground](GND){} 
    
    (-2,4.5) -- (-2,3.5)
    
    
    (2,9) -- (2,6.5)
    (2,6) node[pmos] (M2) {$M_2$} 
    %(0,5) node[anchor=east] {$V_{bias}$}[short, o-] to (M2.gate) node[] {}
    %(M2.source) node[] {} -- (M1.drain) node[] {}
    (M2.drain) node[right] {} -- (2,4) to  [short, *-o, name=S] ++ (2,0) node[right]{$V_{out}$}
    (2,1) node[ground](GND){}
    
    
    (-2,5) node[nmos] (M1) {$M_1$}
    (-4,5)  [short, o-]  node[left]{$V_{in}$} to (M1.gate) ;
    
    \draw (-2,4)[short, *-] to [resistor, a = $R_{F}$] (2,4); % <<<
    
    \draw     (-2,6) to [short,l_=${X}$, *-] (1,6);


    % ~~~ let's see, where the coordinates are (comment out later) ~~~~  
    \draw[teal!30] (0,0) grid (-3,5);
    
    % ~~~ drawing a closed path, here in absolute coords ~~~
    \draw[dbx] (-3,0) -- (-3,4.4) -- (1,4.4) 
                      -- (1,3) -- (-1,3) -- (-1,0) -- cycle;
       
       
 \end{circuitikz}
 \caption{Voltage-Voltage Feedback} \label{fig:volt_volt_loop}
\end{figure}

\end{document}

PS:给盒子贴上标签

  • node在其中一个点后面放一个;这里是第二个,即左门下面
  • 将标签文本放在此处,用于\\换行
  • 添加样式fbt(如格式框文本)
  • anchor东,将文本放在左侧
  • align=center解释\\
  • pos=0.6,在前两点之间偏移 60%
  • font=\bfseries如果你想要粗体字体

请记住,circuitikz是基于 构建的Tikz,因此您仍然可以使用 Tikz 语法和概念。我建议在手册

...
 \begin{circuitikz}[american,
    dbx/.style={dashed, draw}, % <<<
    fbt/.style={anchor=east,align =center,pos=0.6,font=\bfseries},
 ]
...
    % ~~~ drawing a closed path, here in absolute coords ~~~
    \draw[dbx] (-3,0) -- (-3,4.4)node[fbt]{Feedback\\Network}
                      -- (1,4.4) 
                      -- (1,3) -- (-1,3) -- (-1,0) -- cycle;
...

带标签

完整代码:

\documentclass[12pt,letterpaper]{article}
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}

\usepackage{tikz}  % for drawing pictures
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{arrows.meta}


\usepackage[siunitx]{circuitikz} % circuit package and  include electrical units in our labels

\begin{document}

\begin{figure}[]
 \centering
 \begin{circuitikz}[american,
    dbx/.style={dashed, draw}, % <<<
    fbt/.style={anchor=east,align =center,pos=0.6,font=\bfseries},
 ]
    \ctikzset{tripoles/mos style/arrows}
    \def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
    %\path (0,0) -- (2,0); % bounding box
    
    \draw 
    (-3,9)  -- (3,9) node[label=right: $V_{dd} \SI{}{}$] {}
    
    (2,4) to [resistor, a^ = $R_{D2}$] (2,1)
    
    (-2,9) to [resistor, a^ = $R_{D1}$] (-2,5.5)
    
    (-2,3.5) to [resistor, a^ = $R_{S}$] (-2,1.5)
    
    (-2,1.5) to (-2,1) node[ground](GND){} 
    
    (-2,4.5) -- (-2,3.5)
    
    
    (2,9) -- (2,6.5)
    (2,6) node[pmos] (M2) {$M_2$} 
    %(0,5) node[anchor=east] {$V_{bias}$}[short, o-] to (M2.gate) node[] {}
    %(M2.source) node[] {} -- (M1.drain) node[] {}
    (M2.drain) node[right] {} -- (2,4) to  [short, *-o, name=S] ++ (2,0) node[right]{$V_{out}$}
    (2,1) node[ground](GND){}
    
    
    (-2,5) node[nmos] (M1) {$M_1$}
    (-4,5)  [short, o-]  node[left]{$V_{in}$} to (M1.gate) ;
    
    \draw (-2,4)[short, *-] to [resistor, a = $R_{F}$] (2,4); % <<<
    
    \draw     (-2,6) to [short,l_=${X}$, *-] (1,6);


    % ~~~ let's see, wherer the coordinates are (comment out later) ~~~~  
    \draw[teal!30] (0,0) grid (-3,5);
    
    % ~~~ drawing a closed path, here in absolute coords ~~~
    \draw[dbx] (-3,0) -- (-3,4.4)node[fbt]{Feedback\\Network}
                      -- (1,4.4) 
                      -- (1,3) -- (-1,3) -- (-1,0) -- cycle;
       
       
 \end{circuitikz}
 \caption{Voltage-Voltage Feedback} \label{fig:volt_volt_loop}
\end{figure}

\end{document}

相关内容