0

I am trying to make an Rmarkdown document in Rstudio with latex using the tinytex package. Can somebody please tell me why the below latex code doesn't work? It should make the text "huge" but it doesn't. Instead it prints the bracets.

---
header-includes:
  - \usepackage[english,greek]{babel}
documentclass: report
mainfont: GFS Bodoni
fontsize: 12pt
title: | 
       |  {\Huge Εργασία 2}
output:
   pdf_document:
      latex_engine: xelatex
---

Note that you maybe have to install some packages via "tlmgr_install()" from package "tinytex" to run this, like "gfsbodoni" etc.

Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
Ζι Βάγγο
  • 184
  • 1
  • 9

2 Answers2

1

Instead of putting such formatting commands into the text I would configure the already present logical mark up. If you look at the generated .tex file after setting output.pdf_document.keep_tex: yes in the YAML header you see that the title is formatted via the titling package with \pretitle{\vspace{\droptitle}\centering\huge}. You can adjust this using an appropriate \pretitle command, e.g.:

---
header-includes:
  - \usepackage[english,greek]{babel}
  - \pretitle{\vspace{\droptitle}\centering\Huge}
documentclass: report
mainfont: GFS Didot
fontsize: 12pt
title: Εργασία 2
output:
   pdf_document:
      latex_engine: xelatex
      keep_tex: yes
---

(Note that I am using GFS Didot, since I do not have GFS Bodoni on my system.)

I see two possibilities if you want to further customize your title page:

  • Do not use the implicitly defined title page but make your own using the titlepage environment, c.f. https://stackoverflow.com/a/48441951/8416610
  • Use \maketitlehooka to \maketitlehookd to define additional things that should be typeset on the title page. Together with \pretitle et al. for formatting commands, you should get a great deal of flexibility. See the titling documentation for details.
Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
  • Nice! First of all thank you for your advice. What if i want to make a title page for a thesis in Rmarkdown? I really like this way instead of pure latex. Perhaps i want to make a titlepage like this [Link](https://www.overleaf.com/learn/latex/How_to_Write_a_Thesis_in_LaTeX_(Part_5):_Customising_Your_Title_Page_and_Abstract). Is there a possible way to make a title page like this, but in an Rmarkdown document (that is, using the titling package) ? Or you are restricted with the YAML header? – Ζι Βάγγο Apr 25 '19 at 01:17
  • @ΖιΒάγγο One can do a lot of things in Rmarkdown using the YAML header. But sometimes LaTeX code is needed, like the above `\pretitle`. Irrespective of the used tools, it makes sense to separate content from presentation. BTW, for writing a thesis I would use [bookdown](https://bookdown.org) instead of plain Rmarkdown. – Ralf Stubner Apr 25 '19 at 14:31
  • Thanks again. I' ll check the bookdown package. If you want you can take a look at my approach to the titlepage. – Ζι Βάγγο Apr 25 '19 at 16:38
0

Here is my approach to make a title page. I understand that it doesn't answer what I am asking but it maybe can be usefull for someone, that's why I am posting this. It is a little messy but it's enough for me. I've included a backround image and an image of my univercity. You can add your pictures:

---
header-includes:
  - \usepackage{background}
  - \backgroundsetup{firstpage=true,scale=1.4,angle=90,contents=
      {\includegraphics[width=\paperwidth,height =\paperheight]{Back4.jpg}}}
  - \usepackage[english,greek]{babel}
documentclass: report
mainfont: GFS Bodoni
fontsize: 12pt

title: | 
       | \textbf{Εργασία 2}
subtitle: |
       | \Large Π.Μ.Σ. Master in Computational and Statistical Data Analysis
       | \vspace{0.5cm} \textbf{Μάθημα}
       | Πιθανοτικά Μοντέλα με Χρήση Δεδομένων στην Διαδικασία Λήψης Αποφάσεων
       | \vspace{0.5cm} \textbf{Διδάσκοντες}
       | Ι. Δημητρίου, Ε. Μακρή
       | \vspace{2cm} \textbf{Βαγγέλης Κωστούλας, ΑΜ:1070023}
       | \textbf{Γιάννης Κολοκούρης, ΑΜ:1070008}
       | \vfil \vspace{2cm} \includegraphics[width=0.4\textwidth]{Upatras} 
       | Τμήμα Μαθηματικών
       | Πανεπιστήμιο Πατρών
       | Πάτρα, 20 Απριλίου 2019
output:
   pdf_document:
      latex_engine: xelatex
---
Ζι Βάγγο
  • 184
  • 1
  • 9