Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

r - How to escape a colon in the header-includes in a YAML header

I use a custom LaTex beamer theme in an rmarkdown::beamer_presentation.

The custom theme contains a title frame. As per this SO post markdown can be tricked to use the new title frame using header-includes: - AtBeginDocument{itleframe}.

My title contains a colon and ideally a linebreak: First line of title: second line of title. However, if I include the colon, the compilation of the presentation fails.

How can I escape the colon and, if feasible, force a linebreak right after it?

MWE (YAML header)

---
# do not add title here, else markdown generates a second title page
# ==> add title manually below with header-includes
subtitle: "Beamer presentation with R-markdown"
institute: "some place"
date: "`r format(Sys.time(), '%B %d, %Y')`"
author: "Donald Duck"
output:
  bookdown::pdf_book:
    base_format: rmarkdown::beamer_presentation
    theme: "THEMENAME"
    latex_engine: xelatex
    toc: false
    slide_level: 2
    keep_tex: true 
header-includes:
  - itle{First line of the title: second line of the title}
  - AtBeginDocument{itleframe}   
---

For remainder of MWE, i.e. the beamertheme*.sty files, see the mentioned SO post.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can hide the title from markdown in a .tex file:

---
# do not add title here, else markdown generates a second title page
# ==> add title manually below with header-includes
subtitle: "Beamer presentation with R-markdown"
institute: "some place"
date: "`r format(Sys.time(), '%B %d, %Y')`"
author: "Donald Duck"
output:
  bookdown::pdf_book:
    base_format: rmarkdown::beamer_presentation
    theme: "THEMENAME"
    latex_engine: xelatex
    toc: false
    slide_level: 2
    keep_tex: true 
header-includes:
  - input{preamble}
  - AfterBeginDocument{itleframe}   
---

test

preamble.tex:

itle[short version]{First line of the title: second line of the title}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...