2

I'm editing a 50 pages long article in which I'd like to mark texts using tikzmarknode and then draw a path from it into a node like this:

enter image description here

I wrote this this code.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\usepackage{lipsum}
\begin{document}

\lipsum[1]\tikzmarknode[inner sep=2pt,draw]{surname}{\mbox{Kennedy}}\lipsum[1]

\vspace{25pt}

\lipsum[1]

\begin{tikzpicture}[remember picture, overlay] \draw[blue,thick,->](surname.south west) -| ([shift={(-1.3,-5.2)}]surname.south west) -- ([shift={(0.5,-5.2)}]surname.south west) % \draw[blue,thick,->](surname.south west) -| (-1.3,-5.2) -- (1.8,0) % That looks fine but it doesn' give the expected result % \draw[blue,thick,->](surname.south west) -| (-1.3,-5.2) +- (1.8,0) % That's intuitive but it doesn't even compile % \draw[blue,thick,->](surname.south west) -| ([shift={(-1.3,-5.2)}]surname.south west) -- (1.8,0) % That still involves repetition and doesn't give the expected output node [right, draw]{\footnotesize John Fitzgerald Kennedy, the 35th president of the USA from 1961 to 1963};

\end{tikzpicture} \end{document}

I've managed to draw the path albeit with code repetitions. To eliminate them, I've rewritten the path, 3 of my rewrite attempts are given in the code. None of them worked. One of them gave e.g. this output:

enter image description here

I've taken a look at the TikZ documentatiomn but it's hard to digest this specific information out of it. I've taken a look at this similar question Telling TikZ to continue the previously-drawn path with a line-to operation? but it doesn't fit the particular structure of my problem.

How to write that path code in the most concise manner? Rationale: I'll be using this code tens of times in the article I edit.

Optional / Related Question How to use the plus-sign line-to operation? It might be documented somewhere but because it's a symbol with no name, it's not easy to identify it in the TikZ documentation or search for it on the Internet.

1 Answers1

1

I think that what you're looking for is the following:

path with --++ and |-++

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\usepackage{lipsum}
\begin{document}

\lipsum[1]\tikzmarknode[inner sep=2pt,draw]{surname}{\mbox{Kennedy}}\lipsum[1]

\vspace{25pt}

\lipsum[1]

\begin{tikzpicture}[remember picture, overlay] \draw[blue,thick,->](surname.south west) --++ (-1.5,0) |-++ (1.5,-5) node [right, draw]{\footnotesize John Fitzgerald Kennedy, the 35th president of the USA from 1961 to 1963};

\end{tikzpicture} \end{document}

Quick explanation

--++ (-1.5,0) means "draw from current point to the point 1.5cm on the left and place the current point on that location";

|-++ (1.5,-5) means "draw from current point to the point 1.5 cm on the right and 5cm below, but first drawing vertically then horizontally, and place the current point at this location".

SebGlav
  • 19,186