In SO mentioned earlier, see @yihui's comment:
Is there a way to generate the
alt text
withoutfig.cap
option? (i.e. for images that aren't captioned?)
Yes,fig_caption: false
for html_document: 3.1 HTML document | R Markdown: The Definitive Guide
So, if we include fig_caption: false
into YAML:
---
title: "Accessibility"
author: "C Lindell"
date: '2020-06-23'
output:
html_document:
toc: yes
toc_float: yes
fig_caption: false
---
![This image/figure/plot/diagramm represent...](figures/my_image.png "Figure 1: Title")
we get .html
output (with both, title=
& alt=
, under the hood):
<img src="...base64..." title="Figure 1: Title" alt="This image/figure/plot/diagramm represent…"" ... />
but without showing caption/title on the surface.
With fig_caption: true
we get following .html
output:
<img src="...base64..." title="Figure 1: Title" alt="">
<p class="caption">This image/figure/plot/diagramm represent…</p>
having the caption showed on the surface, without alt text
under the hood.
It seems that there is no perfect solution (with knitr
), as pointed by @HanOostdijk.