How to create a R markdown/bookdown cross reference to a table that includes both text and the automatically generated table number?

Viewed 191

I am using Rmarkdown with bookdown::gitbook and kable() to create an html document. I can create cross references to the tables in the document, for example: Table \@ref(tab:avgpars) referring to the code chunk 'avgpars' which defines the table using kable. This link shows in the rendered html as "Table 3.1" where "Table" is regular text and "3.1" is a link to the table.

But the accessibility reviewer said these cross reference hyperlinks need to include the word "Table". I don't want to hardcode table numbers into hyperlinks [Table 3.1]() because the automatic updating of numbers (provided by the cross referencing) is needed.

I can create a hyperlink that looks how we want in the rendered version using the cross reference with this code: [Table \@ref(tab:avgpars)](#avgpars). But I was told that this is even less accessible because the screen reader (for people with vision impairment) will have to deal with two separate a href lines. Code in this paragraph produces this:

<a href="#avgpars">Table </a>

<a href="#tab:avgpars">3.1</a>

So the question is: How can I create a link to a table within the document where both "Table" and "3.1" are part of the same link and "3.1" is not hard coded?

0 Answers
Related