TransWikia.com

How to change the text placement on edge Tikz

TeX - LaTeX Asked by Aziz on December 31, 2020

Consider the following code:

begin{tikzpicture}[
node distance = 35mm,
vertex/.style = {circle, draw, text width=4.4em, align=center},
every edge/.style = {-Straight Barb, draw, semithick}
                  ]
%
node (B) [vertex]  {Facility $B$};
node (C) [vertex, right=of B]  {Facility $C$};
node (A) [vertex, above=of $(B.north)!0.5!(C.north)$] {Facility $A$};
%
draw (A) edge [bend right,"$p_{AB}$"] (B);
draw (B) edge [bend right,"$p_{BA}$"] (A);
%
draw (A) edge [bend left,"$p_{AC}$"] (C);
draw (C) edge [bend left,"$p_{CA}$"] (A);
draw (C) edge [bend left,"$p_{CB}$"] (B);
%
draw[transform canvas={yshift=+1ex}]  (B) edge ["$p_{BC}$"]  (C);
end{tikzpicture}

Which produces:

enter image description here

Here is what I want to achieve:

  • Make the placement of P_AB as that of P_AC.
  • Make the placement of P_CA as that of P_BA.
  • Prevent the edges BA and CA from crossing each other.
  • The subscripts AB, BA, CA, etc. do not really appear to be subscripts. They appear to be on the same line as p. Is there a way to emphasize their subscript-ness, if you may?
  • What is the easiest and most straightforward way of scaling this picture (with all its contents) up or down?

2 Answers

Instruction swap or its shortness ' push edge label on opposite edge side.

Edit: Now are considered all sub questions ...

enter image description here

documentclass[tikz, margin=3.14159mm]{standalone}
usetikzlibrary{arrows.meta,
                calc,
                positioning,
                quotes} 

begin{document}
    begin{tikzpicture}[
node distance = 35mm,
vertex/.style = {circle, draw, text width=3.2em, align=center},
every edge/.style = {-Straight Barb, draw, semithick},
bend angle=15 % <---
                  ]
%
node (B) [vertex]  {Facility $B$};
node (C) [vertex, right=of B]  {Facility $C$};
node (A) [vertex, above=of $(B.north)!0.5!(C.north)$] {Facility $A$};
%
draw   (A) edge [bend right,"$p^{}_{AB}$" ']  (B)
        (B) edge [bend right,"$p^{}_{BA}$"]    (A) 
%
        (A) edge [bend left,"$p^{}_{AC}$"]     (C) 
        (C) edge [bend left,"$p^{}_{CA}$" ']   (A) 
        (C) edge [bend left,"$p^{}_{CB}$"]     (B)
%
        (B) edge [bend left,"$p^{}_{BC}$"]  (C); % <---
    end{tikzpicture}
end{document}

Correct answer by Zarko on December 31, 2020

the overlapping is now addressed -- the subscript issue is addressed

enter image description here

documentclass[a4paper]{report} 
usepackage{amsmath}
%usepackage
usepackage{tikz}
usetikzlibrary{math, positioning, calc, arrows.meta, decorations.markings,quotes}
begin{document}
    
begin{tikzpicture}[
    node distance = 35mm,
    vertex/.style = {circle, draw, text width=4.4em, align=center},
    every edge/.style = {-Straight Barb, draw, semithick}
    ]
    %
    node (B) [vertex]  {Facility $B$};
    node (C) [vertex, right=of B]  {Facility $C$};
    node (A) [vertex, above=of $(B.north)!0.5!(C.north)$] {Facility $A$};
    %
    draw (A) edge [bend right,"$text{p}_text{AB}$" '] (B);
    draw (B.north east) edge [out=45,in=255,looseness=1.2,"$text{p}_text{BA}$"] (A);
    %
    draw (A) edge [bend left,"$text{p}_text{AC}$"] (C);
    draw (C.north west) edge [out=135,in=-75,looseness=1.2,"$text{p}_text{CA}$" '] (A);
    draw (C) edge [bend left,"$text{p}_text{CB}$"] (B);
    %
    draw[transform canvas={yshift=+1ex}]  (B) edge ["$text{p}_text{BC}$"]  (C);
end{tikzpicture}

end{document}

Answered by js bibra on December 31, 2020

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