Skip to content

Setting message=FALSE chunk opts suppresses fig.cap for PDF output #2032

@dchiu911

Description

@dchiu911

I'm not sure when this started, but I've tried with the devel version of knitr and the issue persists: setting knitr::opts_chunk$set(message = FALSE) suppresses figure captions when the output is PDF.

---
title: "Untitled"
date: "7/29/2021"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE)
```

```{r test, fig.cap=caps}
library(ggplot2)
caps <- c("another caption", "and yet an other")
qplot(1:5)
qplot(6:10)
```

And it is important for me to have message=FALSE to suppress messages such as
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions