swcarpentry / r-novice-inflammation

Programming with R
http://swcarpentry.github.io/r-novice-inflammation/
Other
161 stars 394 forks source link

added alt tex #560

Closed brynnelliott closed 1 year ago

brynnelliott commented 1 year ago

Alt text written by McKenzie Hagen for https://swcarpentry.github.io/r-novice-inflammation//fig/rmd-03-loops-R-inflammation-02-3.png

zkamvar commented 1 year ago

This is a duplicate of #555

zkamvar commented 1 year ago

Note: this is NOT a duplicate of #555, but an extension. In knitr 1.31, it is possible to include alt text for images (emphasis mine):

Added a new chunk option fig.alt for users to specify the alternative text in the alt attribute of the tag (images). Previously, the alt attribute takes value from the chunk option fig.cap (it still does so if fig.alt is NULL). If there are multiple plots/images in a chunk, you can pass a character vector to fig.alt, and it will be applied to individual images (thanks, [@]cderv, https://github.com/yihui/knitr/pull/1900).

So, the solution is a bit awkward but what you can do is this (replacing the placeholder text for the actual alt text that describes the image:

{r, plot-name, fig.alt = c("... alt text 1...", "... alt text 2...", "... alt text 3...")}