rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.72k stars 1.27k forks source link

For epub_book output I get warning message "The label(s) thm:tri not found" during build of official template #1387

Open N0rbert opened 1 year ago

N0rbert commented 1 year ago

Steps to reproduce:

  1. Install latest RStudio 2022.07.2 Build 576
  2. Create new bookdown project from official default template in the new directory
  3. Build bookdown::epub_book

Expected results:

Actual results:

Additional info:

> sessionInfo(package = 'bookdown')
R version 4.1.3 (2022-03-10)
Platform: x86_64-alt-linux-gnu (64-bit)
Running under: ALT Regular

Matrix products: default
BLAS:   /usr/lib64/libopenblasp-r0.3.19.so
LAPACK: /usr/lib64/liblapack.so.4

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
character(0)

other attached packages:
[1] bookdown_0.29.2

loaded via a namespace (and not attached):
 [1] compiler_4.1.3  fastmap_1.1.0   graphics_4.1.3  htmltools_0.5.3 tools_4.1.3    
 [6] utils_4.1.3     yaml_2.3.5      grDevices_4.1.3 remotes_2.4.2   stats_4.1.3    
[11] datasets_4.1.3  rmarkdown_2.16  knitr_1.40      methods_4.1.3   xfun_0.33      
[16] digest_0.6.29   rlang_1.0.6     base_4.1.3      evaluate_0.16

> library('rmarkdown'); pandoc_version()
[1] ‘2.19.2’
N0rbert commented 1 year ago

The same happens on Debian 12 Bookworm.

cderv commented 1 year ago

Create new bookdown project from official default template in the new directory

Are you referring to https://github.com/rstudio/bookdown-demo ?

The label(s) thm:tri

It seems you are using a theorem environment in the bookdown project, right ? this is not in the demo book so I am not sure.

However, let me explain the context about epub and the Theorem & Proof feature in bookdown that tries to bring this from LaTeX to other formats.

Unfortunately, we decided to do this change (https://github.com/rstudio/bookdown/blob/main/NEWS.md#major-changes)

The theorem and proof knitr engines no longer use the block2 knitr engine to create theorem/proof environments, but write out fenced Divs instead, which is the new syntax for these environments. Note that this means these environments are no longer supported in EPUB output (they work only in HTML and PDF), but hopefully the support will be back in the future (thanks, @deleeuw, #1178).

It was motivated by a pandoc new bug that broke the old engine, which got hard to maintain. So we used a new (better) way with Lua Filter but unfortunately, we have a hard time with bringing support to epub (https://github.com/rstudio/bookdown/issues/1179) due to the way bookdown is trying to bring this feature.

This means unfortunately that Theorem and Proof environments support was lost for Docx and Epub. Pandoc still has not fixed the issue unfortunately so it stayed that way, even if initially, we though to handle this quickly in #1179 but we did not yet.

So for now workaround is pinning a bookdown version for a epub project unfortunately when using such environment.

I wonder if we could conditionnaly bring the old feature (with its limitations) for epub output only 🤔

N0rbert commented 1 year ago

Thanks. I mean https://github.com/rstudio/bookdown/blob/b428ade285fa80bd1641561fe405b33a87d0bd14/inst/rstudio/templates/project/resources/common/05-blocks.Rmd#L17 from File → New Project → New directory → Book project using bookdown and so on.

cderv commented 1 year ago

oh ok... indeed. According to what I have explain before, this template will indeed not work with epub_book() format. We should explain it or at least make it conditional.

Thanks for reporting this. Main problem with epub still remains

swvanderlaan commented 4 months ago

Has this issue been solved already? I would love to have an ePub of my book... :-)

cderv commented 4 months ago

This is still an improvement to make

It is quite of a big project to bring support for those formats considering how bookdown works. Unfortunately, time and priority among project did not let us handle that yet.

Let me also mention in this thread Quarto (https://quarto.org) which supports all of R Markdown syntax, but has a newer implementation of some bookdown feature like Cross Reference: https://quarto.org/docs/authoring/cross-references.html They don't rely on the same trick as bookdown and so it should work properly for ebook output.

N0rbert commented 3 weeks ago

Still happens with latest RStudio 2024.04.2 Build 764 and other components:

> sessionInfo(package = 'bookdown')
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 12 (bookworm)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.21.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
character(0)

other attached packages:
[1] bookdown_0.40

loaded via a namespace (and not attached):
 [1] compiler_4.2.2    fastmap_1.2.0     cli_3.6.3         graphics_4.2.2    htmltools_0.5.8.1 tools_4.2.2       rstudioapi_0.16.0
 [8] utils_4.2.2       yaml_2.3.9        grDevices_4.2.2   stats_4.2.2       datasets_4.2.2    rmarkdown_2.27    knitr_1.47       
[15] methods_4.2.2     xfun_0.45         digest_0.6.36     rlang_1.1.4       base_4.2.2        evaluate_0.24.0  
> library('rmarkdown'); pandoc_version()
[1] ‘3.1.11’

Build window contents are the following:

==> rmarkdown::render_site(output_format = 'bookdown::epub_book', encoding = 'UTF-8')

  |........                                            |  15% [unnamed-chunk-1]

processing file: _main.Rmd

output file: _main.knit.md

/usr/lib/rstudio/resources/app/bin/quarto/bin/tools/x86_64/pandoc +RTS -K512m -RTS _main.knit.md --to epub3 --from markdown+autolink_bare_uris+tex_math_single_backslash --output _main.epub --lua-filter /home/d/R/x86_64-pc-linux-gnu-library/4.2/bookdown/rmarkdown/lua/custom-environment.lua --metadata-file /tmp/Rtmp1zY4OH/file1426da40243 --number-sections --mathml --citeproc 

Output created: _book/_main.epub
Warning message:
The label(s) thm:tri not found