Problem of compiling Rmd to PDF

Hello Everyone,

I encounter issue when compile Rmd file to PDF file in Rstudio on MacOS 12. I have installed R 4.2.1, latest Rstudio, MacTeX and TexLive 2022 (via macport). From configuration of TexStuio app, it seems TexLive 2022 is now in use.

The problem is Rstudio will stuck at final step of making knit.md output. I here copy the command from Rstudio log window:

/Applications/RStudio.app/Contents/MacOS/quarto/bin/tools/pandoc +RTS -K512m -RTS test1.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test1.tex --lua-filter /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in'

There is no error or warning message but just hanging there for long time. I tried to run above statement in terminal and it gave me same symptom.

The test file is quite simple as below:

---
title: "Test File"
output: pdf_document
date: "2022-10-05"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Introduction

Here 1

By the way, I can successfully compile TeX file generated by Rstudio in TexStudio. But when I tried to use pdflatex or latex to compile it in terminal, I got error telling me lmodern.sty is missing. This happened also in previous MacOS 10.15, and I remembered there are many sty files missing and I downloaded them manually to put together with above generated tex file and finally I could successfully compile it in terminal.

So I am not sure if that is the issue of Rstudio, or knit, or Texlive 2022 in Macport. I do want to use my installed MacTex, but texlive2022-basic was installed together with gr-osmosdr :roll_eyes:

Please provide me your suggestions and thoughts. Thank you so much in advance.

Hello again!
I just keep doing some research in Mac, and I found TeXStudio in fact is using MacTex installation there. That explains why it compile generated tex without issue of missing sty files. Yet Macport Texlive 2022 it does have the issue!
Well, I noticed xelatex was not "ruined" by Macport, therefore I change the setting in RStudio from pdflatex to xelatex thus it will use properly configured MacTex. I confirmed xelatex successfully compiled that tex file. However, Rstudio is hanging at above long statement containg lua scripts again... :face_exhaling:

Well, it seems that:

  1. Is there anything wrong with Tex? Yep because macport's texlive-basic is way too basic.
  2. Whether it led to issue of Rstudio? Nope, since correct xelatex shows exactly same symptom.

:thinking: Please help me with any suggestions and thoughts. Thank you again!

Hi @zhangaa,
Welcome to the RStudio Community Forum.

I'm not sure that this is the problem but I noticed that you had "escaped" the back-tick characters in the .Rmd script (showing as \`\`\`). That is not required and correcting it by removing the back-slashes may fix the problem.

Hi Davoww,

Thank you for reply.
The escaped quota (\’) is because I would like to show source code of my Rmd content in Discourse forum which will render my markdown.
In my source code of Rmd file, it is regular one but not escaped ones. Otherwise Rstudio may not be able to generate Tex file from that.

Thank you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.