6 Xaringan 语法
本项目基于 remark.js,幻灯片的 markdown 书写语法可参考 Markdown · gnab/remark Wiki (github.com)
Xaringan 官方文档:Chapter 7 xaringan Presentations | R Markdown: The Definitive Guide (bookdown.org)
6.2 快捷键
h
/?
显示快捷键列表
Home
/End
跳转到第一页/最后一页
b
黑屏(比如你的当前页面上有测验答案暂时不想给观众看)
f
全屏
p
presenter mode
c
打开克隆窗口。若有双屏,可以将一个窗口展示给观众;另一个窗口开 presenter mode,可以显示注释和下一页提示
6.3 语法
6.3.1 Slides and Properties
<!-- -->
注释---
分隔页--
递增(incremental)显示分隔符,但该符号不能出现在 content classes 中???
presenter notes,仅出现在演讲者模式中,演讲者可见- 在 presentation 中一个常见的错误,就是在幻灯片中塞进太多的内容。结果要么是演讲者上气不接下气地大声朗读这么多单词,要么是观众开始自己安静地阅读幻灯片,不听。幻灯片不是纸或书,所以你应该尽量在幻灯片的视觉内容上简短,但在口头叙述上冗长。如果你对一张幻灯片有很多要说的,但不能记住所有的内容,你可以考虑使用 presenter notes
页属性,写在每页的开头,均兼容标准 css 语法
class:
定义本页类,然后再 css 中可以定义具体类的实现left
/center
/right
,水平对齐方式top
/middle
/bottom
,竖直对齐方式class: bottom
与递增显示分隔符--
连用,即可创建逐行上升的动画效果
inverse
,颜色反转
background-image: url()
,定义背景图片background-position:
,背景图片位置50%, 80%
,图片中心在屏幕中的位置,横向左起,纵向上起
background-size:
,背景图片大小
contain
cover
200px
15%
layout:
true
,定义一页为母版,该页本身不会显示,但其后的幻灯片都会继承母版的属性false
,停止继承母版
name: xxx
,定义一页为模板,该页本身不会显示,后面可以引用该名称多次使用{{content}}
在模板中定义占位符,使用模板时,所写的 markdown 内容会出现在占位符处
template: xxx
,使用定义好的 slide
6.3.2 YAML
title: "幻灯忍者"
subtitle: "写轮眼"
author: "黄蒙 ✉huangmeng@ucass.edu.cn"
institute: "RStudio, PBC"
date: "2016/12/12"
output:
xaringan::moon_reader:
css:
- default # 提供了几个默认类,所以这行必须有,哪怕用了别的主题
- default-fonts
- fc
- fc-fonts
- zh-CN.css
- "https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css" # animation in transition, https://github.com/yihui/xaringan/issues/184
self_contained: no # Whether to produce a self-contained HTML file by embedding all external resources into the HTML file.(可能需要科学上网,才能将Xaringan所依赖的js脚本、谷歌字体等文件嵌入本地 html)
lib_dir: libs
seal: true # 是否根据 YAML 信息自动生成首页
nature:
ratio: '16:9' # 默认4:3
# titleSlideClass: ["center", 'inverse',"middle"] # 默认首页的样式
highlightStyle: github
highlightLines: true # 当一行 R 代码被 {{ }} 包裹时,允许其高亮
countIncrementalSlides: yes
# beforeInit: "macro/macro.js" # 在 remark.js 渲染前插入js脚本,例如该脚本可以快捷定义图片的size
autoplay:
interval: 60000 # 自动播放一页时间间隔(单位:毫秒)
loop: false # 是否循环
countdown: 60000 # 每页的倒计时
6.3.3 Content Classes
ramark.js 一个非常强大的功能,是 markdown 中的任何内容都可以用一个 CSS 类来规范,语法为 .className[content]
. 甚至可以连用,如.center.red[]
default 主题提供的默认类包括:.left[]
, .center[]
, .right[]
, .left-column[ ]
, .right-column[ ]
(宽度为20%-75%), .pull-left[]
, .pull-right[]
(宽度为 50%-50%), .footnote[]
(出现于屏幕左下角)
其他类需要自己在 CSS 文件中设置。
https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css 提供了一些动画类,如 .animated
, .zoomIn
, zoomInDown