首页 > 解决方案 > LaTeX - 带有 hyperref 包的两页“1”

问题描述

编译 LaTeX 文档时,我得到两页编号为“1”的页面:首页和目录的第一页。这是一个MWE:

\documentclass[12pt,a4paper]{report}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\title{Title}

\begin{document}
\maketitle
\tableofcontents
\chapter{Chapter one}
\end{document}

编译时(简单地使用pdflatex file.tex),我得到这个:

在此处输入图像描述 但是当我删除 line 时\usepackage{hyperref},页码很好。请注意,我需要这个包来链接到我的目录中的页面,但也许有更好的方法可以做到这一点。这里发生了什么?如何获得正常的页码?

提前致谢。

标签: latexhyperref

解决方案


\maketitlereport该类下将页码设置为1标题页上的页码,但也将其从 1 重新启动为下一页。这就是为什么您为标题实现了虚拟页码 1,然后是 ToC 的实际页码 1。我在这里强调虚拟,因为\maketitle在页面样式上设置标题,empty以便在页眉/页脚中不打印任何内容。但是,在 Adob​​e Acrobat 中查看时,这些页码仍显示在工具栏中。

一种解决方法是手动将页面显示更改为更适合标题页的内容。例如,让我们调用标题页T

在此处输入图像描述

\documentclass{report}

\usepackage{hyperref}

\title{Title}
\author{Author}

\begin{document}

\begingroup
\renewcommand{\thepage}{T}
\maketitle % Page T
\endgroup

\tableofcontents % Page 1

\chapter{A chapter} % Page 2

\end{document}

推荐阅读