Skip to content

rmarkdown 内置的 Pandoc Filter 脚本不支持 beamer 幻灯片输出 #1815

@XiangyunHuang

Description

@XiangyunHuang

问题

rmarkdown 自带的两个 lua 脚本 rmarkdown:::pandoc_lua_filters() 对 html 和 pdf 输出自动加持了,但是对 beamer 幻灯片没有启用,感觉有点奇怪(beamer 的输出也是 pdf 呀),一个暗黑的做法是在输出格式的地方如下传递 Pandoc 的参数

pandoc_args: !expr c("--lua-filter", list.files(rmarkdown:::pandoc_lua_filters(), full.names = T)[1])

但是,是不是可以也自动支持一下?

动机

beamer 主题通常自定了很多 block,有了 Pandoc 的 lua 脚本外挂,不需要额外增加上面那个魔法

可重复的例子

---
title: "R Markdown 制作 beamer 幻灯片"
author: "xx"
date: "`r Sys.Date()`"
documentclass: ctexbeamer
output: 
  bookdown::pdf_book: 
    number_sections: yes
    toc: no
    base_format: rmarkdown::beamer_presentation
    latex_engine: xelatex
    citation_package: natbib
    keep_tex: no # yes for debug
    template: null
    theme: Verona 
    pandoc_args: !expr c("--lua-filter", list.files(rmarkdown:::pandoc_lua_filters(), full.names = T)[1])
themeoptions: 
  - colorblocks
biblio-style: plainnat
link-citations: yes
---

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

## 设置主题 {#sec:setup-verona}
 
Ivan Valbusa 开发了 [Verona 主题的 Beamer 模版](https://bitbucket.org/rivanvx/beamer),
目前 CTAN 上的版本是 0.2,文档说明见 <https://www.ctan.org/pkg/beamer-verona>
这个主题的宏包依赖很少!我很喜欢!

```r
tinytex::tlmgr_install('beamer-verona')
```


## 自定义的块 {#sec:custom-blocks}

::: {.exampleblock data-latex="{提示}"}
提示
:::

::: {.alertblock data-latex="{警告}"}
警告
:::

::: {.block data-latex="{注意}"}
请读者注意
:::

运行环境

xfun::session_info(c('rmarkdown','tinytex','knitr'))
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 8 (Core), RStudio 1.2.5033

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
  LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

Package version:
  base64enc_0.1.3  digest_0.6.25    evaluate_0.14    glue_1.4.0       graphics_3.6.3   grDevices_3.6.3  highr_0.8        htmltools_0.4.0  jsonlite_1.6.1  
  knitr_1.28.5     magrittr_1.5     markdown_1.1     methods_3.6.3    mime_0.9         Rcpp_1.0.4.10    rlang_0.4.5.9000 rmarkdown_2.1.3  stats_3.6.3     
  stringi_1.4.6    stringr_1.4.0    tinytex_0.22.2   tools_3.6.3      utils_3.6.3      xfun_0.13        yaml_2.2.1      

Pandoc version: 2.9.2

我想对运行环境应该没什么特殊要求,不一定要上面的开发版

运行输出

输出是一个 PDF 文件,见

beamer-verona.pdf


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rmarkdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rmarkdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions