Summary (details and minimal working example at end): I have rendered an .Rmd to a .epub via bookdown::epub_book. From the _output.yml used in my Make File I have
bookdown::epub_book:
cover_image: "./Images/epubSampleCover.png"
chapter_level: "1"
epub_version: "epub3"
stylesheet: styles.css
number_sections: no
fig_width: 3
fig_height: 4
fig_caption: true
toc: yes
I have also tried
number_sections: yes
In both cases, the resulting .epub fails to pass epubcheck (and therefore cannot be uploaded into Apple Books since passing epubcheck is a necessary condition).
I have isolated the first error ERROR(RSC-012) "Fragment identifier is not defined" to the use of \@ref as in
{r,Figure \@ref(fig:epubSample1)}
when referencing a figure caption. I can confirm that, while bookdown::ePub-book does not throw errors in RStudio when building, the resulting ePub and figure references in the text do not shift focus to the figure but instead to the first page when testing the file on a local version of Apple Books.
I have isolated the second error ERROR(RSC-005) "While parsing file: value of attribute "width" is invalid; must be an integer" to the use using the out.width option in include_graphics as in
{r epubSample2, out.width="900px", fig.cap="(ref:epubSample2)"}
if(knitr::is_html_output()) knitr::include_graphics(c("./Images/epubSample2.png")) else knitr::include_graphics(c("./Images/epubSample2.png"))
I have also tried for out.width 100%, 100vh, 100vmax, 100vw but all throw the same "non-integer" error.
As @cderv has kindly pointed out to me recently, as a new person to RMarkdown/Bookdown/RStudio, not all issues are bugs, some are user errors. I do not know which is true in this case.
Possible Issue/Resolution:
In the case of Error[RSC-005], I can simply take out the out.width but then I am not sure how to size the images if needed.
It is unclear to me from reading the epub_book options what and how the sizing works
fig_width: 3
fig_height: 4
particularly when changing these numbers does not seem to affect the figure sizes (in my experience).
The Error[RSC-012] seems like I have forgotten to do something or set some option to allow ePub to reference figures. Perhaps it's a bug?
I can offer that in looking at the .epub output at one of the files in the OPF container EPUB/text/ch001.xhtml as text file I can see that
{r,As seen in Figure <a href="#fig:epubSample1">1</a>}
which seemed to be the same kind of output as in the pdfbook and htmlbook outputs where figure referencing does function properly.
I do not have a resolution to this epubcheck Error[RSC-012].
Details and Minimal Working Example:
I have placed all the files necessary to reproduce this error in a public repo on BitBucket
In the folder ./source-posts you will find the file epubSampleTwoErrors.Rmd which compile via Make Files to ./output/posts/epubSampleTwoErrors.epub. There is also a file ./output/posts/epubSampleNoErrors.epub which shows how naively resolving the issues will have no errors.
The epubcheck information I have is from
java -jar /opt/homebrew/Cellar/epubcheck/4.2.6/libexec/epubcheck.jar --help
which returns I believe the latest version of epubcheck
EPUBCheck v4.2.6
I hope this is enough information to help figure out how to make my ePub created in Bookdown pass the epubcheck required for uploading to Apple Books.
Thanks to anyone who can provide some clarity or a solution.
Best,
Jason M. Osborne