3

I want to mark two points in the middle of a paragraph (or more) of text, and draw an arrow from one point to the next. The arrow can be in colour and with some transparency, and can overwrite the main text, which shall be in black. When text is inserted between the marks, I want the arrow to change automatically; The only thing I can guarantee is that both marks shall remain on a single page. How can this be accomplished?

1 Answers1

3

I'll let someone else post an answer involving \tikzmark.

Regarding how the TikZ manual suggests to do this.

At the points that you want to connect, you'll use the following code

\tikz[remember picture] \node (<node name>) {};

where <node name> is a name of your choice. You should use different names for each such node.

To connect the two nodes, you will need a tikzpicture environment

\begin{tikzpicture}[remember picture,overlay]
  \draw[arrows=->] (node-name-1) -- (node-name-2);
\end{tikzpicture}

Here node-name-1 and node-name-2 are whatever you personally want to name those two nodes.

The remember picture tells TikZ to remember where the nodes and the picture are being created on the physical layout of the page (normally TikZ doesn't bother to try to remember this). The overlay tells TikZ that this is something that shouldn't interrupt the follow of the other content of the page: in other words, it's laid over the content of the page.

There all sorts of things you can do to create the lines joining the two nodes. If you don't want straight lines joining the nodes then you can use a spline as in

 \draw[arrows=->] (node-name-1) .. control ++ (<coordinate-1>) and ++ (<coordinate-2>) .. (node-name-2);

Here the ++ makes the coordinates act like vectors relative to the current node position to create a bezier curve joining the two nodes.

I could provide a much better example if you provided a MWE.

Here are some examples.

Here's a rather boring and dull example:

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

\tikz[remember picture] \node (gaul) {};%%
GALLIA est omnis divisa in partes tres, quarum unam incolunt Belgae,
aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli
appellantur. Hi omnes lingua, institutis, legibus inter se differunt.%%
\tikz[remember picture] \node (3-parts) {};%%

\begin{tikzpicture}[remember picture,overlay]
  \draw[arrows=->,blue,line width=2pt,opacity=0.20] (3-parts) -- (gaul);
\end{tikzpicture}

Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit.

Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque
humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe
commeant atque ea quae ad effeminandos animos pertinent important,
proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter
bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute
praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut
suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.

\end{document}

enter image description here

Here's a more creative answer using various manipulations of how to connect the nodes:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\tikz[remember picture,inner sep=0pt] \node (gaul)  {};%%
GALLIA est omnis divisa in partes tres, quarum unam incolunt Belgae,
aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli
appellantur. Hi omnes lingua, institutis, legibus inter se differunt.%%
\tikz[remember picture,inner sep=0pt] \node (3-parts) {};%%

\begin{tikzpicture}[remember picture,overlay]
  \draw[arrows=->,blue,line width=2pt,opacity=0.20] (3-parts) ++ (-0.25em,1ex) .. controls ++ (2,0) and ++(0,5) .. ($(gaul)+(4pt,1.35ex)$);
\end{tikzpicture}

Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit.

Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque
humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe
commeant atque ea quae ad effeminandos animos pertinent important,
proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter
bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute
praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut
suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.

\end{document}

enter image description here

A.Ellett
  • 50,533