New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: fig.alt as a chunk option #1867
Comments
About this topic, here is a chapter about accessibility in the next Rmarkdown book: https://bookdown.org/yihui/rmarkdown-cookbook/html-accessibility.html Your insights could be useful as we are not expert on this. And yes currently, the caption and alt text are the same, and you can only have the alt text and not show the caption. But I don't think they can be different right now. |
Just here to put in another voice of support for this feature! Accessibility is important, so it should be easy for users to make things accessible. When I was working on my useR! talk I was trying to do the same thing. I think a chunk option is the way to go, and was surprised to see it didn't exist already. |
I just opened an issue in knitr for adding a |
Yes, let me vote for this feature request as an actual screen-reader user. Currently, there is no way for users to create alt text and figure caption separately for graphs. While figure caption is used for a relatively concise figure title, image alt text is intended to deliver more descriptive text-based information for assistive technologies (e.g., screen readers). In the following example, you may understand the usage of auto-generated alt text, which should be different from Ideally, I also want to give the figure a concise fig.cap like "Bar chart of clas" while attaching the alt text value to
Result
Session infoStandard output and standard error`C:/test/g-alt/g-alt_std_out_err.txt`Session info
Standard output and standard error`C:/test/g-alt/g-alt_std_out_err.txt`Session info
Standard output and standard error`C:/test/g-alt/g-alt_std_out_err.txt`Session info
Standard output and standard error`C:/test/g-alt/g-alt_std_out_err.txt`Session info
Standard output and standard error`C:/test/g-alt/g-alt_std_out_err.txt`Session info
Standard output and standard error-- nothing to show -- Session info
|
@jooyoungseo thanks for the feedback. can you try the PR in knitr yihui/knitr#1900 where I suggest an implementation for this ? |
@cderv, awesome! I have just pulled and tested your PR. That works nicely for me. Thanks for your hard work. I hope that it could be merged soon. |
remotes::install_github('yihui/knitr') Please, give us feedback if this is not enough and we missed something. |
Thank you so much!!! |
Hi, I'm trying out this feature and I can't get it to work. |
Hi @atyrell3, unfortunately this is currently a limitation of We need to find a way to make it work with other output format which is not straightforward - please follow: yihui/knitr#1967 |
Hi @cderv, thanks for the explanation. I think I found a suitable workaround that can be used for now. This code: ```{r nice-fig, fig.cap='Here is a nice alt text!', out.width='80%', fig.asp=.75, fig.align='center', dev = c("png", "jpeg", "pdf"), fig.path = "_book/figures//"}
par(mar = c(4, 4, .1, .1))
plot(pressure, type = 'b', pch = 19)
```
\
*Figure \@ref(fig:nice-fig). This is actually the caption!* renders as shown in the attached image. Caveat - as far as I can tell, the document must be rendered with bookdown for |
yes this hack workaround is working. Nice find. For reference, here is why
::: {custom-style="Image Caption"}
Figure \@ref(fig:nice-fig). This is actually the caption!
:::
It is expected. Figure referencing and numbering only work with bookdown output: https://bookdown.org/yihui/bookdown/figures.html#figures Thanks for sharing this, maybe we could work around this to make it work for docx, until Pandoc supports it correctly. 🤔 |
Thanks for the explanation and extra info! There is a way to simplify the workaround slightly. If you turn off captions in the yaml with |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
In addition to using
![alt text][id]
to write alt text it would be very useful to have fig.alt option for code chunks that could write the alt text for a figure. Unfortunately, with the current state of things, the figure caption and alt text is the same when used in code chunk. Thus, when using a screen reader only figure caption is read by the screen reader. However, for visually impaired readers, often further description of an image is needed. An example of what I have on my mind is provided below with modifications to the code provided in the R Markdown book:By filing an issue to this repo, I promise that
xfun::session_info('rmarkdown')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/rmarkdown')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: