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

Fig.cap not working #820

Closed
andersgs opened this issue Jul 28, 2014 · 4 comments
Closed

Fig.cap not working #820

andersgs opened this issue Jul 28, 2014 · 4 comments
Labels
won't fix Won't fix due to lack of time/interest or there exist workarounds
Milestone

Comments

@andersgs
Copy link

Hi. I am trying to add a caption to a figure, but nothing shows up in the PDF. I am using RStudio (0.98.932) + knitr 1.6 + markdown on a Mac with MacTex installed. The following code does not produce a caption, for instance.


---
title: "Test"
author: "Me"
date: "28 July 2014"
output: pdf_document

---

This is an R Markdown document. Markdown is a simple formatting syntax for
authoring HTML, PDF, and MS Word documents. For more details on using R Markdown
see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes
both content as well as the output of any embedded R code chunks within the
document. You can embed an R code chunk like this:

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE,fig.cap="Test"}
plot(cars)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent
printing of the R code that generated the plot.
@yihui
Copy link
Owner

yihui commented Jul 29, 2014

You should use the argument fig_caption: yes in the YAML metadata, e.g.

output:
  pdf_document:
    fig_caption: yes

Please see http://rmarkdown.rstudio.com/pdf_document_format.html

@yihui yihui closed this as completed Jul 29, 2014
@yihui yihui added this to the v1.7 milestone Jul 29, 2014
@yihui yihui added the Invalid label Jul 29, 2014
@andersgs
Copy link
Author

Thank you, Yihui. And, sorry for wasting your time.

On Wed, Jul 30, 2014 at 4:24 AM, Yihui Xie notifications@github.com wrote:

You should use the argument fig_caption: yes in the YAML metadata, e.g.

output:
pdf_document:
fig_caption: yes

Please see http://rmarkdown.rstudio.com/pdf_document_format.html


Reply to this email directly or view it on GitHub
#820 (comment).

@Masood87
Copy link

I was struggling with this too, until I found the answer on stackoverflow.

Basically, you have to insert an empty line after the code chunk that generates the captioned plot.

@github-actions
Copy link

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 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
won't fix Won't fix due to lack of time/interest or there exist workarounds
Projects
None yet
Development

No branches or pull requests

3 participants