4

Refer to this question I try to draw an interrupted line, but with text below / above and arrows at both ends.

\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}

RESULT

enter image description here

As we can see, the text is not readable and the arrows at the end of the lines are also missing.

EXPECTED RESULT

enter image description here

Thanks in advance!

PascalS
  • 826

1 Answers1

6

Like this?

enter image description here

\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}
Zarko
  • 296,517
  • The result looks great! But I got an error in this line \path (n1) to ["TEXT",sloped] (n2); Argument of \language@active@arg" has an extra }. If I comment out this part of code I got the interrupted line without any text. – PascalS Jul 19 '19 at 05:18
  • @Passe Zarko's suggestion works without any error, hopefully you need to update your setup – MadyYuvi Jul 19 '19 at 05:47
  • @Passe, I use recent of the tikz package, i.e. version 3.1.4 but it should works with versions after 3.0.1. However, if you use babel package (for example with french option) in your document, than may help if you add to tikz libraries a library babel. Otherwise consider to update your `setup (as mentioned MadyYuvi in his comment). – Zarko Jul 19 '19 at 06:19
  • I use \RequirePackage[babel,german=quotes]{csquotes} \usetikzlibrary{babel} solved my problem! Thank you! For others who have the same issue please see https://tex.stackexchange.com/questions/166772/problem-with-babel-and-tikz-using-draw – PascalS Jul 19 '19 at 06:31
  • @Passe, problems with babel, which in many languages change the meaning of some characters, is well known :-). I edit my answer and add babel package and library to code. Now it should work in your document. Happy TeXing! – Zarko Jul 19 '19 at 07:53
  • @Zarko Now, I integrated your suggestion in my document. I noticed, that the interruption looks a bit small in comparison to the text. I tried to fix it by myself but without success... Could you mention, witch parameters are responsible for the size and the gap between the two wavy lines?? – PascalS Jul 19 '19 at 14:20
  • 1
    @Passe,defined are in decoration in part 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); }. To enlarge it accordingly change line widths for example from 1.6pt and 1pt to 2.4pt and 1.8pt , from change coordinates for drawings, (0,4pt) to for example `(0,7pt) . – Zarko Jul 19 '19 at 14:35