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

Double-spaced table of contents #2172

Open
rmcd1024 opened this issue Jun 23, 2021 · 13 comments
Open

Double-spaced table of contents #2172

rmcd1024 opened this issue Jun 23, 2021 · 13 comments
Labels
reprex needs a minimal reproducible example

Comments

@rmcd1024
Copy link

Rendering a file to pdf using either rmarkdown 2.9 or 2.9.1 on xubuntu 20.04 with texlive installed generates a double-spaced table of contents. However, running pdflatex on the intermediate tex file converts the toc to single-spaced. Running pandoc directly on test.Rmd from the command line also creates a single-spaced toc.

To dup: render the file test.Rmd to pdf (Rscript -e "rmarkdown::render('test.Rmd')"):

test.Rmd:

---
output:
  pdf_document:
    toc: true
    keep_tex: true
    number_sections: true
toccolor: 'red'
---

# Chapter 1
## subchapter 1.1
### subsubchapter 1.1.1
## subchapter 1.2
## subchapter 1.3
# Chapter 2

Result from Rscript -e "rmarkdown::render('test.Rmd')"

Result from running pdflatex test.tex (the intermediate file created by rmarkdown) or pandoc -f markdown --to latex --toc -o test.pdf test.Rmd

R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

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.27     evaluate_0.14     glue_1.4.2       
  graphics_4.1.0    grDevices_4.1.0   highr_0.9         htmltools_0.5.1.1
  jsonlite_1.7.2    knitr_1.33        magrittr_2.0.1    markdown_1.1     
  methods_4.1.0     mime_0.10         rlang_0.4.11      rmarkdown_2.9.1  
  stats_4.1.0       stringi_1.6.2     stringr_1.4.0     tinytex_0.32     
  tools_4.1.0       utils_4.1.0       xfun_0.24         yaml_2.2.1       

Pandoc version: 2.14.0.3

This issue was also reported at https://stackoverflow.com/questions/68060767/rmarkdown-produces-double-spaced-table-of-contents

@cderv
Copy link
Collaborator

cderv commented Jun 23, 2021

Hi @rmcd1024,

Thanks for the reproducible example.

When I knit you test document using the knit button inside RStudio IDE, or using R command line I correctly get expected result I believe
image

I am not sure where difference could lie. I tested on Windows though. I'll try on Linux Ubuntu to check.

Also I am using TinyTeX (https://yihui.org/tinytex/) but if this is the difference, this would mean this is a TeX Live version difference.

@cderv
Copy link
Collaborator

cderv commented Jun 23, 2021

I tested on Ubuntu 20.04 and I got the TOC with the spaces but with all the methods!

image

I don't know about the differences possible between OS.

@yihui do you know anything about this kind of difference ? Thanks

@rmcd1024
Copy link
Author

Just to complicate this a little bit, my original report actually pertains to Ubuntu 18.04 (I have two machines with different Ubuntu versions). Apologies for the error. When I try to replicate under a fresh Xubuntu 20.04 install, I can't. The TOC is correctly single-spaced by rmarkdown, both versions 2.9 and 2.9.1. So it sounds like you're replicating under 20.04 and I'm not. Very strange.

And to be clear, you're saying that if you run pdflatex test.tex on the intermediate file it doesn't correct the spacing? I've never had that fail.

@yihui
Copy link
Member

yihui commented Jun 23, 2021

I tried the example on macOS and I got the single-spaced TOC.

@cderv As the first step of investigation, you need to compare the intermediate .tex files, and see if the .tex that produces double-spaced TOC is identical to the one that produces single-spaced TOC. If they are identical, we need to compare the versions of LaTeX packages on the two operating systems (tinytex::tl_sizes(field = c('lcat-version', 'localrev'))).

@rmcd1024
Copy link
Author

I just verified that that .tex files emitted by rmarkdown are identical for 18.04 and 20.04 (of course except for the Ubuntu version reported by xfun::session_info()). I also double checked and verified that running pdflatex on the tex file created a single-spaced TOC.

@rmcd1024
Copy link
Author

Also, in case it's relevant, here is the output produced by pdflatex --version:

18.04:
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian)
kpathsea version 6.2.3
Compiled with libpng 1.6.34; using libpng 1.6.34
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with poppler version 0.62.0

