如何在 YAML header 中转义 header-includes 中的冒号

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

我在 rmarkdown::beamer_presentation 中使用自定义 LaTex beamer theme

自定义主题包含标题框。根据 可以使用 header-includes: - \AtBeginDocument{\titleframe}.

欺骗降价以使用新的标题框

我的标题包含一个冒号,最好是一个换行符:First line of title:\n second line of title。 但是,如果我包含冒号,演示文稿的编译就会失败。

我怎样才能转义冒号,如果可行的话,在它后面强制换行?

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:
  - \title{First line of the title: second line of the title}
  - \AtBeginDocument{\titleframe}   
---

对于 MWE 的其余部分,即 beamertheme*.sty 文件,请参阅

您可以在 .tex 文件中隐藏 markdown 的标题:

---
# 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{\titleframe}   
---

test

preamble.tex:

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