请考虑这个MWE:
\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{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
Example\newpage Another example
\end{document}
我想要的是
我想实现两个用 绘制的按钮tikzpicture
,一个用于上一页,另一个用于下一页(单击它们):
我做了什么
我无法在页码周围添加这些图画。图画是一个箭头:
\begin{tikzpicture}[remember picture,overlay]
\draw[line width=1mm,red] (.3,.3) -- (0,0) -- (.3,-.3);
\end{tikzpicture}
我尝试使用没有效果的坐标,并尝试使用 + 移位的位置current page.south west
,但是我不能:
\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{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
Example\newpage Another example
\end{document}
我们如何将这些箭头放在页码附近?
答案1
怎么样
\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{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
Example\newpage Another example
\end{document}
这是更通用的版本。箭头仅在有意义时出现,单击它们即可移动到上一页或下一页。
\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})
node{\hyperlink{page.\the\numexpr\value{page}+1}{\usebox\manoooharrowR}};
\fi
\ifnum\value{page}>1
\path ([xshift=-\paperwidth/4]pageno-\number\value{page})
node{\hyperlink{page.\the\numexpr\value{page}-1}{\usebox\manoooharrowL}};
\fi
\end{tikzpicture}
}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
Example
\newpage
Another example
\newpage
Yet another example
\newpage
Last page
\end{document}
答案2
这是一个非常简单的方法:
\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}
}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
Example\newpage Another example
\end{document}