Issue Executing `rmarkdown::render()` Repeatedly

I have recently installed TinyTex on my RStudio Server Open platform. While users are able to successfully knit their .Rmd files using the RStudio UI, we are running into issues using rmarkdown::render() under specific circumstances.

The environment is:

  • R version 4.1.2
  • RStudio 2021.09.2+382 "Ghost Orchid" Release (fc9e217980ee9320126e33cdf334d4f4e105dc4f, 2022-01-04) for CentOS 8
  • Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0
  • TeX 3.141592653 (TeX Live 2022)
  • kpathsea version 6.3.4
  • rmarkdown 2.11
  • knitr 1.37
  • tinytex 0.36

From a fresh R session, rmarkdown::render() works perfectly fine when rendering an .Rmd file into a .pdf file:


However, when attempting to render the exact same file in the same session as before - without the environment explicitly changing - I receive the following error.

! Undefined control sequence.
<argument> >{\raggedright \arraybackslash 
                                          }p{.5in}|>{\raggedright \arrayback...
l.78 ...edright\arraybackslash}p{1in}|l|r|l|l|l|l}

What is causing this issue? It seems the process is running into issues when the .tex file is generated, as I see the following issues when trying to compile the .tex file into .pdf on repeated attempts:

Restarting the R session and deleting the files results in a successful rmarkdown::render(). I am also executing in a home directory, so I have full read/write permissions.

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.


Sorry for the delay. Summer is slow time and I was not around recently.

Can you share more on the content of the file ? Without it it will be hard to know what is going on.

The fact that the file render correctly means there is no bug in rmarkdown it seems. Do you think of anything that could have changed between the two rendering ? Thanks

Thanks for re-opening this, as the problem is still present.

Would you need the entire .tex file? If so, I'll try to recreate the issue with non-proprietary data.

I can guide you in debug or you can provide a reproducible example so that I can redo on my side.

What is your Rmd content ?
Are you using a specific format ?

It seems you are missing some CTAN package dependencies which leads to some commands not fund.

Sorry about my delay. Just getting back from a short leave.

I appreciate the help! What do we need to do for you to guide me in debug? Not sure if I'll be able to provide a reproducible example, but if you let me know how I can do that, I'd be happy to provide it.

Rmd content isn't anything special, just printing some data tables using kableExtra::kable().
Outputting the content as a pdf_document.

The fact that the first render produces a correct pdf file also shows that the LaTeX environment is okay.
So what happens outside these renders?
Somewhere the environment where the knitting is done is changed.
Of course: no reason otherwise to repeat the render process.
So where is the change that leads to an error in the second render: a data.frame that is now empty, a different path taken in the rmd file that leads to different LaTeX generated code?

@djslp I think you are encountering this issues possibly:

Something related to some dependencies required by what kableExtra is doing and that are not automatically added like they should. See doc about this