TransWikia.com

Shift label below arrow in path

TeX - LaTeX Asked on March 4, 2021

I just want to shift the the label of $v_mpahse{j-45}$ to below the arrow, any idea how can i do that?

documentclass[12pt, margin=3mm]{standalone}
usepackage{tikz}
 usepackage{steinmetz}   
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.6) node[left]  {$Im$}; % y axis
% circle
draw       (0,0) circle (3.25cm);
% defining radius points
node (n1) [dot,] at (-45:3.25) {};
node (n2) [dot,]   at (45:3.25) {};
node (n3) [dot,] at ( 0:3.25) {};
% vector
coordinate (O) at (0,0);
path[draw=black, ultra thick, arr] 
    (O) to ["$,,quad quad V_mmathrm{e}^{j(45^{circ})}$"]  (n2.center);
path[draw=lava, ultra thick, arr] 
    (O) to ["$,,quad quad V_mmathrm{e}^{j(-45^{circ})}$"]  (n1.center);
    path[draw=myblue, ultra thick, arr] 
    (O) to ["$,,,,,,,,,,,,,,quad V_mmathrm{e}^{j(0^{circ})}$"]  (n3.center);
    
    
% angle
pic [ang, "$45^{circ}$"] {angle = n3--O--n2};
pic [ang, "$-45^{circ}$"] {angle = n1--O--n3};
    end{tikzpicture}
end{document}  

3 Answers

You are using the TiKZ quotes library. Looking at page 254 of the TiKZ manual we see:

Once loaded, inside the options of a node command you may also provide strings of the following form: "⟨text⟩"⟨options⟩

So all that you need to do is add the word "below" to the node specifications. This produces:

enter image description here

I have also taken the liberty of replacing ,,,,,,,,,,,,,,quad in the MWE with above right. Here is the updated code:

documentclass[12pt, margin=3mm]{standalone}
usepackage{tikz}
 usepackage{steinmetz}
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}

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.6) node[left]  {$Im$}; % y axis
% circle
draw       (0,0) circle (3.25cm);
% defining radius points
node (n1) [dot,] at (-45:3.25) {};
node (n2) [dot,]   at (45:3.25) {};
node (n3) [dot,] at ( 0:3.25) {};
% vector
coordinate (O) at (0,0);
path[draw=black, ultra thick, arr]
    (O) to ["$,,quad quad V_mmathrm{e}^{j(45^{circ})}$"]  (n2.center);
path[draw=lava, ultra thick, arr]
    (O) to ["$,,quad quad V_mmathrm{e}^{j(-45^{circ})}$" below]  (n1.center);
path[draw=myblue, ultra thick, arr]
    (O) to ["$V_mmathrm{e}^{j(0^{circ})}$" above right]  (n3.center);

% angle
pic [ang, "$45^{circ}$"] {angle = n3--O--n2};
pic [ang, "$-45^{circ}$"] {angle = n1--O--n3};
    end{tikzpicture}
end{document}

Correct answer by user30471 on March 4, 2021

Replace existing path with

path[draw=lava, ultra thick, arr] 
    (O) to node [below,sloped]{$V_mmathrm{e}^{j(-45^{circ})}$}  (n1.center);

enter image description here

Answered by js bibra on March 4, 2021

One more solution, using quote syntax for positioning labels on desired side of path (vector in your case) and siunitx for writing of angles values:

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

begin{document}
    begin{tikzpicture}[
ang/.style = {draw, Straight Barb-Straight Barb, anchor=west,
              angle radius = 8mm, angle eccentricity=1,
              font=footnotesize},  % <--- added
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]  (-3.4,0)--(3.6,0) node[below] {$Re$}; % changed
draw[arr]  (0,-3.4)--(0,3.6) node[left]  {$Im$}; % changed
% circle
draw       (0,0) circle (3.25cm);
% defining radius points
node (n1) [dot,] at (-45:3.25) {};
node (n2) [dot,] at ( 45:3.25) {};
node (n3) [dot,] at (  0:3.25) {};
% vector
coordinate (O) at (0,0);
path[draw=black, ultra thick, arr]
    (O) to ["$V_mmathrm{e}^{j(SI{45}{degree})}$"]  (n2.center);
path[draw=lava, ultra thick, arr]
    (O) to ["$V_mmathrm{e}^{j(SI{-45}{degree})}$" ']  (n1.center); % <--- observe added '
    path[draw=myblue, ultra thick, arr]
    (O) to [pos=0.7,"$ V_mmathrm{e}^{j(SI{0}{degree})}$" ]  (n3.center);

% angle
pic [ang, "SI{45}{degree}"] {angle = n3--O--n2};
pic [ang, "SI{-45}{degree}"] {angle = n1--O--n3};
    end{tikzpicture}
end{document}

enter image description here

Edit: In comparison to your MWE the following changes are made in above MWE:

  • for positioning of label is used shortens ' for option swap, which push label on opposite side of vector:
(O) to ["$V_mmathrm{e}^{j(SI{-45}{degree})}$" swap]

or slightly shorter

(O) to ["$V_mmathrm{e}^{j(SI{-45}{degree})}$" ']
  • axis are prolonged that can cross the circle
  • for label positioning is used option pos=... whih can moveposition of label from middle of path to desired point on the path
  • for better readable the angle labels is reduced to footnotesize

Answered by Zarko on March 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP