Closed szmsu2011 closed 10 months ago
The reinstallation was successful but I immediately ran into issues when trying to render a bookdown document with bookdown::render_book() or directly compile a LaTeX document with tinytex::latexmk(), they both stopped by error
Does it happens only with this project ?
Or does it happen with a simple pdf_document()
rendering ?
stopped by error
Can you share the whole error please. What is surrounding the error in the log file.
In the SO post you shared we see
Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO)
)
\Hy@SavedSpaceFactor=\count411
! LaTeX socket Error: Sockets can only be declared at top-level!
For immediate help type H <return>.
So this could be related to intcalc
package maybe.
We haven't add this issue ourselves with the latest version of TeX Live.
Also TinyTeX is tested before being released daily (today's tests in gha) and we have no issue while rendering our tests docs (simple document or demo book).
It seems related to TeX Live itself or maybe this comes from a specific CTAN package used in your project.
As mentioned on community, this errors could come from Socket package: https://ctan.space-pro.be/tex-archive/macros/latex-dev/base/ltsockets-doc.pdf
related to another.
Anyhow, hard to debug for us without being able to reproduce.
You could try simplify your project until it renders to find what could be the cause.
The answer at https://stackoverflow.com/a/77503626/559676 can fix the problem, and I'm still investigating it to understand why (it seems to be caused by a recent update of hyperref).
Here is a minimal reprex:
---
header-includes:
- \usepackage{setspace}\spacing{1}
output:
pdf_document:
keep_tex: true
---
Test.
Thanks @Yihui!
Yes, it seems like the suggestion at https://stackoverflow.com/a/77503626/559676 did fix the issue for me. Previously I did not bother but after removing/commenting out every single control sequence related to the setspace
package from the .cls
file in my project fixed the problem.
Before the update I was using a very old version of TinyTeX and the setspace
package. Can’t recall the exact versions now but I remembered it was installed in late 2020.
As explained in the hyperref issue (https://github.com/latex3/hyperref/issues/315)
\spacing{1}
is faulty syntax. It opens a group and hyperref is then loaded inside this group. The new socket code does not like this.
Remove the command or replace it with a correct command from setspace.
@u-fischer Thanks! That's very helpful!
@szmsu2011 I wonder how you got the command \spacing{}
in your document. For Markdown documents, you can use the variable linestretch
in YAML to set the spacing: https://pandoc.org/MANUAL.html#variables-for-latex, which will generate the correct command as @u-fischer mentioned (i.e., \setstretch{}
, instead of \spacing{}
).
It was in the .cls
file from a bookdown template I am using. Although the file was quite large, only a very small proportion contributed to issue:
\RequirePackage{setspace}
\spacing{1.5}
\AtBeginDocument{%
\ifsinglesp@%
\singlespacing%
\else%
\doublespacing%
\fi%
}
The prior is not a good way to control line spacing but I wasn’t aware of them until they became a problem.
@szmsu2011 I see. I think it will be great if you can notify the template author to correct the problem.
Today, I reinstalled TinyTeX with
tinytex::reinstall_tinytex()
. The reinstallation was successful but I immediately ran into issues when trying to render a bookdown document withbookdown::render_book()
or directly compile a LaTeX document withtinytex::latexmk()
, they both stopped by errortinytex::latexmk()
was working immediately before I reinstalled TinyTex, and this was the only change made (the issue persists after updating all softwares, R, RStudio, packages, macOS, etc.).Upon searching on the Internet I only managed to find only two reports (in fact, by the same person) for the same issue, very recently, on Nov 11, 2023, so it seems like a new-emerging issue:
https://community.rstudio.com/t/latex-socket-error-cannot-knit-rmd-document/177023 https://stackoverflow.com/questions/77465287/latex-socket-error-cannot-knit-rmd-document
I also tried to reinstall a previous version of TinyTex:
The error persists after trying many versions.
With the information and knowledge I have, I cannot tell if the issue is on this package or the TeX Live distribution.
Session info:
By filing an issue to this repo, I promise that
xfun::session_info('tinytex')
. 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/tinytex')
.I understand that my issue may be closed if I don't fulfill my promises.