ryamlr-markdown

put the title log in the center of the title page from YAML section in Rmarkdown


I have some code in R with Rmarkdown and I am interesting in putting the logo and the title in center of the first page but from the YAML section.



---
mainfont: Arial
output:
  pdf_document:
    latex_engine: xelatex
header-includes:
- \usepackage{mathpazo} 
- \usepackage{graphicx} 
- \usepackage{booktabs} 
- \usepackage{listings} 
- \usepackage{enumerate} 
- \usepackage{titling}
title: |
  ![](logo.jpg){width=1in}  
  my name 
  my subject
---

How can I achieve this ?


Solution

  • I found this way to keep only the logo and title on the first page just using yaml. Please adjust the spacing/Font after the logo and "My Name" using \\[0.2cm]! Available Fontsizes: fontsizes Adjust the fontiszes like this: {\Large My Name} or {\LARGE My Name}

    ---
    mainfont: Arial
    output:
      pdf_document:
        latex_engine: xelatex
    header-includes:
    - \usepackage{mathpazo} 
    - \usepackage{graphicx} 
    - \usepackage{booktabs} 
    - \usepackage{listings} 
    - \usepackage{enumerate} 
    - \usepackage{titling}
    title: |
      \vfill
      \begin{center}
        \includegraphics[width=1in]{logo.jpg} \\[0.2cm] % Adjust the spacing as needed
        {\Large My Name} \\[0.2cm]  % Adjust font size and spacing
        {\large My Subject} 
      \end{center}
      \vfill
      \newpage
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    ```
    
    ## R Markdown
    
    This is an R Markdown document. 
    

    Output

    out