Description Usage Arguments Value Creation notes Examples
Adds a centered caption for latex pdf, html, and word (only left
align works at this time) documents created using Rmarkdown.
adaptiveCenterCaption()
builds off of the function created using
captioner::captioner()
, assesses which type of output document is
being called using knitr::opts_knit$get("rmarkdown.pandoc.to")
, and
then outputs plain markdown formating text for the chosen document type.
1 2 3 4 5 6 | adaptiveCenterCaption(
chunckName,
caption = "",
capFxn,
type = knitr::opts_knit$get("rmarkdown.pandoc.to")
)
|
chunckName |
character string. Rmarkdown code chunk name containing the
graphic to label. Passed to the |
caption |
character string. Caption body to add to graphic. Passed to
the |
capFxn |
character string. Name of the function created by
|
type |
character string. Type of output from the Rmarkdown knit. Likely
not to be changed. Default is set to the result of
|
Returns the plain text markdown code needed to create the centered caption for the specified output type.
First created on 2019-Mar-26 as I was exploring how to use Rmarkdown.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Define captioner function
```{r, include=FALSE}
figNum <- captioner::captioner(prefix="Fig.")
```
# Plot the figure with center alignment
```{r Plot-Caret-Price, echo=FALSE, results='hide', fig.align='center'}
qplot(carat, price, data = diamonds)
```
# Run the adaptiveCenterCaption function making sure to include results="asis" in chunk options
```{r, echo=FALSE, results="asis"}
adaptiveCenterCaption(chunckName="Plot-Caret-Price", caption = "This is caption 1", capFxn = "figNum")
```
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.