使用多行图例注释 tikzpicture 节点

使用多行图例注释 tikzpicture 节点

我对 Tikz 还不是很熟悉。我想实现的是使用多行数学注释两个节点。
我正在处理下图:
在此处输入图片描述

我想用以下图例来代替注释:
在此处输入图片描述 在此处输入图片描述

这是我的 MWE。对我来说,这可能微不足道,但并不简单。任何帮助都将不胜感激。

\documentclass[border=5mm]{standalone}
\usepackage{steinmetz}
\usepackage{amsmath}  
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=2]
% dpic version 2019.11.30 option -g for TikZ and PGF 1.01
\ifx\dpiclw\undefined\newdimen\dpiclw\fi
\global\def\dpicdraw{\draw[line width=\dpiclw]}
\global\def\dpicstop{;}
\dpiclw=0.8bp
\dpiclw=0.8bp
\dpicdraw (0,0)
 --(0,0.8125)\dpicstop
\dpicdraw (0,0.9375) circle (0.049213in)\dpicstop
\filldraw[line width=0bp](0.025,0.93125)
 --(0,1.03125)
 --(-0.025,0.93125) --cycle\dpicstop
\dpicdraw (0,0.84375)
 --(0,1.008344)\dpicstop
\dpicdraw (0,1.0625)
 --(0,1.875)\dpicstop
\draw (0,1.0625) node[above right=-2bp]{$ +$};
\draw (-0.125,0.9375) node[left=2bp]{$\mathrm{I_{\mathit{Nor}}}=-0.2111-j0.5138\,\SI{}{\ampere}$};
\dpicdraw (-0.005556,1.875)
 --(1.505556,1.875)\dpicstop
\dpicdraw[fill=black](1.505556,1.875) circle (0.007874in)\dpicstop
\dpicdraw (1.505556,1.875)
 --(1.505556,1.1875)\dpicstop
\global\let\dpicshdraw=\dpicdraw\global\def\dpicdraw{}
\global\def\dpicstop{--}
\dpicshdraw[fill=white]
\dpicdraw (1.505556,0.6875)
 --(1.655556,0.6875)
 --(1.655556,1.1875)
 --(1.355556,1.1875)
 --(1.355556,0.6875)
 --(1.505556,0.6875)\dpicstop
cycle; \global\let\dpicdraw=\dpicshdraw\global\def\dpicstop{;}
\dpicdraw (1.505556,0.6875)
 --(1.505556,0)\dpicstop
\draw (1.655556,0.9375) node[right=2bp]{$\mathrm{Z_{\mathit{Nor}}}=0.130-j7.496\,\SI{}{\ohm}$};
\dpicdraw[fill=black](1.505556,0) circle (0.007874in)\dpicstop
\dpicdraw (1.505556,1.875)
 --(3.005556,1.875)\dpicstop
\draw (3.005556,1.875) node[right=-2bp]{$A$};
\dpicdraw[fill=black](3.005556,1.875) circle (0.007874in)\dpicstop
\dpicdraw[fill=black](3.005556,0) circle (0.007874in)\dpicstop
\draw (3.005556,0) node[right=-2bp]{$B$};
\dpicdraw (3.011111,0)
 --(-0.005556,0)\dpicstop
\end{tikzpicture}

\end{document}

答案1

您可以使用以下aligned环境:amsmath

$\begin{aligned}
  \mathrm{I_{\mathit{Nor}}} &= \SI{-0.2111-j0.5138}{\ampere} \\
                            &= abc
\end{aligned}$

请注意,如果您只想写一个单位,请使用\si{<unit>}而不是\SI{}{<unit>}。在这里,我将数字放在 的第一个参数中\SI。虽然默认输出与您的示例不相似,但您可以使用

\sisetup{
  multi-part-units=single,
  output-complex-root=\ensuremath{\mathrm{j}},
  complex-root-position=before-number
}

如果希望将此设置应用于整个文档,请将其添加到序言中,或者仅在之后\begin{tikzpicture}针对图表进行修改。

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{steinmetz}
\usepackage{amsmath}  
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=2]
\sisetup{
  multi-part-units=single,
  output-complex-root=\ensuremath{\mathrm{j}},
  complex-root-position=before-number
}

% dpic version 2019.11.30 option -g for TikZ and PGF 1.01
\ifx\dpiclw\undefined\newdimen\dpiclw\fi
\global\def\dpicdraw{\draw[line width=\dpiclw]}
\global\def\dpicstop{;}
\dpiclw=0.8bp
\dpiclw=0.8bp
\dpicdraw (0,0)
 --(0,0.8125)\dpicstop
\dpicdraw (0,0.9375) circle (0.049213in)\dpicstop
\filldraw[line width=0bp](0.025,0.93125)
 --(0,1.03125)
 --(-0.025,0.93125) --cycle\dpicstop
\dpicdraw (0,0.84375)
 --(0,1.008344)\dpicstop
\dpicdraw (0,1.0625)
 --(0,1.875)\dpicstop
\draw (0,1.0625) node[above right=-2bp]{$ +$};
\draw (-0.125,0.9375) node[left=2bp] {%
  $  \begin{aligned}
  \mathrm{I_{\mathit{Nor}}} &= \SI{-0.2111-j0.5138}{\ampere} \\
                            &= abc
  \end{aligned}$};
\dpicdraw (-0.005556,1.875)
 --(1.505556,1.875)\dpicstop
\dpicdraw[fill=black](1.505556,1.875) circle (0.007874in)\dpicstop
\dpicdraw (1.505556,1.875)
 --(1.505556,1.1875)\dpicstop
\global\let\dpicshdraw=\dpicdraw\global\def\dpicdraw{}
\global\def\dpicstop{--}
\dpicshdraw[fill=white]
\dpicdraw (1.505556,0.6875)
 --(1.655556,0.6875)
 --(1.655556,1.1875)
 --(1.355556,1.1875)
 --(1.355556,0.6875)
 --(1.505556,0.6875)\dpicstop
cycle; \global\let\dpicdraw=\dpicshdraw\global\def\dpicstop{;}
\dpicdraw (1.505556,0.6875)
 --(1.505556,0)\dpicstop
\draw (1.655556,0.9375) node[right=2bp]{%
$\begin{aligned}
\mathrm{Z_{\mathit{Nor}}} &= \SI{0.130-j7.496}{\ohm} \\
                           &= def
\end{aligned}$};
\dpicdraw[fill=black](1.505556,0) circle (0.007874in)\dpicstop
\dpicdraw (1.505556,1.875)
 --(3.005556,1.875)\dpicstop
\draw (3.005556,1.875) node[right=-2bp]{$A$};
\dpicdraw[fill=black](3.005556,1.875) circle (0.007874in)\dpicstop
\dpicdraw[fill=black](3.005556,0) circle (0.007874in)\dpicstop
\draw (3.005556,0) node[right=-2bp]{$B$};
\dpicdraw (3.011111,0)
 --(-0.005556,0)\dpicstop
\end{tikzpicture}

\end{document}

答案2

看起来circuitikz你的方案的绘制更简单:

\documentclass[border=5mm]{standalone}
\usepackage{steinmetz}
\usepackage{amsmath, amssymb}
\usepackage{siunitx}
\sisetup{
  multi-part-units=single,
  output-complex-root=\ensuremath{\mathrm{j}},
  complex-root-position=before-number
        }
\usepackage[siunitx]{circuitikz}

\begin{document}
\begin{circuitikz}[american]
\ctikzset{bipoles/length=9mm}
\draw (0,0)  to[isource, name=i,
                l=\footnotesize
               ${\begin{array}{r@{\,}l}
                I_{\text{Nor}}  & = \SI{0.130-j7.496}{\ohm}\\
                                & = 0.555\phase{-112.33}\,\si{\ampere}
                 \end{array}}$]   (0,2) 
             to[short, -*] (2,2) 
             to[short, -*] (5,2) node[right] {$A$}
       (2,2) to[R=\footnotesize
                ${\begin{array}{r@{\,}l}   
                Z_{\text{Nor}}  & = \SI{0.130-j7.496}{\ohm}\\
                                & = 7.497\phase{0.89}\,\si{\ohm}
                  \end{array}}$] (2,0) -- (0,0)
       (2,0) to[short,*-*] (5,0) node[right] {$B$};
\node[above right] at (i.east) {+};
\end{circuitikz}
\end{document}

在此处输入图片描述

相关内容