20.04:
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian)
kpathsea version 6.3.1
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.01

@yihui
Copy link
Member

yihui commented Jun 24, 2021

@rmcd1024 Great! That's super helpful! Now I think one possible solution is to use TinyTeX (tinytex::install_tinytex()) instead of Ubuntu/Debian's texlive package. It's easy to make sure the two systems have exactly the same version of TinyTeX, but it is impossible to apt install the same version of TeX Live in the two systems.

@rmcd1024
Copy link
Author

@yihui I had thought that you recommended against installing tinytex when there is an existing install such as texlive. Am I remembering correctly and if so is that still true?

Also, I remain confused about why the double-spaced TOC problem arose in the first place. I'd been running 18.04 for several years without this issue. In my case, one additional compile fixed the problem, which made me think it might be a pandoc issue, not a texlive issue, but downgrading pandoc to 2.11 doesn't fix the problem. On the other hand, I don't know what's happening with @cderv that he always gets double-spaced TOC. I haven't seen that.

@yihui
Copy link
Member

yihui commented Jun 24, 2021

I had thought that you recommended against installing tinytex when there is an existing install such as texlive. Am I remembering correctly and if so is that still true?

I don't recommend installing both TinyTeX and TeX Live only because rmarkdown/knitr will always use TinyTeX if it is installed, but if you compile other .tex documents, I cannot guarantee which LaTeX distribution will be used, since it depends on your PATH variable (which decides if TinyTeX or TeX Live has higher precedence). If you don't care about that, you can definitely install both in your system.

@cderv
Copy link
Collaborator

cderv commented Dec 23, 2021

FWIW I can't reproduce this difference anymore. So I don't really know if there is something to fix or if changing may have change in Pandoc's template. So not sure what should be fixed or looked into.

Maye we'll close this discussions, and reopen if we stumble upon such difference in the future. 🤔

@cderv cderv added the reprex needs a minimal reproducible example label Dec 23, 2021
@EstherRBirch
Copy link

EstherRBirch commented Aug 22, 2022

I have also been having this problem for quite a while. I am knitting my Markdown files on a Windows 10 machine (Surface Pro 7), running R 4.2.1 and RStudio 2022-07.1-554. I'm using MikTex on Windows. When I run the test toc script provided by OP above, I get the same result. I have not been able to find anyone else having the same issue using the same files, so it's been frustrating trying to figure out the issue. I have been knitting all my files on an old PC that hasn't been updated in a few years. I have tried to revert packages such as knitr and pandoc to the versions on my old computer, but that doesn't work. I can compile the resulting tex file using TexStudio, and the toc is single-spaced as intended. I am knitting using TinyTex and pdflatex (toggling these settings in RStudio also does nothing). The markdown package is version 1.1.

An interesting note is that when I run tinytex::tl_sizes()' on my old computer, it returns "TeX Live does not seem to be installed." The old computer has tinytex V0.25, while the new computer has tinytex V0.41. I'm not sure where the TeX Live is coming in from. I can't find any texlive files on my computer, although the tinytex::tl_sizes(field = c('lcat-version', 'localrev')) command returns the following information regarding TeX Live:
image

Do you have any suggestions for what is going on?

@EstherRBirch
Copy link

EstherRBirch commented Aug 22, 2022

For giggles, I tried to install tinytex using tinytex::install_tinytex() and got the following return:
image
It's the part that says "conflicting [pdf]tex program found on the system path" that is interesting. My old computer also had MikTex (V2.9) installed, so I guess I may have some kind of conflict with texlive, but I don't know how to remedy the issue. Knitting after running this code still resulted in a double-spaced toc.

@antonr4
Copy link

antonr4 commented May 8, 2024

I have just experienced the same problem on an arm Mac. My texlive was old (2015) and would no longer build a book with bookdown. Using TinyTeX built the book but gave double-spaced contents. I am using the most recent R and RStudio and have deleted all texlive files (I think), uninstalled TinyTeX and installed it again. Has anyone found a solution in the two years since this was last commented on? Thanks for any help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

5 participants