13

I would like to draw an arrow between two parts of a sentence:

\documentclass{article}

\begin{document}


This is a very long \underline{sentence that} appears in this very \underline{short short} document.

\end{document}

The arrow should be basically an arc between the middle of "short short" and the middle of "sentence that".

I would like to be able to draw it both below the sentence and above the sentence.

Any ideas?

  • Related – user121799 Dec 30 '17 at 15:19
12

Here's how to do it with pstricks. I also suggest a line with arms:

\documentclass[svgnames]{article}
\usepackage{pst-node}
% \usepackage{auto-pst-pdf} to compile with pdflatex --enable-write18 (MiKTeX)
% or pdflatex --shell-escape (TeXLive, MacTeX)

\begin{document}

This is a very long\Rnode{st}{ \underline{sentence that}} appears in this very \Rnode{ss}{\underline{short short}} document.
\ncarc[arrows = ->, linecolor =LightSteelBlue, arcangle = 15, nodesep = 1pt]{st}{ss}
\ncbar[arrows = ->, linecolor =LightCoral, angle = -90, arm = 0.75em]{ss}{st}

\end{document} 

Some explanations on the concepts at work: the two sentences are defined as Rnodes (aligned by their base line), then they're connected with an arc connection (\ncarc) or a line with arms connection (\ncbar). The parameters used are explained in detail in the documentation of pst-node. Note these graphic elements have no dimension for TeX, so they don't modify the layout.

enter image description here

12

picture of result

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{topaths}
\tikzstyle{every picture}+=[remember picture,inner xsep=0,inner ysep=0.25ex]
\begin{document}


This is a  very long \tikz[baseline=(node1.base)]\node (node1)  {\underline{sentence that}}; appears
in this very \tikz[baseline=(node2.base)]\node (node2) {\underline{short short}}; document.

\begin{tikzpicture}[overlay]
    % Bend above text line
    \draw[-latex] (node2.north) to[bend right] (node1.north);
    % Bend below text line
    %\draw[-latex] (node2.south) to[bend left] (node1.south);
    % Angled
    \draw[-latex] (node2.south) -- ++(0,-1.5ex) -| (node1.south);
\end{tikzpicture}

\end{document}

More information:

  • "To Path Library" in the PGF manual, Chapter 70, p.745f.
  • "Referencing Nodes Outside the Current Picture", Section 17.13 in the PGF manual, p.248f.

I set inner xsep=0 to prevent messing up the word spacing in the horizontal direction. You can adjust inner ysep as desired to set the vertical positioning of the starting and end point.

7

If your purpose involves linguistics, you may want to use the tikz-dependency package. It offers many features for drawing arrows between words.

\documentclass{article}
\usepackage{tikz-dependency}
\begin{document}

\begin{dependency}[theme = simple]
   \begin{deptext}[column sep=.1em]
      This is  a very long \& \underline{sentence that} \&
      appears in this very \& \underline{short short} \& document.\\
   \end{deptext}
   \depedge{4}{2}{}
   \depedge[edge below]{2}{4}{}
\end{dependency}

\end{document}

Example of Tikz dependency

Note that this may be cumbersome because you need to write \& between every item of the sentence that you might want arrows at, but it should be useful if you only want arrows for your specific case.

You can find more by reading at https://ctan.org/pkg/tikz-dependency?lang=en

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.