2

In order to allow underscores in a R Markdown script (whose output is pdf_document, with latex_engine: xelatex), I've added \usepackage{underscore} and \usepackage[english]{babel} (https://tex.stackexchange.com/a/321542, https://tex.stackexchange.com/a/561632).

It works for me, but not for my workmate's environment.

! LaTeX Error: File 'underscore.sty' not found.

I guess the problem is that our versions of pdflatex and R are different (pdfTeX 3.14159265-2.6-1.40.18 VS pdfTeX 3.14159265-2.6-1.40.21 and R version 4.0.3 VS R version 4.0.2), but why does this error appear if we both have the underscore.sty file in the following path (according to locate underscore.sty): /usr/share/texlive/texmf-dist/tex/latex/underscore/underscore.sty ?

I don't know if this is relevant, but he doesn't get any output when he runs kpsewhich underscore.sty in the sell, whereas my output is the path mentioned above.

What is wrong with his setup? What do you recommend us to do? Thanks for the help in advance and sorry if this question or similar has already been resolved.

3
  • Perhaps he has another tex system. R often has also tinytex. He should check in a log where article.cls is from. – Ulrike Fischer Jan 12 at 7:40
  • Thank you very much for your answer, Ulrike. If I run kpsewhich article.cls, the output I get is /usr/share/texlive/texmf-dist/tex/latex/base/article.cls, whereas he gets /home/ubuntu/.TinyTeX/texmf-dist/tex/latex/base/article.cls. According to pdflatex --version, I have TeX Live 2017 and he has TeX Live 2020. – LaTeXLover Jan 12 at 9:22
  • We have tried with tinytex::parse_install(text = "! LaTeX Error: File `underscore.sty' not found."), but it requires to run tlmgr update --self, and when we run this, another error appears (tex.stackexchange.com/questions/137428/tlmgr-cannot-setup-tlpdb) ... ☹️ – LaTeXLover Jan 12 at 12:08
1

We finally found a solution: \catcode`_=12 instead of \usepackage{underscore}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.