简体   繁体   中英

Reduce top margin when creating PDF from Rmarkdown using knitr

I'm creating a PDF document using knitr and Rmarkdown but the logo-and-title are far from the top of the document.

How to reduce the top margin on the first page? Many thanks in advance.

This is my code:

---
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\\}

---

I found a solution that works (not sure if it's a "clean" solution, but it does the job): I added a negative value in - \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\\}
---

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM