我想在页脚附近放置一个 tikzpicture。tikzpicture 用于在图像顶部显示页码。我遇到的问题是 tikzpicture 位于页脚的中心。
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\pagestyle{fancy}
\definecolor{light-blue}{RGB}{0,175,236}
\fancyhf{}
\fancyheadoffset{0in} % Ajust the header/footer width with the set margins.
\addtolength{\footskip}{0.6cm}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\footrule}{{\color{light-blue}%
\vskip-\footruleskip\vskip-\footrulewidth
\hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
\rfoot{\begin{tikzpicture}
\node (image) at (0,0) {\includegraphics[width=0.297in,height=0.353in]{pagenumber.png}};
\node[align=center,white] at (image.center) {\thepage};
\end{tikzpicture}}
\usepackage[left=0.75in,top=1.5in,right=0.75in,bottom=1in]{geometry}
\begin{document}
some text
\end{document}
答案1
一旦修复了拼写错误\includegraphics
(图像文件名称之前缺少一个左括号),您的代码就会按预期工作;使用xshift
,yshift
您可以微调\node
位置:
\documentclass[12pt]{article}
\usepackage[left=0.75in,top=1.5in,right=0.75in,bottom=1in]{geometry}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\pagestyle{fancy}
\definecolor{light-blue}{RGB}{0,175,236}
\fancyhf{}
\addtolength{\footskip}{0.6cm}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\footrule}{{\color{light-blue}%
\vskip-\footruleskip\vskip-\footrulewidth
\hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
\fancyfoot[R]{%
\begin{tikzpicture}[remember picture,overlay]
\node[xshift=-0.1485in,yshift=2pt] (image) {\includegraphics[width=0.297in,height=0.353in]{pagenumber.png}};
\node[align=center,white] at (image.center) {\thepage};
\end{tikzpicture}%
}
\begin{document}
some text
\end{document}
页面右下角的图像并显示所需的结果:
选项demo
只是graphicx
用黑色矩形替换实际图形;不是在实际文档中使用该选项。