[英]Rmarkdown Beamer presentation, option clash clash for xcolor
I am trying to build a beamer presentation using rmarkdown. 我正在尝试使用rmarkdown构建一个beamer演示文稿。 In my presentation I want to include tables using the kable
, and kableExtra
packages. 在我的演示文稿中,我想要使用kable
和kableExtra
包来包含表。 I am having issues with this because one of the LaTex packages that kableExtra
requires is already loaded by the beamer presentation with different options. 我遇到了这个问题,因为kableExtra
需要的一个LaTex软件包已经由不同选项的kableExtra
演示文件加载。 This is the error message that I receive. 这是我收到的错误消息。
! LaTeX Error: Option clash for package xcolor.
I have been searching for a fix for this but have not had any luck. 我一直在寻找一个解决方案,但没有运气。 I have found solutions on the LaTex pages, here and here , but I do not know LaTex and I have not figured out how to apply these solutions in the rmarkdown arena. 我在LaTex页面上找到了解决方案,无论是在这里还是在这里 ,但我不知道LaTex,我还没有想出如何在rmarkdown舞台上应用这些解决方案。 I have tried looking at the Latex templates in rmarkdown, but I do not understand it well enough to try and implement these solutions. 我已经尝试在rmarkdown中查看Latex模板,但我不太了解它以尝试实现这些解决方案。
Any thoughts or solutions would be much appreciated. 任何想法或解决方案将不胜感激。 Here is just a quick sample of the .Rmd that gives the error. 这里只是一个给出错误的.Rmd的快速示例。
---
title: "Untitled"
author: "Author"
date: "April 28, 2018"
output:
beamer_presentation:
keep_tex: true
header-includes:
- \usepackage[table]{xcolor}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
```
## Slide with R Output
```{r cars, echo = TRUE}
kable(dt, format = "latex")
```
## Slide with Plot
```{r pressure}
plot(pressure)
```
The linked answer on the TeX stackexchange suggests adding table
to the class options for the document eg \\documentclass[a4paper,table]{article}
. TeX \\documentclass[a4paper,table]{article}
上的链接答案建议将table
添加到文档的类选项中,例如\\documentclass[a4paper,table]{article}
。 In order to do this in RMarkdown, you can use a classoption:
line in your YAML header: 要在RMarkdown中执行此操作,您可以在YAML标头中使用classoption:
行:
---
title: "Untitled"
author: "Author"
date: "April 28, 2018"
classoption: table
output:
beamer_presentation:
keep_tex: true
---
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.