Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footnotes not converting to sidenotes using tufte/tint #67

Closed
sjoleary opened this issue Jun 27, 2019 · 4 comments
Closed

Footnotes not converting to sidenotes using tufte/tint #67

sjoleary opened this issue Jun 27, 2019 · 4 comments

Comments

@sjoleary
Copy link

stackoverflow post: https://stackoverflow.com/questions/56754848/footnotes-not-converting-to-sidenotes-using-tufte-tint

I am using the tufte/tint R packages to produce html documents using Rstudio-server (v1.2.1335) and R version 3.6.0 on a x86_64-redhat-linux-gnu platform.

Footnotes inserted using ^[side note] are shown in the main body with the superscript in the correct location but no footnote in the margin (or anywhere else).

References/citations are correctly rendered as sidenotes and does using margin_note().

I updated the tufte and tint packages and rmarkdown to the newest versions, as well as pandoc.

I previously rendered the same document on a Rstudio-desktop installation on a windows machine running pandoc at a version below 2.x which produced the expected format for the sidenotes inserted using a footnote. Updating Rstudio and pandoc to it's most recent release on that windows machine resulted in the document no longer being rendered with correct footnotes/sidenotes.

I am not getting an error messages nor am I familiar enough with what is going on under the hood to even know where to start to figure out why the newer pandoc version doesn't seem to render them correctly and/or how to fix the issue or create a workaround.

Any suggestions?

xfun::session_info('tufte') gives:

R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Scientific Linux 7.6 (Nitrogen), RStudio 1.2.1335

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
  LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

Package version:
  base64enc_0.1.3 digest_0.6.19   evaluate_0.14   glue_1.3.1      graphics_3.6.0  grDevices_3.6.0 highr_0.8      
  htmltools_0.3.6 jsonlite_1.6    knitr_1.23      magrittr_1.5    markdown_1.0    methods_3.6.0   mime_0.7       
  Rcpp_1.0.1      rmarkdown_1.13  stats_3.6.0     stringi_1.4.3   stringr_1.4.0   tinytex_0.14    tools_3.6.0    
  tufte_0.5.1     utils_3.6.0     xfun_0.8        yaml_2.2.0  

By filing an issue to this repo, I promise that

  • [x ] I have fully read the issue guide at https://yihui.name/issue/.
  • [x ] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('tufte'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/tufte').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [x ] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Member

yihui commented Jun 28, 2019

Since you are using RStudio, there is no need to install Pandoc separately. I suspect this issue was caused by a higher version of Pandoc. Sounds like a similar issue to #64.

@sjoleary
Copy link
Author

sjoleary commented Jun 28, 2019

yes, my suspicions also lie with pandoc being to blame - especially since my troubleshooting revealed that using the older version of Rstudio I was using on my windows desktop bundled with a pandoc version lower than 2.x correctly rendered the footnotes but once I updated to the most recent Rstudio version (which comes bundled with the most recent pandoc version) it no longer correctly rendered the footnotes.
I tried poking around previous issues/stackoverflow posts but even with related issues (e.g. the one you are referencing which fixes the references in the margin which is working for me probably thanks to that pull request) but for a lot of them even with the posted workaround I can't even figure out where they are inserting the code (the YAML header? a file with parameters for pandoc?).
I have very little experience with how pandoc/knitr work under the hood converting Rmd to html (or pdf) files so even though I'm pretty sure I've pinned it to the newer pandoc version causing the issue, I'm still trying to find the "source files" (or even if they are called source files) that are "instructing" how knitr/pandoc should render the footnotes to figure out why pandoc is no longer correctly converting them correctly.
Based on the pull request you referenced am I correct in assuming that these lines in the html.R file control the formatting of footnotes as sidenotes (line 56 and following)?

# replace footnotes with sidenotes
    for (i in seq_along(notes)) {
      num = sprintf(
        '<a href="#%s%d" class="%s" id="%sref%d"><sup>%d</sup></a>',
        fn_label, i, if (pandoc2) 'footnote-ref' else 'footnoteRef', fn_label, i, i
      )
      con = sprintf(paste0(
        '<label for="tufte-sn-%d" class="margin-toggle sidenote-number">%d</label>',
        '<input type="checkbox" id="tufte-sn-%d" class="margin-toggle">',
        '<span class="sidenote"><span class="sidenote-number">%d</span> %s</span>'
      ), i, i, i, i, notes[i])
      x = gsub_fixed(num, con, x)
    }
    # remove footnotes at the bottom
    if (length(footnotes$range)) x = x[-footnotes$range]

@yihui
Copy link
Member

yihui commented May 8, 2020

I think this issue has been fixed in the development version:

remotes::install_github('rstudio/tufte')

@yihui yihui closed this as completed May 8, 2020
@github-actions
Copy link

github-actions bot commented Dec 4, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants