我不知道是否有类似的问题(我没有找到任何东西)。如果有,请原谅我。也抱歉我的英语不正确。
回答这个问题。这是我的代码:
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenx}
\usepackage{amsmath}
\usepackage[european]{circuitikz}
\begin{document}
\begin{minipage}{.5\linewidth}
\begin{circuitikz}
%
% circuit
%
\draw
(0,0) to [V = $U$] (0,3)
to [short, i = $I$, -*] (3,3) -- (6,3)
to [R = $R_2$, v = $U_2$, i = $I_2$] (6,0) -- (0,0)
(3,3) to [R = $R_1$, v = $U_1$, i = $I_1$, -*] (3,0);
%
% mesh arrows
%
\draw
%
% mesh one (detailed explanation of the implementation)
%
[<-,% direction of the arrow
> = triangle 45,% kind of the arrow end
path picture =% allows ''to paint a picture'' inside of an other ''picture''
{\node[anchor = center]% position of the inner ''picture''
at (path picture bounding box.center)% bordering rectangle, centered inside the arrow (arrow is the outer ''picture'')
{$M_1$};}]% text of the inner ''picture''
(1.75,1)% coordinates of the arrow end
arc% arc-shaped arrow
(-60:% angle of the arrow start
170:% angle of the arrow end
.5);% radius of the arc
%
% mesh two (short implementation)
%
\draw
[<-, > = triangle 45, path picture = {\node [anchor = center] at (path picture bounding box.center) {$M_2$};}] (4.75,1)
arc (-60:170:.5);
%
% mesh three (short implementation)
%
\draw
[<-, > = triangle 45, path picture = {\node [anchor = center, yshift = -15pt] at (path picture bounding box.center) {$M_3$};}] (.25,-.25)
arc (-140:-10:3.75 and 2.5);
\end{circuitikz}
\end{minipage}
\hfill
\begin{minipage}{.45\linewidth}
%
% equations for mesh and knot
%
\begin{align*}
&K : \quad I = I_1 + I_2\\
&M_1: \quad -U = -U_1\Leftrightarrow U = U_1 = R_1I_1\\
&M_2: \quad U_1 = -U_2\\
&M_3: \quad -U = -U_2\Leftrightarrow U = U_2 = R_2I_2
\end{align*}
\end{minipage}
\end{document}
结果如下:
1.网格三的箭头没有沿着电路的边界。
2.方程的位置不太好。
我想要这样的东西(这张图片是用图形程序创建的):
3.我对网格箭头(内部带有文本)的实现方式不满意。还有其他更简单、更优化的方法吗?
提前感谢您的回答和帮助!
答案1
有多种方法可以创建曲线,包括贝塞尔曲线。我还切换到顶部对齐,minipages
并将tikzpicture
基线移到顶部。
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenx}
\usepackage{amsmath}
\usepackage[european]{circuitikz}
\usepackage{showframe}
\begin{document}
\noindent
\begin{minipage}[t]{.5\linewidth}
\begin{circuitikz}[baseline=(current bounding box.north)]
%
% circuit
%
\draw
(0,0) to [V = $U$] (0,3)
to [short, i = $I$, -*] (3,3) -- (6,3)
to [R = $R_2$, v = $U_2$, i = $I_2$] (6,0) -- (0,0)
(3,3) to [R = $R_1$, v = $U_1$, i = $I_1$, -*] (3,0);
%
% mesh arrows
%
\draw
%
% mesh one (detailed explanation of the implementation)
%
[<-,% direction of the arrow
> = triangle 45,% kind of the arrow end
path picture =% allows ''to paint a picture'' inside of an other ''picture''
{\node[anchor = center]% position of the inner ''picture''
at (path picture bounding box.center)% bordering rectangle, centered inside the arrow (arrow is the outer ''picture'')
{$M_1$};}]% text of the inner ''picture''
(1.75,1)% coordinates of the arrow end
arc% arc-shaped arrow
(-60:% angle of the arrow start
170:% angle of the arrow end
.5);% radius of the arc
%
% mesh two (short implementation)
%
\draw
[<-, > = triangle 45, path picture = {\node [anchor = center] at (path picture bounding box.center) {$M_2$};}] (4.75,1)
arc (-60:170:.5);
%
% mesh three (short implementation)
%
\node (mesh3) [below] at (0,0) {\phantom{$M_3$}};% reserve space below circuit for M_3
\draw[->, > = triangle 45,thick] (current bounding box.east)% not the only way, just easy
.. controls (current bounding box.south east) ..
(mesh3.south) node[above,pos=.9] {$M_3$};
\end{circuitikz}
\end{minipage}
\hfill
\begin{minipage}[t]{.45\linewidth}
%
% equations for mesh and knot
%
\begin{align*}
&K : \quad I = I_1 + I_2\\
&M_1: \quad -U = -U_1\Leftrightarrow U = U_1 = R_1I_1\\
&M_2: \quad U_1 = -U_2\\
&M_3: \quad -U = -U_2\Leftrightarrow U = U_2 = R_2I_2
\end{align*}
\end{minipage}
\end{document}
答案2
使用迷你页面有什么特殊原因吗?对我来说,绘制一张包含circuitikz
特定图形 + 带方程式的节点的图像似乎不太复杂(网格线不是那么“重要”):
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenx}
\usepackage{amsmath}
\usepackage[european]{circuitikz}
\usetikzlibrary{arrows.meta,bending}
\usepackage{showframe}
\begin{document}
\begin{center}
\begin{circuitikz}[mesh/.style = {-{Triangle[flex]},thick}
]
% circuit
\draw (0,0) to [V = $U$] (0,3)
to [short, i = $I$, -*] (3,3) -- (6,3)
to [R = $R_2$, v = $U_2$, i = $I_2$] (6,0) -- (0,0)
(3,3) to [R = $R_1$, v = $U_1$, i = $I_1$, -*] (3,0);
% equations
\node (m3) [text width=0.45\linewidth,below right] at (7,3.6)
{ \begin{align*}
&K : \quad I = I_1 + I_2\\
&M_1: \quad -U = -U_1\Leftrightarrow U = U_1 = R_1I_1\\
&M_2: \quad U_1 = -U_2\\
&M_3: \quad -U = -U_2\Leftrightarrow U = U_2 = R_2I_2
\end{align*}
};
% mesh one
\node (m1) at (1.5,1.5) {$M_1$};
\draw[mesh]
(m1) + (210:5mm) % start point
arc (210:-45:5mm);% start angle, end angle and arc's radius
% mesh two
\node (m1) at (4.5,1.5) {$M_2$};
\draw[mesh]
(m1) + (210:5mm) % start point
arc (210:-45:5mm);% start angle, end angle and arc's radius
% mesh three (short implementation)
\draw[mesh,rounded corners=5mm] (m3.west) |- (0,-0.7) node[pos=0.9,above] {$M_3$};
\end{circuitikz}
\end{center}
\end{document}