![在一个文档的底部和右上角设置页码](https://linux22.com/image/384817/%E5%9C%A8%E4%B8%80%E4%B8%AA%E6%96%87%E6%A1%A3%E7%9A%84%E5%BA%95%E9%83%A8%E5%92%8C%E5%8F%B3%E4%B8%8A%E8%A7%92%E8%AE%BE%E7%BD%AE%E9%A1%B5%E7%A0%81.png)
答案1
您应该为不同的组件定义页面样式。在下面的示例中,我(重新)定义了plain
- 用于每个第一页\chapter
- 为完全空白。此外,frontmatter
和被定义为在相应的格式(和)mainmatter
中设置页码。\roman
\arabic
\documentclass[oneside]{book}
\usepackage{fancyhdr,lipsum}
\fancypagestyle{plain}{%
\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0pt}% Remove header rule
\renewcommand{\footrulewidth}{0pt}% Remove footer rule
}
\fancypagestyle{frontmatter}{%
\pagestyle{plain}% Just like plain page style
\fancyfoot[C]{\roman{page}}% Roman page number in footer centre
}
\fancypagestyle{mainmatter}{%
\pagestyle{plain}% Just like plain page style
\fancyhead[R]{\arabic{page}}% Arabic page number in header right
}
\let\oldfrontmatter\frontmatter
\renewcommand{\frontmatter}{
\oldfrontmatter
\pagestyle{frontmatter}
}
\let\oldmainmatter\mainmatter
\renewcommand{\mainmatter}{
\oldmainmatter
\pagestyle{mainmatter}
}
\begin{document}
\frontmatter
\title{A title}
\author{An author}
\maketitle
\cleardoublepage
\sloppy\lipsum[1-20] % Some front matter content
\mainmatter
\chapter{First chapter} % Start of main matter content
\sloppy\lipsum[1-50]
\end{document}