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!

3
  • 1
    Your example doesn't work at all. We don't have the image you've used of course, and the positioning library is needed, but even after using example-image instead, and adding the library, the code produces an error. Jul 18, 2019 at 18:47
  • Why use an image rather than \LaTeX?
    – TeXnician
    Jul 18, 2019 at 19:36
  • @TorbjørnT I edited my question with your suggestions :)
    – PascalS
    Jul 19, 2019 at 5:34

1 Answer 1

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}
7
  • 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, 2019 at 5:18
  • @Passe Zarko's suggestion works without any error, hopefully you need to update your setup
    – MadyYuvi
    Jul 19, 2019 at 5: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, 2019 at 6:19
  • I use \RequirePackage[babel,german=quotes]{csquotes} \usetikzlibrary{babel} solved my problem! Thank you! For others who have the same issue please see tex.stackexchange.com/questions/166772/…
    – PascalS
    Jul 19, 2019 at 6:31
  • 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, 2019 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .