本文介绍了使用自定义投影仪主题在 rmarkdown::beamer_presentation 中创建从徽标到目录幻灯片的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 rmarkdown::beamer_presentation 中使用自定义 LaTex beamer 主题.根据这些 SO 答案(

我尝试了什么:在 beamerouterthemeTHEMENAME.sty

中定义自定义脚线

mode

...% 脚线setbeamertemplate{脚线}{离开模式%hyperlink{toc---目录{includegraphics[width=12mm,trim=0mm 0.4mm 0mm 0mm]{img/my_logo.png}}hfillhyperlinkappendixstart{insertframenumber/inserttotalframenumber}vspace{3mm}}模式<全部>

有关完整的 MWE,请参阅我的 这里有问题.

解决方案

在普通的 beamer 代码中,你可以简单地在框架上附加一个标签,但是 Rmarkdown 似乎太笨了,无法正确解析 中的方括号开始{frame}[label=outline]....烦人!

作为一种解决方法,您可以使用类似节名之类的东西,markdown 会自动为其插入标签:

---副标题:带有 R-markdown 的 Beamer 预演"研究所:某个地方"日期:r格式(Sys.time(),'%​​B%d,%Y')"作者:《唐老鸭》输出:# beamer_presentation: 默认bookdown::pdf_book:base_format: rmarkdown::beamer_presentation# 包括:# in_header: preamble.tex主题:主题名称"latex_engine:xelatex目录:假幻灯片级别:2keep_tex: 真标头包括:- AtBeginDocument{	itle{MWE}	itleframe}- AtEndDocument{egin{closureframe}lalalaend{closureframe}}- makeatlettereamer@ignorenonframefalsemakeatother---```{r 设置,包括=FALSE}knitr::opts_chunk$set(echo = FALSE)```## 大纲 {.unnumbered}目录# 部分## 用子弹滑动<!-- ==========================================================-->- 子弹 1- 子弹 2- 子弹 3<!-- 附录--><!-- ==========================================================-->``` {=乳胶}结束{帧}附录开始{帧}```

并在脚注中使用此目标

% 脚注setbeamertemplate{脚线}{离开模式%hyperlink{outline}{includegraphics[width=12mm,trim=0mm 0.4mm 0mm 0mm]{example-image}}hfillhyperlinkappendixstart{insertframenumber/inserttotalframenumber}vspace{3mm}}

I use a custom LaTex beamer theme in an rmarkdown::beamer_presentation.As per these SO answers (LaTex theme, colon, theme path), I used several modifications of the YAML header and beamerthemeTHEMENAME.sty.These LaTex hacks are necessary to apply the LaTex Beamer theme smoothly in the rmarkdown::beamer_presentation.

For the foot line defined in beamerouterthemeTHEMENAME.sty, it would be very nice to have a hyperlink from the logo to the table of contents slide (like the slide numbers are linked to the appendix).

What I tried: define custom foot line in beamerouterthemeTHEMENAME.sty

mode<presentation>

...

% Foot line
setbeamertemplate{footline}{
    leavevmode%
    hyperlink{toc---table-of-contents}{includegraphics[width=12mm,trim=0mm 0.4mm 0mm 0mm]{img/my_logo.png}}
    hfill
    hyperlinkappendixstart{insertframenumber/inserttotalframenumber}
    vspace{3mm}
}

mode<all>

For a complete MWE, see my SO question here.

解决方案

In normal beamer code, you could simply attach a label to the frame, but Rmarkdown seems to be too stupid to correctly parse the square brackets in egin{frame}[label=outline].... annoying!

As a workaround you could use something like a section name for which markdown will automatically insert a label:

---
subtitle: "Beamer presnetation with R-markdown"
institute: "some place"
date: "`r format(Sys.time(), '%B %d, %Y')`"
author: "Donald Duck"
output:
  # beamer_presentation: default
  bookdown::pdf_book:
    base_format: rmarkdown::beamer_presentation
    # includes:
    #   in_header: preamble.tex
    theme: "THEMENAME"
    latex_engine: xelatex
    toc: false
    slide_level: 2
    keep_tex: true
header-includes:
  - AtBeginDocument{	itle{MWE}	itleframe}
  - AtEndDocument{egin{closingframe}lalalaend{closingframe}}
  - makeatlettereamer@ignorenonframefalsemakeatother
---

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

## Outline {.unnumbered}

	ableofcontents

# section

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

- Bullet 1
- Bullet 2
- Bullet 3

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

and use this target in the footline

% Footline
setbeamertemplate{footline}{
    leavevmode%
    hyperlink{outline}{includegraphics[width=12mm,trim=0mm 0.4mm 0mm 0mm]{example-image}}
    hfill
    hyperlinkappendixstart{insertframenumber/inserttotalframenumber}
    vspace{3mm}
}

这篇关于使用自定义投影仪主题在 rmarkdown::beamer_presentation 中创建从徽标到目录幻灯片的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 18:38