Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove compact title from R markdown to latex conversion?

I wrote my own titlepage and it is loaded via an include in the R-markdown file. However, this conflicts with the pandoc title. I am trying to find settings in the R markdown yaml header such that pandoc does not insert the following code snipped into the tex-file.

% Create subtitle command for use in maketitle
\newcommand{\subtitle}[1]{
  \posttitle{
    \begin{center}\large#1\end{center}
    }
}

\setlength{\droptitle}{-2em}
  \title{}
  \pretitle{\vspace{\droptitle}}
  \posttitle{}
  \author{}
  \preauthor{}\postauthor{}
  \date{}
  \predate{}\postdate{}

There is no clear indication in the pandoc documents or the r markdown guidelines how to disable the title generation. Any help would be appreciated.

Update: In particular, I am looking for solutions that allow me to keep creating my title page with the \maketitle command. That is why I focussed on this particular code snipped that I want to get rid of.

like image 408
Jascha Grübel Avatar asked Jan 03 '23 16:01

Jascha Grübel


1 Answers

I also use my own title page with rmarkdown documents for latex/pdf outputs. To remove the title, you can add the following command in a text file called with in_header :

\AtBeginDocument{\let\maketitle\relax}

A reproductible example with the header.tex file built directly within the Rmd document:

---
title: "RMarkdown No title Test"
author: "StatnMap"
date: "July 30, 2017"
output:
  pdf_document:
    includes:
      in_header: header.tex
--- 

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r rm_title_page, echo=FALSE}
head <- cat('
\\AtBeginDocument{\\let\\maketitle\\relax}
', file = "header.tex")

```

# Title 1
**Some text**

# Title 2
**Some text**
like image 190
Sébastien Rochette Avatar answered Jan 13 '23 16:01

Sébastien Rochette