quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.96k stars 326 forks source link

Supporting file are cleanup to soon when using multiformat #8373

Open Sciemon opened 10 months ago

Sciemon commented 10 months ago

Bug description

An mwe can be found in the github repo https://github.com/Sciemon/issue_figures_folder

Somehow latex assumes the figures are in a 'mediabag' folder that does not exist.

Steps to reproduce

It is only possible to render (with quarto render ...) the file 'model_requirements.qmd' if 'docx: default' is deleted from the yaml.

Expected behavior

if 'docx: default' is deleted, the pdf is rendered

Actual behavior

Otherwise latex throws the following error:

ERROR: compilation failed- error Unable to load picture or PDF file 'model_requirements_files/mediabag/figs/SVS_droop.pdf'.

} l.373 ...ements_files/mediabag/figs/SVS_droop.pdf}### ### Your environment - IDE: VSCode 1.85.2 - OS: Windows 10 ### Quarto check output Quarto 1.4.545 [>] Checking versions of quarto binary dependencies... Pandoc version 3.1.11: OK Dart Sass version 1.69.5: OK Deno version 1.37.2: OK [>] Checking versions of quarto dependencies......OK [>] Checking Quarto installation......OK Version: 1.4.545 Path: C:\Program Files\Quarto\bin CodePage: 1252 [>] Checking tools....................OK TinyTeX: v2024.01 Chromium: (not installed) [>] Checking LaTeX....................OK Using: TinyTex Path: C:\Users\seberlein\AppData\Roaming\TinyTeX\bin\windows\ Version: 2023 [>] Checking basic markdown render....OK [>] Checking Python 3 installation....OK Version: 3.11.7 Path: C:/Users/seberlein/AppData/Local/Programs/Python/Python311/python.exe Jupyter: 5.7.1 Kernels: python3 (-) Checking Jupyter engine render....Traceback (most recent call last): File "C:\Program Files\Quarto\share\jupyter\jupyter.py", line 21, in from notebook import notebook_execute, RestartKernel File "C:\Program Files\Quarto\share\jupyter\notebook.py", line 14, in from yaml import safe_load ModuleNotFoundError: No module named 'yaml' [>] Checking Jupyter engine render....OK
cderv commented 8 months ago

Some context about the issue.

This is similar to this one

but happens with mediabag supporting files and with output file name conflict.

Overall issue is order of cleanup for supporting files

I am putting back what I shared there at https://github.com/quarto-dev/quarto-cli/issues/6705#issuecomment-1706569288 by adapting to this use case.

Try just putting docx first as a workaround

diff --git a/model_requirements.qmd b/model_requirements.qmd
index 522edb4..3f12bf1 100644
--- a/model_requirements.qmd
+++ b/model_requirements.qmd
@@ -8,6 +8,7 @@ toc: true
 number-sections: true
 highlight-style: pygments
 format:
+  docx: default
   pdf:
     geometry:
       - top=30mm
@@ -17,7 +18,6 @@ format:
     html-math-method: katex
     default-image-extension: svg
     css: style.css
-  docx: default
 ---

Setting keep-md: true in the YAML as global, or just under docx format will also prevent the cleaning before PDF Rendering and should avoid the issue

This is a topic we can deal with

It will happen with any combination of formats mixing

This would probably be the better options. @cscheid do you agree ?

cderv commented 2 months ago

New use case I found:

---
title: About 
format: 
  typst: default
  typst+toc:
    toc: true
---

# Header

Content
❯ quarto render index.qmd
pandoc
  to: typst
  output-file: index.typ
  standalone: true
  default-image-extension: svg
  wrap: none
  citeproc: false

metadata
  title: About

pandoc
  to: typst
  output-file: index.typ
  standalone: true
  default-image-extension: svg
  wrap: none
  citeproc: false
  toc: true

metadata
  title: About

[typst]: Compiling index.typ to index.pdf...DONE

[typst]: Compiling index.typ to index.pdf...error: input file not found (searched at C:\Users\chris\Documents\DEV_OTHER\00-TESTS\test-quarto\index.typ)
ERROR: Error
    at Object.complete (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/output-typst.ts:80:13)
    at eventLoopTick (ext:core/01_core.js:153:7)
    at async file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render.ts:282:23
    at async withTimingAsync (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/core/timing.ts:50:20)
    at async Object.complete (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render.ts:277:7)
    at async Object.onPostProcess (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:720:28)
    at async renderFileInternal (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:689:3)
    at async renderFiles (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:325:9)
    at async renderProject (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/project.ts:441:23)
    at async Command.actionHandler (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/cmd.ts:248:26)

Adding keep-typ solves it

format: 
  typst: default
  typst+toc:
    toc: true
    keep-typ: true

So it is not possibly to use the variant format with Typst right now because of our rendering and cleaning process.

cderv commented 1 month ago

https://github.com/quarto-dev/quarto-cli/issues/10883 is another report involving docx cleaning before LaTeX rendering happens.

---
title: "Quazz"
format:
  pdf: default
  docx: default
---

# Quazz

This is a sumbol of a pie chart in SVG:

![Symbolic pie chart](./piechart.svg)

That is it.

With this svg to reproduce: piechart.svg

Doing reverse order solves it

format:
  docx: default
  pdf: default