移动电路

移动电路

我正在尝试将电路放入文档中,但是坐标工作得不太好。

以下是我正在尝试组织的电路:

在此处输入图片描述

我想将电路移到左边,代码如下:

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage{tikz}  
\usepackage{mathtools}  
\usepackage[american]{circuitikz} 
\usepackage{enumitem}
\usetikzlibrary{shapes,arrows}  
\renewcommand*\contentsname{Contenido} 
\begin{document} 


\begin{circuitikz}   

%Primer circuito
\draw (-6,-1.5) 
to [V, v=$V_i$,invert] (-6,3)
to [short] (-3,3)  
to [diode] (-3,1)   
(-3,3) to [short] (0,3) 
to [battery, label = 1V] (0,1)  
(-3,1) to [R=$1k\Omega $,v = $V_o$] (0,1)  
(0,1) to [R=$2k\Omega$] (0,-1.5) 
(-3,1) to [R=$2k\Omega$] (-3,-1.5) 
(-6,-1.5) to [short] (-3,-1.5) 
(-3,-1.5) to [short] (0,-1.5) 
(-3,-1.5) -- (-3,-1.7) node[ground]{}
; 

%Segundo circuito 

\draw (4,-1.5) 
to [V, v=$V_i$,invert] (4,3) 
to [short] (7,3)  
to [diode] (7,1)   
(7,3) to [short] (10,3) 
to [R=$1k\Omega$] (10,1)  
(7,1) to [diode] (10,1)  
(10,1) to [R=$2k\Omega$, v] (10,-1.5) 
(7,1) to [R=$2k\Omega$] (7,-1.5) 
(4,-1.5) to [short] (7,-1.5) 
(7,-1.5) to [short] (10,-1.5) 
(7,-1.5) -- (7,-1.7) node[ground]{}

;

\end{circuitikz} 
\end{document}

我希望看起来更像这个文档:

在此处输入图片描述

感谢您的帮助!

答案1

我理解,你喜欢并行使用两种电路方案:

在此处输入图片描述

(红线表示文本区域边框)

在绘制电路时使用相对坐标很容易获得。在这种方法中,你只需要确定绘制电路的起点。在以下方案中,我也使用siunitx单位符号:

\documentclass{article}
\usepackage{geometry}
\usepackage[siunitx, american]{circuitikz}
\usetikzlibrary{arrows, shapes}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{center}
    \begin{circuitikz}
%Primer circuito
\draw   (0,0)   coordinate (A)
                to [V=$V_i$,invert] ++ (0, 6)
                to [short]          ++ (2, 0) coordinate (aux1)
                to [diode]          ++ (0,-3) coordinate (aux2)
                to [R=2<\kilo\ohm>]      ++ (0,-3) node[ground]{}
                to [short]  (A)
        (aux1)  to [short]          ++ (2,0)
                to [battery,l=1<\volt>] ++ (0,-3)
                to [R=2<\kilo\ohm>] ++ (0,-3)
                to [short]          ++ (-2,0)
        (aux2)  to [R=1<\kilo\ohm>,v=$V_0$] ++ (2,0)
        ;

%Segundo circuito
\draw   (A) ++ (8,0) coordinate (B) % here is determined starting point of the second circuit
                to [V=$V_i$,invert] ++ (0, 6)
                to [short]          ++ (2, 0) coordinate (aux1)
                to [diode]          ++ (0,-3) coordinate (aux2)
                to [R=2<\kilo\ohm>]      ++ (0,-3) node[ground]{}
                to [short]  (B)
        (aux1)  to [short]          ++ (2,0)
                to [R=1<\kilo\ohm>] ++ (0,-3)
                to [R=2<\kilo\ohm>, v=$V_o$] ++ (0,-3)
                to [short]          ++ (-2,0)
        (aux2)  to [diode] ++ (2,0)
        ;
    \end{circuitikz}
\end{center}
\end{document}

编辑: 在第一个示例中添加了标签缺失的元素,并添加了新示例,其中线条连接用点标记。

\documentclass{article}
\usepackage{geometry}
\usepackage[siunitx, american]{circuitikz}
\usetikzlibrary{arrows, shapes}

\begin{document}
\begin{center}
    \begin{circuitikz}
%Primer circuito
\draw   (0,0)   coordinate (A)
                to [V=$V_i$,invert] ++ (0, 6)
                to [short,-*]       ++ (2, 0) coordinate (aux1)
                to [diode,-*]       ++ (0,-3) coordinate (aux2)
                to [R=2<\kilo\ohm>,-*]      ++ (0,-3) node[ground]{}
                to [short]  (A)
        (aux1)  to [short]          ++ (2,0)
                to [battery,l=1<\volt>,-*] ++ (0,-3)
                to [R=2<\kilo\ohm>] ++ (0,-3)
                to [short]          ++ (-2,0)
        (aux2)  to [R=1<\kilo\ohm>,v=$V_0$] ++ (2,0)
        ;

