Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tikzDevice ignores engine passed via dev.args #214

Closed
fkohrt opened this issue Dec 16, 2021 · 2 comments
Closed

tikzDevice ignores engine passed via dev.args #214

fkohrt opened this issue Dec 16, 2021 · 2 comments

Comments

@fkohrt
Copy link

fkohrt commented Dec 16, 2021

When using tikzDevice as device when plotting with knitr and rmarkdown, there appear to be differences between using global options and chunk options for setting the PDF engine. I will demonstrate this with a R Markdown document with embedded PDF documents.

Setting engine = "luatex" has no effect when using the dev.args chunk option, the PDF metadata still indicate pdfTeX as creator:

---
title: "Setting PDF engine via chunk options"
output: html_document
---

```{r, dev-tikz, dev = "tikz", dev.args = list(engine = "luatex")}
par(mar = c(4, 4, 2, .1))
curve(dnorm, -3, 3, xlab = '$x$', ylab = '$\\phi(x)$',
      main = 'The density function of $N(0, 1)$')
text(-1, .2, cex = 3, col = 'blue',
  '$\\phi(x)=\\frac{1}{\\sqrt{2\\pi}}e^{\\frac{-x^2}{2}}$')
```

Only when setting the global option tikzDefaultEngine = "luatex", the metadata indicate LuaTeX as creator:

---
title: "Setting PDF engine via global options"
output: html_document
---

```{r}
options(tikzDefaultEngine = "luatex")
```

```{r, dev-tikz, dev = "tikz"}
par(mar = c(4, 4, 2, .1))
curve(dnorm, -3, 3, xlab = '$x$', ylab = '$\\phi(x)$',
      main = 'The density function of $N(0, 1)$')
text(-1, .2, cex = 3, col = 'blue',
  '$\\phi(x)=\\frac{1}{\\sqrt{2\\pi}}e^{\\frac{-x^2}{2}}$')
```
@rstub
Copy link
Member

rstub commented Jul 24, 2022

AFAIK this is a conseuqnece of how the tikzDevice support has been implemented in knitr. The resulting .tex file is always processed using tikzDefaultengine, c.f. https://github.com/yihui/knitr/blob/master/R/plot.R#L174

This is also documented at https://github.com/yihui/knitr/blob/master/inst/examples/knitr-graphics.Rnw#L249-L251

@fkohrt
Copy link
Author

fkohrt commented Jul 24, 2022

Then this should be an issue of {knitr}. I will create one there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants