# How to automatically calculate tikz shift within pagenodes

I'm trying to correctly align a tikzpicture consisting of text inside an arrow that I put in the footer. My problem is that I want the arrow tip aligned with the eastern edge of the footer and I want the baseline of the text to align with the rest of the text in the other parts of the footer.

None of the anchoring options seem to yield what I want. If I use the base east anchor, the text is correctly aligned but the arrowhead sticks out into the margin, as shown here:

I'm aware of how to add a manual shift. In the MWE below, I have a more or less working solution by using yshift to pull the arrow up to the right place, but the value is one that I determined by eyeballing it. That solution looks like this:

However, it's obviously only valid for this one size. Is there a way to have tikz calculate the shift automatically?

Here's my MWE:

\documentclass{memoir}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{positioning,calc,shapes.arrows}
\usepackage{showframe}
\usepackage{lipsum}

\renewcommand*{\ShowFrameColor}{\color{red}}

% This version correctly aligns the CONTINUE text to the baseline,
% but the arrow head sticks out into the margin.
\newcommand{\ContinueNotice}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries}]
\node[single arrow,single arrow head extend=3pt,fill=black,text=white,anchor=base east]
at (current page footer area.south east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}

% This version is more or less correctly aligned, but the yshift is done by eye.
\newcommand{\ContinueNoticeAlt}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries}]
at (current page footer area.east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}

\makepagestyle{TestStyle}
\makeoddfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNotice}
\makeevenfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNoticeAlt}
\pagestyle{TestStyle}

\begin{document}

\lipsum

\end{document}


Use anchor=east or left for the nodes. Name the nodes by eg n and use baseline=(n.base) as option for the tikzpicture:

\documentclass{memoir}
\usepackage{tikzpagenodes}
\usetikzlibrary{shapes.arrows}
\usepackage{showframe}
\usepackage{lipsum}

\renewcommand*{\ShowFrameColor}{\color{red}}

\newcommand{\ContinueNotice}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
at (current page footer area.south east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}

\newcommand{\ContinueNoticeAlt}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
at (current page footer area.east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}

\makepagestyle{TestStyle}
\makeoddfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNotice}
\makeevenfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNoticeAlt}
\pagestyle{TestStyle}

\begin{document}
\lipsum
\end{document}


Update

Note that there is no need to use tikzpagenodes and remember picture. Then you have to run it only once.

\documentclass{memoir}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\usepackage{showframe}
\usepackage{lipsum}

\renewcommand*{\ShowFrameColor}{\color{red}}

\newcommand{\ContinueNotice}{%
\begin{tikzpicture}[overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
{\enspace CONTINUE\enspace};
\end{tikzpicture}%
}

\newcommand{\ContinueNoticeAlt}{%
\begin{tikzpicture}[overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
{\enspace CONTINUE\enspace};
\end{tikzpicture}%
}

\makepagestyle{TestStyle}
\makeoddfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNotice}
\makeevenfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNoticeAlt}
\pagestyle{TestStyle}

\begin{document}
\lipsum
\end{document}


The result is the same as above.

• This does exactly what I want, so thanks. I have an additional question, though, merely out of curiosity. When I run your version through TexStudio, it takes 6 iterations of pdflatex before it stops. I'm used to 2 or 3 runs to get everything to settle down, but 6 seems supererogatory. Do you know what's happening to cause so many iterations? Apr 24 '17 at 0:58
• I have added a version without tikzpagenodes and without option remember picture. Then have to run it only once.
– esdd
Apr 24 '17 at 6:54