使用Waffle Chart和Glyphs FAILURE编译RMarkdown PDF.包括MWE [英] Compile RMarkdown PDF with Waffle Chart and Glyphs FAILURE. MWE included

查看:139
本文介绍了使用Waffle Chart和Glyphs FAILURE编译RMarkdown PDF.包括MWE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用RMarkdown,waffle软件包和字形来编译PDF

I am unable to compile PDF using RMarkdown, the waffle package, and glyphs

我使用TIKZ设备还是PDF渲染都没有关系.该文档可以毫无问题地编译为HTML.

It doesn't matter if I use the TIKZ device or PDF rendering. The document compiles without a problem to HTML.

我现在唯一能想到的解决方法是使用HTML编译器创建SVG图形,然后在我的中间.TEX文件中引用这些文件.

The only work around I can think of right now is to create SVG graphic with the HTML compiler, then to reference those files in my intermediate .TEX file.

请注意,如果您仅运行代码"## ---- waffle_figure ----"下面的代码.假设您先前已经在系统上安装了 fontawesome 字体,则会创建图表. R中的 extrafont 程序包,然后运行 font_install()命令.

Notice that if you simply run the code below the line that says, " ## ---- waffle_figure ---- ". It should create the chart given that you've previously installed the fontawesome font on your system, installed the extrafont package in R, and run the font_install() command.

---
title: "Waffle"
output:
  pdf_document:
    latex_engine: xelatex
  html_document: default
header-includes:
- \usepackage{fontspec}
- \defaultfontfeatures{Extension = .otf}
- \usepackage{fontawesome}
- \usepackage{tikz}
---

```{r setup, include=FALSE}
library(knitr)
library(tikzDevice)
knitr::opts_chunk$set(warning = FALSE,  error = FALSE, message = FALSE,  results='hide', echo = FALSE, dev = "tikz", external = TRUE)
```

\faTwitter

## Waffle Plot

You can also embed plots, for example:  \newline

```{r pressure, echo=FALSE, dev="tikz"}
## ---- waffle_figure ----
loadpackages <- function(package.list = c("ggplot2", "Rcpp")) {
    new.packages <- package.list[!(package.list %in% installed.packages()[,"Package"])]
    if (length(new.packages)){install.packages(new.packages, repos = 'http://cran.us.r-project.org')}
    lapply(eval(package.list), require, character.only = TRUE)}

loadpackages(c("waffle", "extrafont", "grid", "gridExtra", "tikzDevice"))
parts <- c(40, 30, 20, 10)
waffle(parts,
       rows=10,
       use_glyph = "user",
       glyph_size = 5)
```

推荐答案

Waffle软件包现已更新!现在,石英和开罗设备都可以与knitr/rmarkdown一起使用.谢谢你是鲍勃·鲁迪斯(Bob Rudis)和戴夫·甘迪(Dave Gandy)所致.

The Waffle package is now updated! Now, both the quartz and cairo devices work with knitr/rmarkdown. Huge thank you's are due to Bob Rudis and Dave Gandy.

修订后的代码包括拉丁文现代(LaTeX)字体,目的是证明可以在华夫饼图中将乳胶字体与字体字体一起使用.

The revised code includes latin modern (LaTeX) font in order to demonstrate that it is possible to implement latex fonts alongside fontawesome glyphs in waffle charts.

为了使代码正常工作,必须首先从各自的网站上安装 lmroman10-regular-webfont.ttf fontawesome-webfont.ttf :点击 webfont kit 链接字体下载.

In order for the code to work, you must first install lmroman10-regular-webfont.ttf and fontawesome-webfont.ttf from their respective websites: Click on the webfont kit link and Fontawesome download.

title: "Waffle"
output:
  pdf_document:
    latex_engine: xelatex
  html_document: default
header-includes:
- \usepackage{fontspec}
- \defaultfontfeatures{Extension = .otf}
- \usepackage{fontawesome}
- \usepackage{tikz}
---

```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(warning = FALSE,  error = FALSE, message = FALSE,  results='hide', echo = FALSE, dev = "tikz", external = TRUE)
```

## Font Awesome Gyphy

Font awesome glyphs are easy to integrate into the main text. For example: \faTwitter.

## Waffle Plot

You can also embed plots with glyphs and custom fonts, for example:  \newline

```{r pressure, echo=FALSE, dev="quartz_pdf", dev.args=list(family = "Helvetica")}
## ---- waffle_figure ----
loadpackages <- function(package.list = c("ggplot2", "Rcpp")) {
    new.packages <- package.list[!(package.list %in% installed.packages()[,"Package"])]
    if (length(new.packages)){install.packages(new.packages, repos = 'http://cran.us.r-project.org')}
    lapply(eval(package.list), require, character.only = TRUE)}

loadpackages(c("waffle", "extrafont", "grid", "gridExtra"))
# font_import()  # Run this command, type "y", and press enter after installing new fonts.

parts <- c(40, 30, 20, 10)
waffle(parts,
       rows=10,
       use_glyph = "user",
       glyph_size = 7)+ggtitle("Some Sample Text Here")+
  theme(plot.title = element_text(family="LM Roman 10"))
```

这篇关于使用Waffle Chart和Glyphs FAILURE编译RMarkdown PDF.包括MWE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