【问题标题】:LaTeX - two pages "1" with package hyperrefLaTeX - 带有 hyperref 包的两页“1”
【发布时间】:2018-07-17 12:14:33
【问题描述】:

在编译 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),我得到了:

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

提前致谢。

【问题讨论】:

    标签: latex hyperref


    【解决方案1】:

    report class 下的\maketitle 将页码设置为标题页上的1,但对于下一页也从1 重新开始。这就是为什么要为标题实现 virtual 页码 1,然后为 ToC 实现 actual 页码 1。我在这里强调virtual,因为\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}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多