Skip to content

Commit 8442b5a

Browse files
authored
Fix issue with cross referencing figures and tables in epub (#1426)
It seems we were correctly resolving the references, and adding a link to it, but no anchor id anywhere as we do for HTML This changes insert an anchor id inside an empty span in the caption part. This is a quick solution as the id should be probably added to the figure or table itself.
1 parent e9f82a1 commit 8442b5a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Fix an issue with CSL using hanging indent style in `gitbook()` (thanks, @pablobernabeu, #1422).
44

5+
- Fix cross referencing of figures and tables in `epub_book()` format by correctly adding an anchor id at the caption level (thanks, @muschellij2, #766, @tstratopoulos, @jasonmosborne, #1399, @N0rbert, rstudio/bookdown-demo#42).
6+
57
- Adapt an `epub_book()` internal command-line argument passed to Pandoc for changes from version 3.0 and above (#1425).
68

79
- Fix an issue with Pandoc 2.19 not rendering math by default in `epub3` format (#1417).

R/ebook.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ resolve_refs_md = function(content, ref_table, to_md = output_md()) {
122122
if (grepl(m, content[i])) {
123123
id = ''; sep = ':'
124124
type = gsub('^([^:]+).*$', '\\1', j)
125-
if (type %in% theorem_abbr) {
125+
if (type %in% c(theorem_abbr, 'fig', 'tab')) {
126126
id = sprintf('<span id="%s"></span>', j)
127127
sep = ''
128128
}

0 commit comments

Comments
 (0)