I'm really confused.
The following is my Rmd file following your hint.
---
title: "Example"
date: "8 April 2018"
output:
pdf_document:
fig_caption: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(cache=TRUE, error=FALSE, fig.cap = " ", message=FALSE, warning=FALSE)
```
Bla...Bla...Bla...1
```{r Chunk_1}
x <- rnorm(10)
plot(x)
```
Bla...Bla...Bla...2
```{r Chunk_2}
y <- rcauchy(10)
z <- runif(10)
plot(y)
```
```{r Chunk_3}
plot(z)
```
Bla...Bla...Bla...3
This gives me the following output.
try.pdf (116.7 KB)
As you can see, there is no caption. Can you please point out the mistake?
For captioner
, I tried a lot, but not totally satisfied. I tried the following.
---
title: "Example"
date: "8 April 2018"
output:
pdf_document:
fig_caption: yes
---
```{r setup, include=FALSE}
fig_caption <- captioner::captioner("Fig.")
fig_caption("first", "trying for the first time")
fig_caption("second", "trying for one more time")
fig_caption("third", "trying once again")
```
Bla...Bla...Bla...1
```{r Chunk_1, fig.cap = fig_caption("first")}
x <- rnorm(10)
plot(x)
```
Bla...Bla...Bla...2
```{r Chunk_2, fig.cap = fig_caption("second")}
y <- rcauchy(10)
z <- runif(10)
plot(y)
plot(z)
```
Bla...Bla...Bla...3
```{r Chunk_3, fig.cap = fig_caption("third", display = "cite")}
w <- rexp(20)
plot(w)
```
Bla...Bla...Bla...4
I got this output.
try_2.pdf (128.3 KB)
You can understand why I didn't like it. First of all, it shows awkward cations like "Figure 1: Fig. 1: What I wrote". Second, for the 2nd chink, that has two plots, the first caption counter (I don't know when was it initialized) can mark those differently, while my defined one can't. And, the other point is that all plots are at the end, which is not convenient for me to include in my college reports.
Since the display = "cite"
worked correctly (without any text and ':'), I got hopeful and tried the same with removal of fig_caption: yes
, but that attempt failed, as nothing changed.
Edit (for the next reply)
I have the following:
R: 3.4.4
RStudio: 1.1.442
MikTeX: 2.9.6637
sessionInfo()
## R version 3.4.4 (2018-03-15)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 16299)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252
## [3] LC_MONETARY=English_India.1252 LC_NUMERIC=C
## [5] LC_TIME=English_India.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## loaded via a namespace (and not attached):
## [1] compiler_3.4.4 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2
## [5] tools_3.4.4 htmltools_0.3.6 yaml_2.1.18 Rcpp_0.12.16
## [9] stringi_1.1.7 rmarkdown_1.9 knitr_1.20 stringr_1.3.0
## [13] digest_0.6.15 evaluate_0.10.1
I am fairly sure that all of these are updated. And, should there be any reason due to Windows and Mac?