Tikz 中行上方的文本不起作用

Tikz 中行上方的文本不起作用

我从我之前的帖子中得到了这段代码Zarko 的回答,现在的问题正如你在在此处输入图片描述附图是标签。代码应该可以工作,所以它与我的 Latex 版本或其他东西有关。(我正在使用代码生成下面的图像)

\documentclass[12pt, margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles, arrows.meta,    % new
                quotes}                 % new
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
%\usepackage{gensymb} % better is to use siunitx

\begin{document}
    \begin{tikzpicture}[
ang/.style = {draw, Straight Barb-Straight Barb, anchor=west,
              angle radius = 8mm, angle eccentricity=1},
arr/.style = {cap=round,-Straight Barb},
dot/.style = {circle, fill, minimum size=3pt,inner sep=0pt},
every edge quotes/.style = {auto, font=\footnotesize, sloped},
every label/.style       = {inner sep=1pt},
                        ]
% axis
\draw[arr]  (-2.7,0)--(3.6,0)   node[below] {$\Re$}; % x axis
\draw[arr]  (0,-2.7)--(0,3) node[left]  {$\Im$}; % y axis
% circle
\draw       (0,0) circle (2.5cm);
% defining radius points
\node (n1) [dot,label= 45:$V_m$] at (90:2.5) {};
\node (n2) [dot,label= 45:$P$]   at (45:2.5) {};
\node (n3) [dot,label=-45:$V_m$] at ( 0:2.5) {};
% vector
\coordinate (O) at (0,0);
\path[draw=lava, ultra thick, arr] 
    (O) to ["$V_m\mathrm{e}^{j\theta}$"]  (n2.center);
% projections
\path[draw=myblue, very thick, arr] 
    (O) to ["$V_m \cos(\phi)$" ']   (n2.center |- O); % projection on x axis
\path[draw=myblue, very thick, arr]
    (O) to ["$V_m \sin(\phi)$"]     (n2.center -| O); % projection on y axis
% angle
\pic [ang, "$\omega t+\phi$"] {angle = n3--O--n2};
    \end{tikzpicture}
\end{document}  

在此处输入图片描述

答案1

通过在标签中添加上方和下方解决了该问题,如以下代码所示

\documentclass[12pt, margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles, arrows.meta,   
                quotes}                
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
\usepackage{steinmetz}
\usepackage{siunitx}     % new
\usepackage{amsmath,amsthm, amssymb, latexsym}
\renewcommand{\Re}{\operatorname{Re}}
\renewcommand{\Im}{\operatorname{Im}}

\begin{document}
    \begin{tikzpicture}[
ang/.style = {draw, Straight Barb-Straight Barb, anchor=west,
              angle radius = 8mm, angle eccentricity=1},
arr/.style = {cap=round,-Straight Barb},
dot/.style = {circle, fill, minimum size=3pt,inner sep=0pt},
every edge quotes/.style = {auto, font=\footnotesize, sloped},
every label/.style       = {inner sep=1pt},
                        ]
                        
 \def\Rad{3.25}                       
                        
% axis
\draw[arr]  (-\Rad-.3,0)--(\Rad+.5,0)   node[above] {$\Re$}; % x axis
\draw[arr]  (0,-\Rad-.3)--(0,\Rad+.5) node[left]  {$\Im$}; % y axis
% circle
\draw       (0,0) circle (\Rad cm);
% defining radius points
\node (n1) [dot,label= 45:$V_m$] at (90:\Rad) {};
\node (n2) [dot,label= 45:$P$]   at (45:\Rad) {};
\node (n3) [dot,label=-45:$V_m$] at (0:\Rad) {};
% vector
\coordinate (O) at (0,0);
\path[draw=lava, ultra thick, arr] 
    (O) to ["$V_m\mathrm{e}^{j\theta}$" above]  (n2.center);
% projections
\path[draw=myblue, very thick, arr] 
    (O) to ["$V_m \cos(\phi)$" below]   (n2.center |- O); % projection on x axis
\path[draw=myblue, very thick, arr]
    (O) to ["$V_m \sin(\phi)$" above ]     (n2.center -| O); % projection on y axis
% angle
\pic [ang, "$\footnotesize{\omega t+\phi}$"] {angle = n3--O--n2};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容