You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在R Markdown生成的PDF文档中隐藏页面页眉?

解决R Markdown生成PDF时隐藏页眉的方法

1. 默认pdf_document格式设置

在文档的YAML头部添加LaTeX代码,通过fancyhdr包清空页眉内容并移除分隔线,同时保留原有的标题结构和目录导航功能:

---
title: "你的文档标题"
output:
  pdf_document:
    toc: true  # 保留目录导航,按需开启/关闭
header-includes:
  - \usepackage{fancyhdr}
  - \pagestyle{fancy}
  - \fancyhead{}  # 清空所有页眉内容
  - \renewcommand{\headrulewidth}{0pt}  # 移除页眉下方的横线
---

2. bookdown::pdf_book格式设置

如果使用bookdown生成PDF,同样在YAML头部添加相同的header-includes配置即可:

---
title: "你的文档标题"
output:
  bookdown::pdf_book:
    toc: true
header-includes:
  - \usepackage{fancyhdr}
  - \pagestyle{fancy}
  - \fancyhead{}
  - \renewcommand{\headrulewidth}{0pt}
---

可选:完全移除页眉页脚(含页码)

如果不需要任何页眉页脚(包括页面底部的页码),可以简化配置为:

header-includes:
  - \pagestyle{empty}

内容的提问来源于stack exchange,提问作者reidj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 23:45:41