htmlrr-markdownknitrcaption

rmarkdown HTML number figures not working with knitr_1.44


Using code similar to this answer. After updating knitr_1.43 to knitr_1.44 captions are no longer numbered and floating right. They changed something, bug or feature?

Note, there are HTML tags in captions, which worked fine in old version.

Downgrading to knitr_1.43 does as a workaround. How to get appropriate numbering with knitr_1.44?

---
title: "My Title"
subtitle: "Subtitle"
author: "Me"
date:  "1/1/2016"
output:
   bookdown::html_document2: 
     toc: true
     toc_float: true
     toc_depth: 4
     toc_collapsed: true
     number_sections: true
     keep_md: yes
     theme: flatly
     citation_package: biblatex
header-includes: 
- \usepackage{amsmath}
- \usepackage{extarrows}
---
<style type="text/css">
  body{
    font-size: 11pt;
  }
  .tblCaptionBlue > caption{
    color: blue;
  }
  .tblCaptionRed > caption{
    color: red;
  }
</style>


```{r cars, fig.cap = "<b>An amazing plot</b>"}
plot(cars)
```

knitr_1.43

enter image description here

knitr_1.44

enter image description here

Note

sessionInfo()

## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] 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   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Europe/Zurich
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## loaded via a namespace (and not attached):
##  [1] digest_0.6.33     R6_2.5.1          bookdown_0.34     fastmap_1.1.1    
##  [5] xfun_0.40         cachem_1.0.8      knitr_1.44        htmltools_0.5.6  
##  [9] rmarkdown_2.24    cli_3.6.1         sass_0.4.7        jquerylib_0.1.4  
## [13] compiler_4.3.1    rstudioapi_0.15.0 tools_4.3.1       evaluate_0.21    
## [17] bslib_0.5.1       yaml_2.3.7        jsonlite_1.8.7    rlang_1.1.1

Solution

  • They were so kind and fixed the issue in dev version knitr_1.44.1. Install it from their repos=:

    install.packages('knitr', repos='https://yihui.r-universe.dev')