參閱这问题我尝试绘制一条中断的线,但下方/上方有文字且两端有箭头。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations}
\usetikzlibrary{positioning}
\begin{document}
\pgfdeclaredecoration{discontinuity}{start}{
\state{start}[width=0.5\pgfdecoratedinputsegmentremainingdistance-0.5\pgfdecorationsegmentlength,next state=first wave]{}
\state{first wave}[width=\pgfdecorationsegmentlength, next state=second wave]
{
\pgfpathlineto{\pgfpointorigin}
\pgfpathmoveto{\pgfqpoint{0pt}{\pgfdecorationsegmentamplitude}}
\pgfpathcurveto
{\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.75\pgfdecorationsegmentamplitude}}
{\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.25\pgfdecorationsegmentamplitude}}
{\pgfpoint{0pt}{0pt}}
\pgfpathcurveto
{\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.25\pgfdecorationsegmentamplitude}}
{\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.75\pgfdecorationsegmentamplitude}}
{\pgfpoint{0pt}{-\pgfdecorationsegmentamplitude}}
}
\state{second wave}[width=0pt, next state=do nothing]
{
\pgfpathmoveto{\pgfqpoint{0pt}{\pgfdecorationsegmentamplitude}}
\pgfpathcurveto
{\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.75\pgfdecorationsegmentamplitude}}
{\pgfpoint{-0.25*\pgfmetadecorationsegmentlength}{0.25\pgfdecorationsegmentamplitude}}
{\pgfpoint{0pt}{0pt}}
\pgfpathcurveto
{\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.25\pgfdecorationsegmentamplitude}}
{\pgfpoint{0.25*\pgfmetadecorationsegmentlength}{-0.75\pgfdecorationsegmentamplitude}}
{\pgfpoint{0pt}{-\pgfdecorationsegmentamplitude}}
\pgfpathmoveto{\pgfpointorigin}
}
\state{do nothing}[width=\pgfdecorationsegmentlength,next state=do nothing]{
\pgfpathlineto{\pgfpointdecoratedinputsegmentlast}
}
\state{final}
{
\pgfpathlineto{\pgfpointdecoratedpathlast}
}
}
\begin{tikzpicture}
\node[](S0){\LaTeX};
\node[above right = 26mm and 18mm of S0](S1){\LaTeX};
\def\myshift#1{\raisebox{1ex}}
\draw[decoration={discontinuity,amplitude=0.5cm,segment length=0.25cm,meta-segment length=0.5cm},decorate,<->,dotted,ultra thick,postaction={decorate,decoration={discontinuity,amplitude=0.5cm,segment length=0.25cm,meta-segment length=0.5cm,text along path,text align=center,text={|\sffamily\myshift|TEXTTEXT}}}](S0) -- (S1);
\end{tikzpicture}
\end{document}
结果
我们可以看到,文本不可读,并且行尾的箭头也丢失了。
预期结果
提前致谢!
答案1
像这样?
\documentclass[tikz, margin=3mm]{standalone}
\usepackage[babel,german=quotes]{csquotes} %
\usetikzlibrary{arrows.meta,
babel, % <---
decorations.markings,
positioning,
quotes}
\begin{document}
\begin{tikzpicture}[
node distance = 22mm and 22mm,
> = Straight Barb,
decoration = {markings,
mark=at position 0.5 with {
\draw[line width=1.6pt, -]
(0pt,4pt) .. controls + (2pt,-2pt) and + (-2pt,2pt) .. (0pt,-4pt);
\draw[white, line width=1pt, solid, -]
(0pt,4.1pt) .. controls + (2pt,-2pt) and + (-2pt,2pt) .. (0pt,-4.1pt);
}
},
every edge quotes/.append style = {inner ysep=5pt}
]
\node (n1) {\LaTeX};
\node (n2) [above right=of n1] {\LaTeX};
\path (n1) to ["TEXT",sloped] (n2);
\draw[dash pattern=on 1.5pt off 0.5pt, <->, postaction={decorate}]
(n1) -- (n2);
\end{tikzpicture}
\end{document}