提问于:
浏览数:
1952
## 编译环境
操作系统
* [x] Windows 7/8/10
* [ ] macOS
* [ ] Linux
`若需勾选,请把[ ]改成[x]`
Tex发行版
* [x] TexLive `2019`
* [ ] MikTeX `版本号`
* [ ] CTeX
`若需勾选,请把[ ]改成[x]`
## 我的问题
如何将箭头上的文字稍稍移动以免重叠?
```
\documentclass{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{shapes.geometric,arrows}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=1cm, minimum height=1cm, text centered, draw=black, fill=red!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=3cm]
% adding nodes
\node (S) [startstop] {$S$};
\node (E) [startstop, right of=S] {$E$};
\node (I) [startstop, right of=E] {$I$};
\node (H) [startstop, right of=I] {$H$};
\node (F) [startstop, above of=E]{$F$};
\node (A) [startstop, below of=E] {$A$};
\node (P) [startstop, below of=I] {$P$};
\node (R) [startstop, below of=H] {$R$};
% adding arrows
\draw [arrow] (S) -- node[anchor=south] {$\beta,\beta',\beta l$} (E);
\draw [arrow] (E) -- node[anchor=east] {$\kappa(1-\rho_1-\rho_2)$} (A);
\draw [arrow] (E) -- node[anchor=north] {$\kappa\rho_1$} (I);
\draw [arrow] (E) -- node[anchor=south] {$\kappa\rho_2$} (P);
\draw [arrow] (I) -- node[anchor=north] {$\delta_i$} (F);
\draw [arrow] (I) -- node[anchor=south] {$\gamma_a$} (H);
\draw [arrow] (I) -- node[anchor=north] {$\gamma_i$} (R);
\draw [arrow] (H) -- node[anchor=south] {$\gamma_r$} (F);
\draw [arrow] (H) -- node[anchor=west] {$\delta_h$} (R);
\draw [arrow] (P) -- node[anchor=south] {$\delta_p$} (F);
\draw [arrow] (P) -- node[anchor=north] {$\gamma_a$} (H);
\draw [arrow] (P) -- node[anchor=north] {$\gamma_i$} (R);
%\draw [arrow] (dec1) -- node[anchor=east] {是} (pro6);
%\draw [arrow] (dec1) -- node[anchor=south] {否}(pro5);
\end{tikzpicture}
\end{document}
```
![](https://wenda.latexstudio.net/data/attach/200628/26aQnLL0.png)
1 回答
1
用`pos=...`指定`path`上的`node`位置
```tex
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{shapes.geometric,arrows,backgrounds}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=1cm, minimum height=1cm, text centered, draw=black, fill=red!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=3cm]
% adding nodes
\node (S) [startstop] {$S$};
\node (E) [startstop, right of=S] {$E$};
\node (I) [startstop, right of=E] {$I$};
\node (H) [startstop, right of=I] {$H$};
\node (F) [startstop, above of=E]{$F$};
\node (A) [startstop, below of=E] {$A$};
\node (P) [startstop, below of=I] {$P$};
\node (R) [startstop, below of=H] {$R$};
% adding arrows
\draw [arrow] (S) -- node[anchor=south] {$\beta,\beta',\beta l$} (E);
\draw [arrow] (E) -- node[anchor=east] {$\kappa(1-\rho_1-\rho_2)$} (A);
\draw [arrow] (E) -- node[above, pos=.25] {$\kappa\rho_1$} (I);
\draw [arrow] (E) -- node[below left, inner sep=1pt, pos=.4] {$\kappa\rho_2$} (P);
\draw [arrow] (I) -- node[anchor=north] {$\delta_i$} (F);
\draw [arrow] (I) -- node[anchor=south] {$\gamma_a$} (H);
\draw [arrow] (I) -- node[below left, pos=.3, inner sep=2pt] {$\gamma_i$} (R);
\draw [arrow] (H) -- node[anchor=south] {$\gamma_r$} (F);
\draw [arrow] (H) -- node[anchor=west] {$\delta_h$} (R);
\draw [arrow] (P) -- node[above right, pos=.3, inner sep=2pt] {$\delta_p$} (F);
\draw [arrow] (P) -- node[below right, pos=.25, inner sep=2pt] {$\gamma_a$} (H);
\draw [arrow] (P) -- node[anchor=north] {$\gamma_i$} (R);
%\draw [arrow] (dec1) -- node[anchor=east] {是} (pro6);
%\draw [arrow] (dec1) -- node[anchor=south] {否}(pro5);
\end{tikzpicture}
\end{document}
```
![](https://wenda.latexstudio.net/data/attach/200628/GkhfbE4o.png)
你的回答
请登录后回答
你的回答将会帮助更多人,请务必认真回答问题。