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

Setting fig.align in R chunks makes plot disappear in Beamer #148

Closed
xiaoweiz opened this issue Jun 30, 2014 · 6 comments
Closed

Setting fig.align in R chunks makes plot disappear in Beamer #148

xiaoweiz opened this issue Jun 30, 2014 · 6 comments

Comments

@xiaoweiz
Copy link

If the option fig.align is set to anything other than default, the figure won't show up in the generated beamer slides.

Minimal example:

---
title: "Untitled"
author: "X"
date: "30 June, 2014"
output: beamer_presentation

---
## Slide with Plot
```{r, echo=FALSE, fig.align='center'}
plot(cars)```
@xiaoweiz xiaoweiz changed the title Set fig.align in R chunks makes plot disappear in Beamer Setting fig.align in R chunks makes plot disappear in Beamer Jun 30, 2014
@jjallaire
Copy link
Member

Note that this is documented behavior of knitr (fig.align results in HTML being emitted). See: #86. It sounds like @yihui is planning on enhancing knitr to respect fig.align by outputting plots with raw_tex.

@yihui
Copy link
Member

yihui commented Jul 10, 2014

Yes I am. For the record, you may keep an eye on yihui/knitr#626. I hope to get it done in knitr 1.7. Before that happens, the easiest solution for you is to turn on figure captions, e.g.

---
title: "Untitled"
author: "X"
date: "30 June, 2014"
output:
  beamer_presentation:
    fig_caption: yes
---

## Slide with Plot

```{r, echo=FALSE, fig.width=4, fig.cap='Hello world!'}
plot(cars)
```

Then figures are centered by default since they are put in the figure environment in LaTeX.

abnova added a commit to abnova/diss-floss that referenced this issue Sep 8, 2014
…'t use fig.align - use fig.caption instead: rstudio/rmarkdown#148); 2) added knitr setting to use Cairo PDF device (for potential use in the future): yihui/knitr#436; 3) added absolute path for generated figures via fig.path.
@yihui
Copy link
Member

yihui commented Nov 9, 2014

FYI: This has been fixed in the development version of knitr, which I plan to release to CRAN in the next few days.

@johnsonzhj
Copy link

fig.align='center' seem still not work in the current version of knitr for pdf_document output.

@yihui
Copy link
Member

yihui commented Nov 27, 2015

@johnsonzhj You may also need the development version of rmarkdown here.

@github-actions
Copy link

github-actions bot commented Nov 3, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants