rlatexr-markdownknitrpandoc

RMarkdown. How to reduce space between title block and start of body text


I've been using RMarkdown via RStudio on a Mac successfully.

Recently upgraded to RStudio 1.2.5019 and tinytex_0.18 and now the vertical spaceing between my "title block" and "first body text / heading" has increased.

Simple example, (deliberately excluding author: and date:), is:

---
output: 
  pdf_document
title: "Example of Title to Body Text"
subtitle: Subtitle Places Here
---
This is the first paragraph (or heading if specified as such). It is quite a way down from the title of the document. How can this be reduced to a "single line" vertical space?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.

I then tried to use the "titlesec" package, but haven't been able to work out which command to use to achieve the desired outcome. Example of attempt is:

---
output: 
  pdf_document

subparagraph: yes
header-includes: |
  \usepackage{titlesec}
  \titlespacing{\title}{0pt}{\parskip}{-\parskip}

title: "Example of Title to Body Text"
subtitle: Subtitle Places Here
---
This is the first paragraph (or heading if specified as such). It is quite a way down from the title of the document. How can this be reduced to a "single line" vertical space?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.

This is what it currently looks like rendered to PDF.

Current output

This is what I would like the PDF to look more like (edit from graphics program).

Desired output

So, how can I reduce this vertical spacing between the title block and the start of the document's body?

Thanks in advance.


Solution

  • You can reduce the space between the (sub)title and the first paragraph by adding \vspace{} command from LaTeX right before the first paragraph.

    ---
    output: 
      pdf_document
    
    subparagraph: yes
    header-includes: |
      \usepackage{titlesec}
      \titlespacing{\title}{0pt}{\parskip}{-\parskip}
    
    title: "Example of Title to Body Text"
    subtitle: Subtitle Places Here
    ---
    
    \vspace{-5truemm}
    
    
    This is the first paragraph (or heading if specified as such). It is quite a way down from the title of the document. How can this be reduced to a "single line" vertical space?
    
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.