如何更改 Tikz 边缘上的文本位置

如何更改 Tikz 边缘上的文本位置

考虑以下代码:

\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}

其结果为:

在此处输入图片描述

这是我想要实现的目标:

  • P_AB将 的放置设为P_AC
  • P_CA将 的放置设为P_BA
  • 防止边缘BA互相CA交叉。
  • 下标ABBACA等实际上看起来并不是下标。它们似乎与 在同一行p。如果可以的话,有没有什么方法可以强调它们的下标性?
  • 将这张图片(及其所有内容)放大或缩小的最简单、最直接的方法是什么?

答案1

将说明书swap或其缩写'推入对侧边缘的标签。

编辑: 现在考虑所有子问题......

在此处输入图片描述

\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}

答案2

重叠问题现已解决——下标问题已解决

在此处输入图片描述

\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}

相关内容