# Load the rmarkdown package library(rmarkdown) # Set the working directory to the location of your R Markdown file setwd("C:/wd_for_R/exercise_sheet_2") # Render the R Markdown file to PDF and HTML render("exercise_2.Rmd", output_format = "pdf_document") ##Console: ```processing file: exercise_2.Rmd |........ | 8% (setup) Quitting from lines 10-18 ( exercise_2.Rmd) Error in parse_block(g[-1], g, params.src, markdown_mode) : Duplicate chunk label 'setup', which has been used for the chunk: # Load the rmarkdown package library(rmarkdown) # Set the working directory to the location of your R Markdown file setwd("C:/wd_for_R/exercise_sheet_2") # Render the R Markdown file to PDF and HTML render("exercise_2.Rmd", output_format = "pdf_document")
Regarding point 1:
- you say that you have installed MikTex. Then I do not see why you would need
- You also say that you get an error on the
try to execute the functions in your script one line at a time and see which packages have to be updated.
view_pdfis not a function of
tinytexthat you can use: it does not exist
and the name suggests that you want to view a pdf-file. How did you create that file?
Point 2 suggests that you managed to create an HTML-file.
Did you change the YAML (the prefix of the RMD-file) to indicate that a pdf-file should be rendered? E.g.
--- title: "Untitled" author: "me" date: '2022-07-16' output: pdf_document: keep_tex: TRUE html_document: default ---
I need to render the Rmd file into 2 formats: PDF and HTML. The HTML output is successful.
Got this after I used your codes as the prefix of my file:
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.5.13) 14 MAY 2023 02:28
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
! Emergency stop.
Here is how much of TeX's memory you used:
3 strings out of 478006
113 string characters out of 5837259
1850993 words of memory out of 5000000
20284 multiletter control sequences out of 15000+600000
512287 words of font info for 32 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
0i,0n,0p,1b,6s stack positions out of 10000i,1000n,20000p,200000b,200000s
! ==> Fatal error occurred, no output PDF file produced!
Hi @Philmocoucou ,
I do not recognize a clear error message in your pdfTex output.
Are you sure this is all of your output?
Maybe one of the forum members with more experience with TEX output can help (?)
Hello, I have updated the problem. Could you please take a look at it?
Thank you in advance for your help!
Hello @Philmocoucou ,
I am not sure what you mean by "I have updated the problem".
To me, it does not look at your original problem at all.
But I see now a clear error mentioned (although I don't see why the html version would render and the pdf version would fail):
Error in parse_block(g[-1], g, params.src, markdown_mode) : Duplicate chunk label 'setup', which has been used for the chunk ....
This suggests to me that you maybe try to use the render function in exercise_2.Rmd . You should not do this:
use your script with the
render function and your Rmd file is a complete file with YAML, one setup chunk and other text and code chunks.
I hope this helps.
If not then answer to this post with the full script and the full Rmd file that you use, while clearly indicating what is in the script and what is in the Rmd file. The Rmd file should be enclosed with backticks: assuming you have at most 3 consecutive backticks in the Rmd file enclose it with 4 backticks.
In this way we can see the chunks and YAML. For the 'full' Rmd file you can of course leave out anything that you don't want to share, but make sure that the structure is the same.
So let us see the script, the Rmd-file and optionally output messages clearly delimited.
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.