quarto-dev / quarto-r

R interface to quarto-cli
https://quarto-dev.github.io/quarto-r/
145 stars 24 forks source link

render quarto in R not generate the title page #210

Open caocloud opened 2 months ago

caocloud commented 2 months ago

Hi,

I am writing a code to generate a document to pdf using Qarto- R with the set up of title page image.

YAML format is below:


---
format: 
  titlepage-pdf:
    titlepage-bg-image: "logo4.png"
    titlepage-theme:
      bg-image-size: "1.8\\textwidth"
      bg-image-left: "0\\paperwidth"
      documentclass: article
---
```{r}
for ( i in 1: 100){
quarto_render(
    input= "quarto3.qmd",
    output_format = "pdf",execute = TRUE,
    output_file =  stringr::str_glue("{Filename[i]}.pdf"),
    execute_params = list(ID = ID[i],RegionID=2))
}


So, I have created a file called "qarto3.qmd" with the YAML at the top. when I render the report by click "Render" button. Everything is fine. The document can be generated with the title page (the image need to cover all the first page, not just as in the middle of the page). 

However, because I have multiple documents to run with the different params. In another file, I have used quarto_render. to run the code that can generate multiple documents. It did generate without any issues except for the title page. 

My current environment is 

"[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.3.433
      Path: C:\Program Files\RStudio\resources\app\bin\quarto\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....(None)

      Unable to locate an installed version of Python 3.
      Install Python 3 from https://www.python.org/downloads/

[>] Checking R installation...........OK
      Version: 4.4.0
      Path: C:/PROGRA~1/R/R-44~1.0
      LibPaths:
        - C:/Program Files/R/R-4.4.0/library
      knitr: 1.48
      rmarkdown: 2.28

[>] Checking Knitr engine render......OK"

Can you please help?

Thanks. 
cderv commented 2 months ago

Could you format your code correctly and with full reproducible example to have an example I can look at ?

See https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us

Thanks.

caocloud commented 2 months ago

Hi, I have updated my question. Thanks

cderv commented 2 months ago

Just to understand correctly: Are you calling quarto render on your qarto3.qmd file and this file is calling also quarto render itself ?

Just asking because there could be some side effect of having quarto render nested calls like that.

caocloud commented 2 months ago

Hi Christophe,

I test my code on the quarto3.qmd by clicking the "render" button. After everything looks fine.

I then run quarto render in a different Rmd file, which uses quarto::quarto_render function.

Chloe.

On Thu, 5 Sept 2024 at 23:54, Christophe Dervieux @.***> wrote:

Just to understand correctly: Are you calling quarto render on your qarto3.qmd file and this file is calling also quarto render itself ?

Just asking because there could be some side effect of having quarto render nested calls like that.

— Reply to this email directly, view it on GitHub https://github.com/quarto-dev/quarto-r/issues/210#issuecomment-2331748355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7VIPCFPJHS65IYQMFF23DZVBPBBAVCNFSM6AAAAABNVWCZV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZRG42DQMZVGU . You are receiving this because you authored the thread.Message ID: @.***>

cderv commented 2 months ago

Sorry for all my questions. I am just trying to understand everything correctly so that I can reproduce.

Is this the content of quarto3.qmd ?

---
format: 
  titlepage-pdf:
    titlepage-bg-image: "logo4.png"
    titlepage-theme:
      bg-image-size: "1.8\\textwidth"
      bg-image-left: "0\\paperwidth"
      documentclass: article
---
```{r}
for ( i in 1: 100){
quarto_render(
    input= "quarto3.qmd",
    output_format = "pdf",execute = TRUE,
    output_file =  stringr::str_glue("{Filename[i]}.pdf"),
    execute_params = list(ID = ID[i],RegionID=2))
}


Which means your are calling `quarto_render()` from within a .qmd file, right ? 
So you do `quarto render quarto3.qmd` (or call the render button), and then you expect the same document to also be rendered by knitr by calling `quarto_render()` in the cell ? 

Do I get it right ? 
caocloud commented 2 months ago

HI Christopher,

Sorry for not making it clear enough.

The Yaml is for the quarto3.qmd. I am not calling quarto_render within this (I use "render" button to run this file only). The quarto_render function is coded in a separate .RMD.

On Fri, 6 Sept 2024 at 18:13, Christophe Dervieux @.***> wrote:

Sorry for all my questions. I am just trying to understand everything correctly so that I can reproduce.

Is this the content of quarto3.qmd ?

