LaTeX 页码

您所在的位置:网站首页 word2003第一页不显示页码 LaTeX 页码

LaTeX 页码

2023-12-22 09:01| 来源: 网络整理| 查看: 265

原  文:Page numbering 译  者:Xovee 翻译时间:2021年8月12日

页码

LaTeX 使用阿拉伯数字作为默认的页码格式。你也可以使用罗马数字或者字母来作为页码。你甚至可以在一个文档中混合使用多种页码格式。

文章目录 页码介绍编号样式在一个文档中使用两种页码样式自定义编码格式延伸阅读

介绍

设置一种页码格式是非常简单的:

\documentclass{article} \usepackage[utf8]{inputenc} \pagenumbering{roman} \begin{document} \tableofcontents \section{Testing section} ... \end{document}

\pagenumbering{roman}命令会将页码格式设置为小写罗马数字。

编号样式

除了上面展示的小写罗马数字,你还可以使用其他的编号样式。来看一个例子:

\documentclass{article} \usepackage[utf8]{inputenc} \pagenumbering{alph} \begin{document} \tableofcontents \section{Testing section} ... \end{document}

在这里插入图片描述 设置编号样式的命令为:

\pagenumbering{num_style}

可选项包括:

arabic:阿拉伯数字roman:小写罗马数字Roman:大写罗马数字alph:小写字母Alpa:大写字母

页码在页面中的位置取决于页面样式,请参考这篇文章。

在一个文档中使用两种页码样式

在书籍中,人们通常使用罗马数字来对第一章节之前的内容进行编号,使用阿拉伯数字来对后面的内容进行编号。你可以使用两个命令来做到这一点:

\documentclass{book} \usepackage[utf8]{inputenc} \begin{document} \frontmatter \addcontentsline{toc}{chapter}{Foreword} \Some text... \addcontentsline{toc}{chapter}{Dummy entry} Some text... \tableofcontents \mainmatter \chapter{First Chapter} This will be an empty chapter... \end{document}

在这里插入图片描述 这两个命令是: \frontmatter 这个命令之后,\mainmatter命令之前的内容,将会用小写罗马数字编号。

\mainmatter 这个命令之后的内容,将会用阿拉伯数字编号。

如果你的文档的类型不是book,或者你需要控制编码计数器或者自定义编码样式,请看下面这个例子:

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \pagenumbering{roman} \begin{document} \tableofcontents \section{First section} \setcounter{page}{3} Some text here... \section{Second section} Some more text here.. \section{Heading on Level 1 (section)} \pagenumbering{arabic} More text here... \end{document}

在这里插入图片描述 在这个例子中,我们使用了特定的编码格式,并且将编码计数器设置为一个特定的数字。

\pagenumbering{roman} 设置页码编码为小写罗马数字。

\setcounter{page}{3} 将当前页的编码计数器设置为3,之后的页码将会从这个数字开始编码。

\pagenumbering{arabic} 设置页码编码为阿拉伯数字。这个命令会重置页码计数。

自定义编码格式

你可以使用fancyhdr包来自定义页码的显示方式。例如,如果你想同时显示当前页码和总页码(比如Page 4 of 5),你可以这样做:

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{fancyhdr} \usepackage{lastpage} \pagestyle{fancy} \fancyhf{} \rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}} \begin{document} \tableofcontents \section{First section} Some text... \section{Second section} More text... \end{document}

在这里插入图片描述 这里,我们引入了lastpage包:

\usepackage{lastpage}

通过这个包,我们可以引用文档的最后一页。然后我们使用fancyhdr包来将页码显示在页码的右下方。

延伸阅读

LaTeX 中的页码



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3