Knitting without preview word and pdf

Hello R Community

I have as an operating system Ubuntu 22.04 LTS and Rstudio 2022.07.1 Build 554. When I knit a document I don't see the preview in the formats word and pdf but I see the preview in html. I don't know what is happening? Also my rmarkdown is version 2.16

Hi @luifrancgom!

There are a couple different reasons why this might be happening. These options are summarized well in this article on StackOverflow.

Thank you for the answer. The problem is that the options are there. When I try to knit as pdf or word the preview doesnt appear.

Please do share more information about the file or project you are trying to render from, the log message you may have or any other information that would help know better what is running on your computer. It is hard to help without more information than a generic issue behavior.

Thank you

Thank you for the answer. This is the warning I get

library(rmarkdown)
render(input = "test.Rmd", 
       output_format = "pdf_document")
#> Warning in normalizePath(path, winslash = winslash, mustWork = mustWork):
#> path[1]="test.Rmd": No such file or directory
#> Error in abs_path(input): The file 'test.Rmd' does not exist.

Created on 2022-09-13 by the reprex package (v0.3.0)

The file is normal Rmarkdown:


title: "Untitled"
author: "Luis Francisco Gomez Lopez"
date: '2022-09-13'
output:
pdf_document: default
html_document: default

knitr::opts_chunk$set(echo = TRUE)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)

Including Plots

You can also embed plots, for example:

plot(pressure)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

This means that the test.Rmd files is not found in the current working directory.

Where are you calling rmarkdown::render from ?

If you call list.files() do you see test.Rmd in the result ?

  1. I am calling rmarkdown::render from the project where the file is: test.R. This is the tree of the project:

β”œβ”€β”€ ./001_The Data Scientist’s Toolbox
β”œβ”€β”€ ./002_R_programming
β”œβ”€β”€ ./Data Science: Foundations using R Specialization.Rproj
β”œβ”€β”€ ./test.html
β”œβ”€β”€ ./test.pdf
β”œβ”€β”€ ./test.R
└── ./test.Rmd

  1. I see the following files when I call list.files

list.files()
[1] "001_The Data Scientist’s Toolbox"
[2] "002_R_programming"
[3] "Data Science: Foundations using R Specialization.Rproj"
[4] "test.html"
[5] "test.pdf"
[6] "test.R"
[7] "test.Rmd"

I see test.Rmd in there. I reaally don't understand then :thinking:

Did you update all the packages already to latest available version ?
Can you share the traceback() results after you have the error when calling rmarkdown::render() ?

This will show us exactly were it happens.

but to be clear:

  • Does the rendering to PDF works ?
  • Is the issue only that Preview does not open in the RStudio IDE ?

Hello cderv

Thank you for your help.

Yes I update all the packages to the lastest version.
This is the result of the traceback

library(rmarkdown)
render(input = "test.Rmd", 
       output_format = "pdf_document")
#> Warning in normalizePath(path, winslash = winslash, mustWork = mustWork):
#> path[1]="test.Rmd": No such file or directory
#> Error in abs_path(input): The file 'test.Rmd' does not exist.

traceback()
#> No traceback available

Created on 2022-09-20 by the reprex package (v0.3.0)

Yes. The rendering of the pdf works
Yes. Is only the issue that the preview does not open in the RStudio IDE

It seems R is having problems parsing the file path, does the path contain empty spaces or non-ASCII characters? If so, try moving your project files to a folder that doesn't have these kind of characters on its path.

Thank you for your help. The problem is that doesn't work in any file of my computer. The same error is generated in other files.

Ok I missed this part. It means there is an issue with the IDE mainly, or interaction.

I believe for the preview to work, you need to use the Knit button. Does it give you the same log message ?

Which version of the RStudio IDE are you using also ?
What is your configuration here ?

If you have it like this, then no preview. If you select one, you'll have a preview either in RStudio bundled PDF viewer, or your system one.

Otherwise, RStudio IDE does not yet support showing PDF in the same viewer pane than the HTML document for examples.

So this config is confusing and I believe have no effect for Rmd
image

2 Likes

Thank you for your help. I fixed the error thank to you. The problem was with the option PDF Preview in Sweave.
Thanks again!!!

1 Like

This topic was automatically closed 7 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.