0

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

---
Sal
  • 117
  • 12
  • Have you considered placing the logo in the header? Nevertheless, does this answer your question? https://stackoverflow.com/questions/13515893/set-margin-size-when-converting-from-markdown-to-pdf-with-pandoc – mhovd Aug 11 '20 at 18:32
  • Don't abuse \\ for linebreaks and don't specify both the width and height of an image, this will distort the aspect ratio – samcarter_is_at_topanswers.xyz Aug 11 '20 at 18:55

1 Answers1

2

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\\}
---
Sal
  • 117
  • 12