【问题标题】:RMarkdown beamer & Table of contentRMarkdown 投影仪和目录
【发布时间】:2020-12-31 08:09:48
【问题描述】:

我正在尝试使用 RMarkdown beamer 创建我的第一组幻灯片。

到目前为止我所拥有的:

---
title: title
author: author
date: date
output: beamer_presentation: default
ioslides_presentation: default
linkcolor: blue
---
    
## Plan for today
    
text
        
## Outline
    
text
    
## Day 1
    
text
    
## Day 2
    
text
    
## Day 3
    
text
    
## Day 4
    
text
    
## Day 5
    
text

我看到演示文稿的标题顶部有目录,当演示者更改为具有不同部分的新幻灯片时,它会突出显示演示者所在的标题部分。为了做到这一点,我需要什么代码?理想情况下,我希望在 Introduction 下的“Plan for today”和“Outline”目录中,然后是 Day 1Day2 等。直到结论

我也想:

  1. 在右上角的标题中添加图片
  2. 在右下角的页脚中添加页码,如 3/14(仅在标题页之后)

有什么想法吗?非常感谢。

我正在尝试做的事情的图片:

【问题讨论】:

    标签: r r-markdown tableofcontents


    【解决方案1】:

    对于标头中的 TOC,最好在支持此功能的 predefined themes 中进行选择,例如 Szeged,然后在 YAML 中使用 theme: Szeged 指定它。

    要获得所需的大纲,您需要使用第一级(以# 开头)和第二级(以## 开头)节标题的正确组合,见下文。我也设置了slide_level: 3

    在右上角添加徽标、在页脚添加页码和自定义标题幻灯片需要一些 LaTeX 代码,这些代码需要插入到用于编译最终 PDF 输出的模板中。您可以通过使用 .Rmd 文件的 YAML 标头中的 includes 选项将代码包含在单独的 .tex 文件中来做到这一点。它应该是这样的:

    presentation.Rmd

    ---
    output:
      beamer_presentation:
        theme: Szeged
        slide_level: 3
        includes:
          in_header: header.tex
    ---
    
    # Introduction
    
    ## Plan for today
    text
    
    ## Outline
    text
    
    # Day 1
    
    text
    
    # Day 2
    
    and so on ...
    
    # Conclusion
    
    your conclusion
    
    

    header.tex

    % add custom title slide
    \setbeamertemplate{title page}{
      \inserttitle\\[0.5ex] 
      \insertauthor\\[0.5ex] 
      \insertdate
      \pagenumbering{gobble}
      \thispagestyle{plain}
    }
    % remove title slides at beginning of sections
    \AtBeginSection{}
    \AtBeginSubsection{}
    % add page counter to the footer
    \setbeamertemplate{footline}[frame number]
    \setbeamertemplate{frametitle}{}
    % add logo
    \usepackage{textpos}
    \addtobeamertemplate{frametitle}{}{%
    \begin{textblock*}{100mm}(0.9\textwidth,0.5cm)
     \includegraphics[height=0.5cm,width=1cm]{logo}
    \end{textblock*}}
    

    徽标是来自here 的 .PNG 文件。为了使您的图像能够很好地显示,您可能需要对位置和大小进行一些调整。请注意,header.texlogo.png 需要与 presentation.Rmd 位于同一目录中。

    【讨论】:

    • 非常感谢。我有很多部分,例如介绍,第 1 天,第 2 天,... 第 6 天,结论。通过使用这个主题,标题中很难有 TOC,因为它是垂直方向的。实际上,我在水平方向的演示文稿中看到过一次,但找不到那个主题。我猜你没有看到它,只是要求确认。谢谢!
    • 我浏览了所有 Beamer 主题,“Szeged”可以工作。我如何编辑标题以便它只显示第一部分而不是下面的第二部分(在查看 Szeged 主题时)?这是太多的信息。我在标题中看到的带有 TOC 部分的演示文稿必须经过编辑,因为它没有列在可用主题中。
    • 我还想使用此主题删除页脚中自动出现的信息,并包括页码,例如 13/30。不确定您是否知道如何编辑主题?谢谢!
    • 我不确定我是否遵循。在 YAML 标头中设置 theme: Szeged 对我来说很好。当然,现在徽标的位置(和颜色)不是最佳的,但可以通过更改 header.tex 中的参数轻松调整。如果您不想要框架标题 (?),请将 \setbeamertemplate{frametitle}{} 添加到 header.tex
    • 主题风格:Szeged在页眉中包含2个部分,共3条蓝线。但我只需要带有 TOC 的顶部部分(2 行)。下面的部分是空白的 - 可以删除它吗?最后一个问题,幻灯片上没有显示二级节标题,如何包含它们?谢谢!
    猜你喜欢
    • 2014-11-08
    • 1970-01-01
    • 2017-12-07
    • 2015-04-21
    • 2021-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-12
    相关资源
    最近更新 更多