rstudio / bookdown

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

(ref:textreference) won't expand in gitbook TOC when used as heading #528

Open brooksambrose opened 6 years ago

brooksambrose commented 6 years ago

Building the following as gitbook, the text reference is expanded in the body but not in the TOC

---
title: "A Book"
author: "Frida Gomam"
site: bookdown::bookdown_site
documentclass: book
output:
  bookdown::gitbook: default
  bookdown::pdf_book: default
---

# H1

Some content.

(ref:H2) Heading 2

## (ref:H2) {#h2}

Some content

Yields

Session info:

> devtools::session_info('bookdown')
Session info -------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.2 (2017-09-28)
 system   x86_64, linux-gnu           
 ui       RStudio (1.1.383)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       UTC                         
 date     2018-02-01                  

Packages -----------------------------------------------------------------------------------------------------------------------
 package   * version date       source                           
 backports   1.1.1   2017-09-25 CRAN (R 3.4.2)                   
 base64enc   0.1-3   2015-07-28 CRAN (R 3.4.2)                   
 bitops      1.0-6   2013-08-17 CRAN (R 3.4.2)                   
 bookdown  * 0.6.2   2018-02-01 Github (rstudio/bookdown@d3570d3)
 caTools     1.17.1  2014-09-10 CRAN (R 3.4.2)                   
 digest      0.6.12  2017-01-27 CRAN (R 3.4.2)                   
 evaluate    0.10.1  2017-06-24 CRAN (R 3.4.2)                   
 graphics  * 3.4.2   2017-11-01 local                            
 grDevices * 3.4.2   2017-11-01 local                            
 highr       0.6     2016-05-09 CRAN (R 3.4.2)                   
 htmltools   0.3.6   2017-04-28 CRAN (R 3.4.2)                   
 jsonlite    1.5     2017-06-01 CRAN (R 3.4.2)                   
 knitr     * 1.17    2017-08-10 CRAN (R 3.4.2)                   
 magrittr  * 1.5     2014-11-22 CRAN (R 3.4.2)                   
 markdown    0.8     2017-04-20 CRAN (R 3.4.2)                   
 methods   * 3.4.2   2017-11-01 local                            
 mime        0.5     2016-07-07 CRAN (R 3.4.2)                   
 Rcpp        0.12.13 2017-09-28 CRAN (R 3.4.2)                   
 rmarkdown   1.6     2017-06-15 CRAN (R 3.4.2)                   
 rprojroot   1.2     2017-01-16 CRAN (R 3.4.2)                   
 stats     * 3.4.2   2017-11-01 local                            
 stringi     1.1.5   2017-04-07 CRAN (R 3.4.2)                   
 stringr   * 1.2.0   2017-02-18 CRAN (R 3.4.2)                   
 tinytex     0.3.1   2018-02-01 Github (yihui/tinytex@0c8b1f8)   
 tools       3.4.2   2017-11-01 local                            
 utils     * 3.4.2   2017-11-01 local                            
 xfun        0.1.5   2018-02-01 Github (yihui/xfun@5e238ac)      
 yaml        2.1.14  2016-11-12 CRAN (R 3.4.2)                   
> rmarkdown::pandoc_version()
[1] ‘1.19.2.1’
> system('pdflatex --version')
pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian)
kpathsea version 6.2.2
Copyright 2016 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.28; using libpng 1.6.28
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with poppler version 0.48.0
cderv commented 3 years ago

It is not really a bug in fact. With gitbook, text reference were introduce to simplify the use of special syntax in figure caption. It only work in the body for now. references won't be resolved in the toc.

I know it has been some time but is there a specific use case behind using text reference in headers ?

We could maybe look into improving the support to headers but it would be interesting to know the benefit for a use case.

Thanks you !