使用Knitr从Rmarkdown创建PDF时减少上边距

问题描述

我正在使用knitr和Rmarkdown创建PDF文档,但徽标和标题距离文档顶部远。

如何减少首页的页边距?预先非常感谢。

这是我的代码

---
title: "Title come here (there is a logo before the title)"

output:
  pdf_document:
header-includes:
  - \usepackage{titling}
  - \pretitle{\begin{center}
  -  \includegraphics[width=1.5in,height=1.5in]{logo.png}\LARGE\\}

---

解决方法

我找到了一个可行的解决方案(不确定它是否是“干净的”解决方案,但确实可以完成工作):我在- \setlength{\droptitle}{-1.1in}中添加了负值

---
title: "\\vspace{0.5in} Title here"

output:
  pdf_document:
header-includes:
  - \usepackage{titling}
  - \setlength{\droptitle}{-1.1in}
  - \pretitle{\begin{center}
  -  \includegraphics[height=1.5in]{logo.png}\LARGE\\}
---