stargirl
stargirl

Reputation: 149

How to add image underneath title on title page?

I am writing a data analysis report. On my cover page I want to insert an image underneath the title and above the author in the blank space.

My code is shown below.

    ---
    title: \vspace{1in}"Title"
    header-includes:
    - \usepackage{fancyhdr}
    - \usepackage{titling}
    - \pretitle{\begin{center}\LARGE\includegraphics[width=2cm, height=3cm]{logo.png}\\[\bigskipamount]}
    - \posttitle{\end{center}}
    - \fancyfoot[C]{Insert Department Name Here}
    - \fancypagestyle{plain}{\pagestyle{fancy}}
    author:
    - \vspace{4in}
    - \emph{Author}
    - \emph{optional Author 2 or contact information}
    date: \vspace{1in}\emph{Date}
    geometry: left=.5in,right=.5in,top=1in,bottom=1in
    mainfont: Times New Roman
    output: 
      pdf_document: 
        highlight: tango
        toc: true 
        toc_depth: 4
        number_sections: true
        fig_caption: true
        df_print: kable
    fontsize: 11pt
    ---

It generates the following output:

enter image description here

Since I've successfully added a logo, I tried placing a copy of the same lines into various places in my code, but I either get an error saying that it fails to compile (when I try to knit to a pdf) or the image does not show up.

Upvotes: 0

Views: 2587

Answers (1)

Martin Schmelzer
Martin Schmelzer

Reputation: 23889

To keep it as easy as possible, just make use of subtitle:

---
output:
  pdf_document: 
    keep_tex: true
title: "Test"
subtitle: "\\includegraphics{unnamed.png}\\vspace{4in}"
author: "Martin \\vfill University of Duisburg-Essen \\newpage"
---

enter image description here

Upvotes: 3

Related Questions