欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

如何更改 LaTeX 文档中的页眉和页脚样式

最编程 2024-02-09 10:52:17
...
1.全局默认参数

latex支持默认的三种预定义的页眉页脚样式(pagestyle),使用方法是是\pagestyle{style},其中的style参数确定了使用哪种样式,包括三种:

  • plain,默认设置,在页脚显示页码
  • headings, 页脚空白,在页眉中显示章节名及页码
  • empty, 页眉页脚均设置为空白
2. 局部页面设置

如果只改变当前页面的样式,可以采用\thispagestyle{plain}来设置。

3. 自定义页眉页脚(fancyhdr)

使用fancyhdr包来设置特定的页眉页脚(headers and footers)。

以下代码展示了一个样例,其中页眉是自定义的文章标题,页脚采用 page #number of # total number 形式,表明当年页码和总页码。

\usepackage{fancyhdr} % Headers and footers
\usepackage{lastpage}
\pagestyle{fancy} % All pages have headers and footers
\fancyhead{} % Blank out the default header
\fancyfoot{} % Blank out the default footer
\fancyhead[C]{This is my custom header text } % Custom header text
\fancyfoot[RO,LE]{ Page \thepage \hspace{1pt} of \pageref{LastPage}} % Custom footer text