I know it is possible to place TikZ nodes in positions specified relative to the page, as shown in Positioning relative to page in TikZ.
I'm also aware that it is possible to obtain nodes relative to the margins, as in Aligning tikz node at bottom of page (not paper; including margin).
However, I'd like to place a tikz node not at the bottom of the page, neither at its margin, but at the lowest place actually filled by the text block while using raggedbottom
(thus calculations from the margins are not really helpful, as far as I can tell). More precisely, how could I supply tikz with the y coordinate of the baseline of the last typeset line in the current page with raggedbottom
? Due to what I'm trying to do with this, a manual specification of the last line with a tikzmark
would not be a viable alternative (as far as I can see), so what I want to specify is the coordinate of the last line, whatever that happens to be when typeset.
For the sake of having a MWE, I supply the following which may be convenient but does not actually try to address the question, for I'm at a loss on this:
\documentclass{article}
\usepackage{tikz}
\usepackage[paperheight=8cm,paperwidth=12cm]{geometry}
\usepackage[defaultlines=4,all]{nowidow}
\usepackage{blindtext}
\raggedbottom
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=south] at (current page.south) {I am south-bound...};
\draw[thick] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}
\blindtext
\end{document}
Update: I initially tried to keep the question more abstract but, as suggested in the comments, perhaps more context might be helpful. What I'm trying to do is to polish Gonzalo Medina's solution to Mark (highlight) a paragraph (\item{…}) with a squiggly line for later attention to a raggedbottom
context. In cases in which the lateral line is drawn through a page break, the y bottom coordinate of the part in the first page is calculated as y of current page.center -0.5\textheight
, so that if the page is shorter under raggedbottom
the line stretches too far. The following code, slightly adapted from Gonzalo Medina's answer illustrates the problem:
\documentclass{article}
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,calc}
\usepackage{lipsum}
\usepackage[defaultlines=6,all]{nowidow}
\raggedbottom
\newcounter{tmp}
\newcommand\tikzmark[1]{%
\tikz[overlay,remember picture] \node (#1) {};}
\newcommand\Startsquiggly{%
\stepcounter{tmp}%
\tikzmark{a}\label{a\thetmp}%
\ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp} \else
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={coil,aspect=0},decorate,ultra thick,gray]
let \p1 = (a.north), \p2 = (b), \p3 = (current page.center) in
( $ (\x3,\y1) + (.55\textwidth,0) $ ) -- ( $ (\x3,\y3) + (0.55\textwidth,-0.5\textheight) $ );
\end{tikzpicture}%
\fi%
}
\newcommand\Endsquiggly{%
\tikzmark{b}\label{b\thetmp}
\ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp}
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={coil,aspect=0},decorate,ultra thick,gray]
let \p1 = (a.north), \p2 = (b), \p3 = (current page.center) in
( $ (\x3,\y1) + (.55\textwidth,0) $ ) -- ( $ (\x3,\y2) + (.55\textwidth,0) $ );
\end{tikzpicture}%
\else
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={coil,aspect=0},decorate,ultra thick,gray]
let \p1 = (a.north), \p2 = (b), \p3 = (current page.center) in
( $ (\x3,\y3) + (.55\textwidth,.5\textheight) $ ) -- ( $ (\x3,\y2) + (.55\textwidth,0) $ );
\end{tikzpicture}%
\fi
}
\newcommand\Squ[1]{\Startsquiggly#1\Endsquiggly}
\begin{document}
\begin{itemize}
\item \lipsum*[1]
\item \Startsquiggly\lipsum*[1]\Endsquiggly
\item \lipsum*[1]
\item \Startsquiggly\lipsum*[1]\Endsquiggly
\end{itemize}
\end{document}
The over-stretching line looks like this:
Either ideas to address the initial general question, or an alternative approach that works for the specific situation are welcome.
tikzmark
library or do the equivalent, if you prefer, and put\tikzmark{mymark}
at an appropriate place. Then you can use it in the picture definition using({pic cs:mymark})
.tikzmark
on it. Is that it? That would be too manual for my purposes. If that is the only way, I'd probably give up. Or am I getting wrong how to use thetikzmark
? If you think it is necessary, I can give more details on the context and what I'm trying to do with this coordinate.