指定自定义主题的路径,序言并包含在使用 R 降价生成的投影仪演示文稿的 YAML 标头中 MWE.RmdbeamerthemeTHEMENAME.stypreamble.tex

问题描述

在使用 rmarkdown::beamer_presentation 生成的投影仪演示文稿中,我的目标是应用自定义主题,其中包含 beamerthemeTHEMENAME.sty(带有子文件 beamercolorthemeTHEMENAME.stybeamerfontthemeTHEMENAME.sty、{{ 1}}、beamerinnerthemeTHEMENAME.sty),作为 beamerouterthemeTHEMENAME.styIncludes

目前我在 YAML-header 中获取这些文件如下:

template.tex

为了更整齐地组织演示文稿及其文件,我想移动这些文件...

在每种情况下,我必须如何调整 YAML 标头才能正确获取上述文件

解决方法

与此同时,我找到了一个适用于短期的答案。
(对于 hints regarding a long-term solution,see the answer from @Steven 和 @Samcarter_is_at_topanswers.xyz 的评论。)

  • 将自定义主题 THEMENAME 的所有文件以及任何包含(例如,preamble.tex)放入名为 beamer_files 的子文件夹中,该文件夹中包含 Rmd 文件演示文稿位于。

  • 修改 YAML 标头和 beamerthemeTHEMENAME.sty,如下所示。 根据这些 SO 答案 (LaTex theme,colon),一些 LaTex 技巧对于在 LaTex beamer theme 中顺利应用 rmarkdown::beamer_presentation 是必要的。

MWE.Rmd

---
# COMMENT out "title" in YAML header: else markdown generates a second title page
# ==> if title contains no special characters: feed it straight into LaTex at the end of the YAML header
# ==> if title contains special characters,like ":",feed it in "preamble.tex" sourced in "LaTex Hacks"
subtitle: "Beamer presentation with R-markdown"
institute: "some place"
date: "`r format(Sys.time(),'%B %d,%Y')`"
output:
  # beamer_presentation: default
  bookdown::pdf_book:
    base_format: rmarkdown::beamer_presentation
    # Source below in "LaTex Hacks",if want theme to be stored in subfolder (else rmarkdown does not find it)
    # theme: "THEMENAME"
    # Source "includes" below in "LaTex Hacks" if using custom theme with custom title page
    # => else,markdown places the includes at inadequate position in LaTex file,which then either does not show the title or throws an error
    # includes: ...
    latex_engine: xelatex
    toc: false
    slide_level: 2
classoption: aspectratio=169 # fix aspect ratio of presentation (169 => 16:9,149 => 14:9,default: 4:3)
#
# LaTex Hacks
# --------------------------
compact-title: false # to remove markdown generated title frame
header-includes:
  # - \title{Title if no special characters} 
  - \input{beamer_files/beamerthemeTHEMENAME.sty}
  - \input{beamer_files/preamble}       # feed title to LaTex in preamble.tex due to ":"
  - \def\titlefigure{img/my_bg}
  - \AtBeginDocument{\titleframe} # add title frame defined in beamerouterthemeTHEMENAME
  - \makeatletter\beamer@ignorenonframefalse\makeatother
  ---


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

<!-- TOC - Table of Contents -->
<!-- ======================================================== -->

``` {=latex}
\end{frame}
\tocframe
\begin{frame}
```

## Slide with Bullets
<!-- ======================================================== -->

- Bullet 1
- Bullet 2
- Bullet 3

<!-- Appendix -->
<!-- ======================================================== -->
``` {=latex}
\end{frame}
\appendix
\begin{frame}
```

beamerthemeTHEMENAME.sty

% WAS:
% \usecolortheme{THEMENAME}
% \useoutertheme{THEMENAME}
% NOW:
\input{beamer_files/beamercolorthemeTHEMENAME.sty}
\input{beamer_files/beamerouterthemeTHEMENAME.sty}

\mode<all>

preamble.tex

% "title" is commented out in YAML header: else markdown generates a second title page
% if title contains no special characters: feed it straight into LaTex at the end of the YAML header
% if title contains special characters,like ":" or a forced linebreak feed it to LaTex here:
\title[short version]{First line of the title:\par second line of the title}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...