---format: titlepage-pdf: titlepage-bg-image: "logo4.png" titlepage-theme: bg-image-size: "1.8\textwidth" bg-image-left: "0\paperwidth" documentclass: article---{r}for ( i in 1: 100){quarto_render( input= "quarto3.qmd", output_format = "pdf",execute = TRUE, output_file = stringr::str_glue("{Filename[i]}.pdf"), execute_params = list(ID = ID[i],RegionID=2))}

Which means your are calling quarto_render() from within a .qmd file, right ? So you do quarto render quarto3.qmd (or call the render button), and then you expect the same document to also be rendered by knitr by calling quarto_render() in the cell ?

Do I get it right ?

— Reply to this email directly, view it on GitHub https://github.com/quarto-dev/quarto-r/issues/210#issuecomment-2333498088, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7VIPEXR3UI6WVML2GXPSTZVFP2RAVCNFSM6AAAAABNVWCZV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZTGQ4TQMBYHA . You are receiving this because you authored the thread.Message ID: @.***>

caocloud commented 2 months ago

Hi,

I have attached my code in here as an example.

I have a title_page-test.qmd to generate pdf with title page. Using "render" button, I have the pdf file with title page.

In another .rmd file, I use quarto_render to render the document. It no longer provides me the title page.

Hope this is clear to you.

On Fri, 6 Sept 2024 at 18:13, Christophe Dervieux @.***> wrote:

Sorry for all my questions. I am just trying to understand everything correctly so that I can reproduce.

Is this the content of quarto3.qmd ?

---format: titlepage-pdf: titlepage-bg-image: "logo4.png" titlepage-theme: bg-image-size: "1.8\textwidth" bg-image-left: "0\paperwidth" documentclass: article---{r}for ( i in 1: 100){quarto_render( input= "quarto3.qmd", output_format = "pdf",execute = TRUE, output_file = stringr::str_glue("{Filename[i]}.pdf"), execute_params = list(ID = ID[i],RegionID=2))}

Which means your are calling quarto_render() from within a .qmd file, right ? So you do quarto render quarto3.qmd (or call the render button), and then you expect the same document to also be rendered by knitr by calling quarto_render() in the cell ?

Do I get it right ?

— Reply to this email directly, view it on GitHub https://github.com/quarto-dev/quarto-r/issues/210#issuecomment-2333498088, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7VIPEXR3UI6WVML2GXPSTZVFP2RAVCNFSM6AAAAABNVWCZV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZTGQ4TQMBYHA . You are receiving this because you authored the thread.Message ID: @.***>

cderv commented 2 months ago

The Yaml is for the quarto3.qmd. I am not calling quarto_render within this (I use "render" button to run this file only). The quarto_render function is coded in a separate .RMD.

Ok it makes sense. So in your first post above, the code block is not a single block. It is first a YAML which is the only content of the .qmd Then the R code of a cell in a Rmd file.

You could probably edit again to make this more clear.

In another .rmd file, I use quarto_render to render the document. It no longer provides me the title page.

Is there a reason to use .Rmd and not .qmd ? Just trying to get the all use case.

I'll try to reproduce based on the information provided

cderv commented 2 months ago

In fact you are also using an extension right ? where is titlepage-pdf coming from ?

If so, did you open an issue in the extension repo already ?

We ask you to provide reproducible example to save time and avoid all this back and forth. Please provide all the necessary information, that will really help us !

caocloud commented 2 months ago

I used the extension from this link: https://nmfs-opensci.github.io/quarto_titlepages/

I have not opened an issue in the extension repo. I thought it might have something to do with the metadata that the quarto-render does not recognise the YAML input of an image.

for why using knirt instead of a quarto, I have tried it by putting the same code from RMD to Quarto. It behaves the same way since both use knirt engine.

On Fri, 6 Sept 2024 at 19:05, Christophe Dervieux @.***> wrote:

In fact you are also using an extension right ? where is titlepage-pdf coming from ?

If so, did you open an issue in the extension repo already ?

We ask you to provide reproducible example to save time and avoid all this back and forth. Please provide all the necessary information, that will really help us !

— Reply to this email directly, view it on GitHub https://github.com/quarto-dev/quarto-r/issues/210#issuecomment-2333599372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7VIPGIMTS7GNYBGIQVJT3ZVFV43AVCNFSM6AAAAABNVWCZV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZTGU4TSMZXGI . You are receiving this because you authored the thread.Message ID: @.***>

cderv commented 2 months ago

Thank for the clarification.

To be honest, it would really help me (and save time) if you can provide a github repo with an example of what you are trying to do, or share a bundle zip you upload in this issue. This way, I'll be sure to try the same thing as you and understand you problem correctly;

Right now, I feel I need to try a few things and guess with my best knownledge - which honestly is not efficient and not the best way to help.

Thank you very much !