我想用向上弯曲的箭头连接文本的两个“位置”。到目前为止,我已经做到了这一点(简单地遵循 TikZ 手册):
\documentclass[a4paper,12pt]{book}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\begin{document}
How can I have from here \tikz[remember picture] \node[circle,fill=red!50] (n1) {}; a curved upwards arrow till here\tikz[remember picture] \node[fill=blue!50] (n2) {};?
\begin{tikzpicture}[remember picture,overlay]
\draw[->,very thick] (n1) -- (n2);
\end{tikzpicture}
\end{document}
如果您知道如何在其上方添加文本,那就太好了。
答案1
像这样:
\documentclass[a4paper,12pt]{book}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\begin{document}
How can I have from here \tikz[remember picture] \node[circle,fill=red!50] (n1) {}; a curved upwards arrow till here\tikz[remember picture] \node[fill=blue!50] (n2) {};?
\begin{tikzpicture}[remember picture,overlay]
\draw[->,very thick] (n1) to [out=45,in=135] (n2);
\end{tikzpicture}
\end{document}
也许有点像这样:
\documentclass[a4paper,12pt]{book}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\begin{document}
How can I have from here \tikz[remember picture] \node[circle,fill=red!50] (n1) {}; a curved upwards arrow till here\tikz[remember picture] \node[fill=blue!50] (n2) {};?
\begin{tikzpicture}[remember picture,overlay]
\draw[->,very thick] (n1) to [out=45,in=135] node[above] {some text here} (n2);
\end{tikzpicture}
\end{document}
甚至还有更奇特的:
\documentclass[a4paper,12pt]{book}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,decorations.text}
\begin{document}
How can I have from here \tikz[remember picture] \node[circle,fill=red!50] (n1) {}; a curved upwards arrow till here\tikz[remember picture] \node[fill=blue!50] (n2) {};?
\begin{tikzpicture}[remember picture,overlay]
\def\myshift#1{\raisebox{1ex}}
\draw[->,very thick,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|some bent text here}}}] (n1) to [out=45,in=135] (n2);
\end{tikzpicture}
\end{document}
最后采取的方法来自这个问题。
答案2
另一个想法:
\documentclass[a4paper,12pt]{book}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\begin{document}
How can I have from here \tikz[remember picture] \node[circle,fill=red!50] (n1) {}; a curved upwards arrow till here \tikz[remember picture] \node[fill=blue!50] (n2) {};?
\begin{tikzpicture}[remember picture,overlay]
\draw[->,very thick] (n1) .. controls +(1,1) and +(-1,1) .. node[above] {text above}(n2);
\end{tikzpicture}
\end{document}
.. controls +(1,.5) and +(-1,.5) ..
如果您希望它更平坦,请使用。
答案3
没有弯曲但是...
\documentclass[a4paper,12pt]{book}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,calc}
\begin{document}
How can I have from here \tikz[remember picture,baseline=-0.5ex] \node[circle,fill=red!50] (n1) {}; a curved upwards arrow till here \tikz[remember picture,baseline=-0.5ex] \node[fill=blue!50] (n2) {};?
\begin{tikzpicture}[remember picture,overlay]
\draw[->,very thick] (n1) -- ++(0,2ex)coordinate (a) -- node[above]{some text here} ($(a-|n2)$) -- (n2);
\end{tikzpicture}
\end{document}
添加\footnotesize
(或类似)
node[above,font=\footnotesize]{some text here}
要得到