%Segundo circuito
\draw   (A) ++ (8,0) coordinate (B) % here is determined starting point of the second circuit
                to [V=$V_i$,invert] ++ (0, 6)
                to [short,-*]       ++ (2, 0) coordinate (aux1)
                to [diode,-*]       ++ (0,-3) coordinate (aux2)
                to [R=2<\kilo\ohm>,-*]      ++ (0,-3) node[ground]{}
                to [short]  (B)
        (aux1)  to [short]          ++ (2,0)
                to [R=1<\kilo\ohm>] ++ (0,-3)
                to [R=2<\kilo\ohm>, v=$V_o$] ++ (0,-3)
                to [short]          ++ (-2,0)
        (aux2)  to [diode,-*] ++ (2,0)
        ;
    \end{circuitikz}
\end{center}
\end{document}

在此处输入图片描述

编辑2 纠正了示例序列中的混乱:第二个示例不再嵌套在第一个示例中。

答案2

Z(并circuitikz基于 TiZ)你可以移动任何东西,只要说

\begin{scope}[xshift=<some x shift>,xshift=<some x shift>]
 <contents>
\end{scope}

或者

\begin{scope}[shift={(<delta x>,<delta y>)}]
 <contents>
\end{scope}

所以

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage[american]{circuitikz} 
\usetikzlibrary{arrows}  
\begin{document} 
\begin{circuitikz}   

 %Primer circuito
 \draw (-6,-1.5) 
 to [V, v=$V_i$,invert] (-6,3)
 to [short] (-3,3)  
 to [diode] (-3,1)   
 (-3,3) to [short] (0,3) 
 to [battery, label = 1V] (0,1)  
 (-3,1) to [R=$1k\Omega $,v = $V_o$] (0,1)  
 (0,1) to [R=$2k\Omega$] (0,-1.5) 
 (-3,1) to [R=$2k\Omega$] (-3,-1.5) 
 (-6,-1.5) to [short] (-3,-1.5) 
 (-3,-1.5) to [short] (0,-1.5) 
 (-3,-1.5) -- (-3,-1.7) node[ground]{}
 ; 

 \begin{scope}[xshift=-10cm,yshift=-6cm]
 %Segundo circuito 

  \draw (4,-1.5) 
  to [V, v=$V_i$,invert] (4,3) 
  to [short] (7,3)  
  to [diode] (7,1)   
  (7,3) to [short] (10,3) 
  to [R=$1k\Omega$] (10,1)  
  (7,1) to [diode] (10,1)  
  (10,1) to [R=$2k\Omega$, v] (10,-1.5) 
  (7,1) to [R=$2k\Omega$] (7,-1.5) 
  (4,-1.5) to [short] (7,-1.5) 
  (7,-1.5) to [short] (10,-1.5) 
  (7,-1.5) -- (7,-1.7) node[ground]{}
  ;
 \end{scope}
\end{circuitikz} 
\end{document}

在此处输入图片描述

请注意,您可以通过改变方法避免很多此类情况。我不会讨论所有可能的改进。相反,我将重点介绍 TiZ 特定的单位。我也不会改变这个arrows库,因为你似乎对它给你的东西很满意。不过,我会撒谎来宣传

  1. 相对定位,以及
  2. siunitx

有了这些,代码就变成了

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage[american]{circuitikz} 
\usepackage{siunitx}
\usetikzlibrary{arrows}  
\begin{document} 
\begin{circuitikz}   
 %Primer circuito
 \draw (-6,-1.5) 
 to [V, v=$V_i$,invert] ++ (0,4.5)
 to [short] ++ (3,0)  
 to [diode] ++ (0,-2)   
 ++ (0,2) to [short] ++(3,0) 
 to [battery, label =\SI{1}{\volt}] ++(0,-2)
 ++(-3,0) to [R=\SI{1}{\kilo\ohm},v = $V_o$] ++(3,0)
     to [R=\SI{2}{\kilo\ohm}] ++(0,-2.5) 
 ++(-3,2.5) to [R=\SI{2}{\kilo\ohm}] ++(0,-2.5) 
 ++(-3,0) to [short] ++(3,0)  to [short] ++(3,0) 
 ++(-3,0) -- ++(0,-0.2) node[ground]{}; 

  \draw (-6,-8.5) 
  to [V, v=$V_i$,invert] ++(0,4.5)
  to [short] ++(3,0)
  to [diode] ++(0,-2)
  ++(0,2) to [short]  ++(3,0)
  to [R=\SI{1}{\kilo\ohm}] ++(0,-2)
   ++(-3,0) to [diode] ++(3,0)
     to [R=\SI{2}{\kilo\ohm}, v] ++(0,-2.5) 
  ++(-3,2.5) to [R=\SI{2}{\kilo\ohm}] ++(0,-2.5) 
  ++(-3,0) to [short] ++(3,0) 
     to [short] ++(3,0) 
  ++(-3,0)  -- ++(0,-0.2) node[ground]{};
\end{circuitikz} 
\end{document}

正如您所见,移动电路变得更加简单,因为所有坐标都相对于第一个坐标。我也发现它们更加直观。并且siunitx您可以实现单位的​​一致排版。

相关内容