निरंजन
I am trying to draw a line from one (`\tikz`)`mark` to another one from my document. As can be seen in the following code; it works correctly when both the marks are present on a single page, but doesn't work when the page is crossed.
```
\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{list}{\tikzmark{one}}%
\item Hello world
\end{list}
\lipsum%[1]% Works fine when both the marks are on the same
% page.
\begin{list}{\tikzmark{two}}%
\item Hello world
\end{list}
\begin{tikzpicture}[remember picture]
\draw[overlay] (pic cs:one) -> (pic cs:two);
\end{tikzpicture}
\end{document}
```
PS: Kindly don't suggest `tcolorbox` or `mdframed` solutions. I have tried both of them and there are various reasons for not choosing them for this purpose. Don't worry about that line overlapping the text. That `lipsum` text is just a place-holder.
Top Answer
samcarter
Tikzpictures don't break across pages. You'll have to split it into one tikzpicture per page:
```
\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\begin{document}
\begin{list}{}{}%
\item[\tikzmark{one}] Hello world
\end{list}
\begin{tikzpicture}[remember picture]
\draw[overlay]
let \p1 = (pic cs:one),
\p2 = (current page text area.south)
in
(pic cs:one) -- (\x1,\y2);
\end{tikzpicture}
\lipsum%[1]% Works fine when both the marks are on the same
% page.
% make sure to place this code on the second page
\AddToHook{shipout/foreground}[foo]{
\begin{tikzpicture}[remember picture]
\draw[overlay]
let \p1 = (pic cs:one),
\p2 = (current page text area.north west),
\p3 = (current page text area.south west),
in
(\x1,\y2) -- (\x1,\y3);
\end{tikzpicture}
}
\lipsum
\lipsum
\begin{list}{}{}%
\item[\tikzmark{two}] Hello world
\end{list}
\begin{tikzpicture}[remember picture]
\draw[overlay]
let \p1 = (pic cs:two),
\p2 = (current page text area.north)
in
(\x1,\y2) -- (pic cs:two) ;
\end{tikzpicture}
\RemoveFromHook{shipout/foreground}[foo]
\end{document}
```
(I moved `\tikzmark` to the label of the first item, otherwise you risk to define the same mark multiple times)
