我有一个弯曲的箭头,想在里面放些文字(当然,要和箭头一样弯曲)。如果文字比箭头长,则文字应该放在多行上(最好是箭头自动适当变粗)。见下图。
(我怎样才能做到这一点?
更新:
我现在使用
\coordinate (specRoot) at (-10,0);
\coordinate (testTreeRoot) at (0,0);
\draw[->, >=latex, blue!20!white, line width=15pt, bend left]
(specRoot) to (testTreeRoot);
\path [decorate,decoration={text along path, text={traverse part of
the STS and heuristically choose the best test tree}}]
[out=30] (specRoot) to [in=130] (testTreeRoot);
但是我怎样才能将路径上的装饰文字和实际的箭头结合起来呢?
如何执行回车,即沿着单条路径装饰两行文本?
更新:
现在我在文件中使用以下内容lazyOTFoverviewSmall.tex
:
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.2cm, semithick, mypostaction/.style 2 args={
decoration={
text align={
left indent=#1},
text along path,
text={#2}
},
decorate
}
]
\begin{scope}[shift={(-10cm,0cm)}]
\node[state] (specq0) {$q_0$};
\end{scope}
\begin{scope}
\node[state] (q0) {$q_0$};
\end{scope}
\coordinate (specRoot) at (-10,0);
\coordinate (testTreeRoot) at (0,0);
\draw[-latex, blue!20!white, line width=5ex, bend left]
(specRoot) ++(1cm,1cm)
to (testTreeRoot) ++(-1cm,1cm);
\path [postaction={mypostaction={1cm}{traverse part of the STS}},
postaction={mypostaction={1cm}{and heuristically choose the best test
tree}, /pgf/decoration/raise=-3mm}]
[out=30] (specRoot) ++(1cm,1cm) to [in=130] (testTreeRoot) ++(-1cm,1cm);
\end{tikzpicture}
并且master.tex
我有:
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usetikzlibrary{backgrounds,shapes} %pictures
\usetikzlibrary{arrows,automata}
....
\begin{document}
...
\begin{figure}[hbt]
\centering
\scalebox{.7}{\input{gfx/MBT/lazyOTFoverviewSmall.tex}}
\caption{Overview of Lazy On-the-fly MBT}\label{fig:lazyOTFoverview}
\end{figure}
....
答案1
TikZ 正在努力,但文本装饰并不完美,因为文本被分解为单个字母和空格,然后被框起来并旋转。所以总的来说,它需要进一步调整才能看起来不错。主要的障碍是大箭头,它会改变路径的弯曲以适应箭头,因此需要手动调整路径。这是一个快速演示,但我建议为每行放置不同的路径。
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[mypostaction/.style 2 args={
decoration={
text align={
left indent=#1},
text along path,
text={#2}
},
decorate
}
]
\coordinate (specRoot) at (-10,0);
\coordinate (testTreeRoot) at (0,0);
\draw[-latex, blue!20!white, line width=5ex] (specRoot) to[in=135,out=45] (testTreeRoot);
\path [postaction={mypostaction={1cm}{traverse part of the STS}},
postaction={mypostaction={1cm}{and heuristically choose the best test tree},
/pgf/decoration/raise=-3mm}]
(specRoot) to [in=120,out=45] (testTreeRoot);
\end{tikzpicture}
\end{document}
答案2
以下答案使用轮图包,是我写的。
箭头中的文本由第三个变量给出。此文本用 表示\WCvarC
并在键中使用arc data
。此处,\\
可用于将文本拆分为多行。
此文本位于带有键的圆弧的中心arc data pos=0.5
。
箭是用钥匙获得的slices end arrow={1}{-1}
。
\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\wheelchart[
arc data=\WCvarC,
arc data angle shift=2,
arc data expand=f,
arc data pos=0.5,
data=,
radius={4}{5},
slices end arrow={1}{-1},
slices style={\WCvarB,draw=black,very thick},
start half,
total angle=60
]{1/blue!20/text that is curved and\\can be on multiple lines}
\end{tikzpicture}
\end{document}