# How to place a \draw near the page number using tikzpicture environment

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{tikz}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rfoot{
\begin{tikzpicture}[remember picture,overlay]
\fill[black] (current page.south west) rectangle ++(\paperwidth,1.5cm)
node[midway,align=center,font=\LARGE,text=white] {\bfseries\thepage}; % From https://tex.stackexchange.com/a/443744/152550
\end{tikzpicture}
}

\renewcommand{\footrulewidth}{0pt}

\begin{document}

Example\newpage Another example

\end{document}


# What I want

I want to implement two buttons that are drawings made with tikzpicture, one for previous page and the other for next page (click on them):

# What I have done

I am not able to add these drawings around the page number. The draw is an arrow:

\begin{tikzpicture}[remember picture,overlay]
\draw[line width=1mm,red] (.3,.3) -- (0,0) -- (.3,-.3);
\end{tikzpicture}


I tried to use coordinates with no effects, and tried to use the position of current page.south west + a shift but I couldn't:

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{tikz}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rfoot{
\begin{tikzpicture}[remember picture,overlay]
\fill[black] (current page.south west) rectangle ++(\paperwidth,1.5cm) node[midway,align=center,font=\LARGE,text=white] {\bfseries\thepage}; % From https://tex.stackexchange.com/a/443744/152550
\draw[line width=1mm,white] (current page.south west) -- ++(.5cm,.5cm) -- (.3,-.3); % This should be placed near the page number, and there should be another arrow pointing to the right
\end{tikzpicture}
}

\renewcommand{\footrulewidth}{0pt}

\begin{document}

Example\newpage Another example

\end{document}


How can we place those arrows near the page number?

• Using the tikzpagenodes package, there is (currnet page footer area), but you would still need fancyhdr or everypage to draw it. The thing to remember about footers and headers is that they are actually single lines of text, similar to \hbox to \textwidth{\rlap{left text}\hfill center text \hfill\llap{right text}}. – John Kormylo Feb 23 '20 at 16:39

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{tikz}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rfoot{
\begin{tikzpicture}[remember picture,overlay]
\fill[black] (current page.south west) rectangle ++(\paperwidth,1.5cm)
node[midway,align=center,font=\LARGE\bfseries,text=white]
(pageno-\number\value{page}) {\thepage}; % From https://tex.stackexchange.com/a/443744/152550
\draw[white,ultra thick,line cap=round,line join=round]
([xshift=-\paperwidth/4]pageno-\number\value{page}.south)
--  ([xshift=-\paperwidth/4-7pt]pageno-\number\value{page}.center)
-- ([xshift=-\paperwidth/4]pageno-\number\value{page}.north)
([xshift=\paperwidth/4]pageno-\number\value{page}.south)
--  ([xshift=\paperwidth/4+7pt]pageno-\number\value{page}.center)
-- ([xshift=\paperwidth/4]pageno-\number\value{page}.north);
\end{tikzpicture}
}

\renewcommand{\footrulewidth}{0pt}

\begin{document}

Example\newpage Another example

\end{document}


Here is a more versatile version. The arrows only appear when it makes sense, and by clicking on them you move to the previous or next page.

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{tikz}
\usepackage{hyperref}
\usepackage{lastpage}
\usepackage{refcount}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newsavebox{\manoooharrowL}
\newsavebox{\manoooharrowR}
\sbox\manoooharrowR{\begin{tikzpicture}
\draw[line width=1mm,white,line cap=round,line join=round]
(0,0) -- (7pt,8pt) -- (0pt,16pt);
\end{tikzpicture}}
\sbox\manoooharrowL{\begin{tikzpicture}
\draw[line width=1mm,white,line cap=round,line join=round]
(0,0) -- (-7pt,8pt) -- (0pt,16pt);
\end{tikzpicture}}
\fancyhf{}
\rfoot{
\begin{tikzpicture}[remember picture,overlay]
\fill[black] (current page.south west) rectangle ++(\paperwidth,1.5cm)
node[midway,align=center,font=\LARGE\bfseries,text=white,xscale=1.5]
(pageno-\number\value{page})
{\thepage}; % From https://tex.stackexchange.com/a/443744/152550
\ifnum\value{page}<\getpagerefnumber{LastPage}
\path ([xshift=\paperwidth/4]pageno-\number\value{page})
\fi
\ifnum\value{page}>1
\path ([xshift=-\paperwidth/4]pageno-\number\value{page})
\fi
\end{tikzpicture}
}

\renewcommand{\footrulewidth}{0pt}

\begin{document}

Example
\newpage
Another example
\newpage
Yet another example
\newpage
Last page

\end{document}


• Thank you so much!! You have done what I wanted. I just replaced ultra thick with line width=1mm since I think it is thin (in this case I should increase the thickness of the \thepage but I did not how to do it, only got a small thickness by adding \bfseries). – manooooh Feb 23 '20 at 15:50
• @manooooh You can make it arbitrarily fat by using xscale=1.5, say, in the node options. – user194703 Feb 23 '20 at 15:54
• @manooooh I added a more versatile version with hyperlinks and somewhat more intelligent arrows. (One can of course add further arrows to jump to the last and/or first page, say.) – user194703 Feb 23 '20 at 16:18
• This works like a charm!!! I was going to post another question asking about your last code. Look! imgur.com/a/8JTYjm8 – manooooh Feb 23 '20 at 16:22
• @manooooh Sorry, was offline. Yes, ocgx is great, especially if its grand master AlexG is dealing with it. Normal mortals and cats often use more mundane tools. ;-) – user194703 Feb 23 '20 at 18:40

Here is a very simple approach:

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{tikz}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rfoot{
\begin{tikzpicture}[remember picture,overlay]
% From https://tex.stackexchange.com/a/443744/152550
\fill[black] (current page.south west) rectangle ++(\paperwidth,1.5cm)
node[midway,align=center,font=\LARGE,text=white] (pgNum){\bfseries\thepage};
% Left arrow
\node[left of=pgNum, xshift=-3cm, scale=4,
path picture={\draw[line width=1mm, red] (.3,.3) -- (0,0) -- (.3,-.3);}] {};
% Right arrow
\node[right of=pgNum, xshift=3cm, scale=4,
path picture={\draw[line width=1mm, red] (-.3,-.3) -- (0,0) -- (-.3,.3);}] {};
\end{tikzpicture}
}