Search code examples
r-markdowntext-alignmentauthor

RMarkdown change the order of author and title


I'm trying to align right author and put it before the title that is centered.

---
author: "Author name" 
title: "Title name"
output: pdf_document
header-includes:
    - \usepackage{titling}
    - \preauthor{\begin{flushright}}
    - \postauthor{\end{flushright}}

---

Solution

  • There is a } lacking at the end of - \preauthor{\begin{flushright}. In order to move the author up, you may use \vspace*{-1.5cm}.

    Code:

    ---
    author: "Author name" 
    title: "Title name"
    output: pdf_document
    header-includes:
        - \usepackage{titling}
        - \preauthor{\begin{flushright}\vspace*{-1.5cm}}
        - \postauthor{\end{flushright}}
    ---
    

    -output enter image description here