在以下情节中
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.arrows,shapes}
\begin{document}
\begin{tikzpicture}
\node[draw,ultra thick,above right,] (USR) at (1,7) {User};
\node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
\draw[-latex,line width=1.mm,teal] (MNT.north) to[ out=120, in=210,] (USR.west);
\draw[-latex,line width=1.mm,teal] (USR.east) to[ out=-30, in=50,] (MNT.east);
%---
\node[] (get) at (-1,4) {\large{GET}};
% \node[below,yshift=-2mm] at (get) {\large{SET}};
\node[] at (2,4) {\large{RESPONSE}};
\end{tikzpicture}
\end{document}
我无法使文本GET
、 和RESPONSE
沿线放置(倾斜)。我测试了pos=0.7
、near end
或选项,但near start
它们不起作用。最后,单词出现在坐标处以显示此示例。
答案1
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.arrows,shapes}
\begin{document}
\begin{tikzpicture}
\node[draw,ultra thick,above right,] (USR) at (1,7) {User};
\node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
\draw[-latex,line width=1.mm,teal] (MNT.north) to[ out=120, in=210,]node[above,sloped] (get) {\large{GET}} (USR.west) ;
\draw[-latex,line width=1.mm,teal] (USR.east) to[ out=-30, in=50,] (MNT.east);
%---
% \node[above,sloped] (get) at (-1,4) {\large{GET}};
% \node[below,yshift=-2mm] at (get) {\large{SET}};
% \node[] at (2,4) {\large{RESPONSE}};
\end{tikzpicture}
\end{document}
或者
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.arrows,shapes,decorations.text}
\begin{document}
\begin{tikzpicture}
\node[draw,ultra thick,above right,] (USR) at (1,7) {User};
\node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
\draw[-latex,line width=1.mm,teal] (MNT.north) to[ out=120, in=210,]node[above,sloped] (get) {\large{GET}} (USR.west) ;
\def\myshift#1{\raisebox{1ex}}
\draw[-latex,line width=1.mm,teal, postaction={decorate,decoration={text along path,text align=center,text={
|\myshift|some bent text here}}}] (USR.east) to[ out=-30, in=50,] (MNT.east);
%---
% \node[above,sloped] (get) at (-1,4) {\large{GET}};
% \node[below,yshift=-2mm] at (get) {\large{SET}};
% \node[] at (2,4) {\large{RESPONSE}};
\end{tikzpicture}
\end{document}
答案2
如果您希望文本遵循曲线,则必须使用decorations.text
库和一些技巧,如下所示:
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\node[draw,ultra thick,above right,] (USR) at (1,7) {User};
\node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
\def\shft#1{\raisebox{1ex}} % Vertical shift to be used as an argument in the path decoration
\draw[-latex,line width=1.mm,teal,postaction={decorate,decoration={text along path,text align=center,text={|\large\shft|GET SET}}}] (MNT.north) to[ out=120, in=210,] (USR.west);
\draw[-latex,line width=1.mm,teal,postaction={decorate,decoration={text along path,text align=center,text={|\large\shft|RESPONSE}}}] (USR.east) to[ out=-30, in=50,] (MNT.east);
\end{tikzpicture}
\end{document}