Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange bug related to multiple PDF formats with quarto 1.4.429 #7325

Open
dmkaplan2000 opened this issue Oct 23, 2023 · 9 comments
Open

Strange bug related to multiple PDF formats with quarto 1.4.429 #7325

dmkaplan2000 opened this issue Oct 23, 2023 · 9 comments
Labels
bug Something isn't working latex LaTeX engines related libraries and technologies
Milestone

Comments

@dmkaplan2000
Copy link

Bug description

This is a tough bug (or bugs) to explain, so please bear with me. I have been using Quarto 1.4.429 to deal with the issue reported here #7267, but I have been noticing some strange regressions where if I render on my Ubuntu 20 machine in rstudio or from the command line specifying to only render to the titlepage-pdf format, then I get incorrect table numbering again, but if I render from the command line letting it render all available formats, including pdf and docx, then the table numbering is correct provided that I specify that the pdf format render to a different filename than the titlepage-pdf format (using the output-file option). On my Ubuntu 22 machine yesterday I was able to render correctly in rstudio without these issues, so the problem is somehow a mix of OS (or pandoc version?) and quarto and multi-format qmd documents.

Unfortunately, I haven't been able to come up with a minimal example that reproduces all of these issues (my actual document is a long paper with lots of moving pieces, so hard to identify which elements are essential). But I have been able to create a minimal example that at least shows that rendering multiple PDF formats from the command-line produces errors (on Ubuntu 20 - not sure if this impacts Ubuntu 22) that seem to be related to interactions between the multiple formats. See example below.

Steps to reproduce

Render from the command line the following document using quarto render test.qmd:

---
title: "Test table numbering"
format: 
  titlepage-pdf: default
  pdf: default
---

Expected behavior

Should render without error.

Actual behavior

Here is the output:

$ quarto render test-table-numbering.qmd
pandoc 
  to: latex
  output-file: test-table-numbering.tex
  standalone: true
  pdf-engine: xelatex
  variables:
    graphics: true
    tables: true
  default-image-extension: pdf
  
metadata
  block-headings: true
  title: Test table numbering
  
pandoc 
  to: latex
  output-file: test-table-numbering.tex
  standalone: true
  pdf-engine: xelatex
  variables:
    graphics: true
    tables: true
  default-image-extension: pdf
  
metadata
  documentclass: scrartcl
  classoption:
    - DIV=11
    - numbers=noendperiod
  papersize: letter
  header-includes:
    - '\KOMAoption{captions}{tableheading}'
  block-headings: true
  title: Test table numbering
  

Rendering PDF
running xelatex - 1
  This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019/Debian) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
running xelatex - 2
  This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019/Debian) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  

ERROR: NotFound: No such file or directory (os error 2): open 'test-table-numbering.tex'

Stack trace:
    at async Object.open (ext:deno_fs/30_fs.js:564:15)
    at async processLines (file:///opt/quarto/bin/quarto.js:73760:18)
    at async file:///opt/quarto/bin/quarto.js:73737:9
    at async Object.complete (file:///opt/quarto/bin/quarto.js:70032:37)
    at async Object.onPostProcess (file:///opt/quarto/bin/quarto.js:76403:36)
    at async renderFileInternal (file:///opt/quarto/bin/quarto.js:76387:5)
    at async renderFiles (file:///opt/quarto/bin/quarto.js:76160:17)
    at async render (file:///opt/quarto/bin/quarto.js:81164:21)
    at async Command.fn (file:///opt/quarto/bin/quarto.js:81284:32)
    at async Command.execute (file:///opt/quarto/bin/quarto.js:8111:13)

If I choose to just render a single format (e.g., quarto render test.qmd --to pdf), then the error goes away.

Your environment

  • IDE: RStudio 2023.09.0 Build 463
  • OS: Ubuntu 20.04.6 LTS
  • R version 4.3.1 (2023-06-16)

Quarto check output

$ quarto check
Quarto 1.4.429
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.8: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.4: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.429
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: 2019

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

[✓] Checking Python 3 installation....OK
      Version: 3.8.10
      Path: /usr/bin/python3
      Jupyter: 4.6.3
      Kernels: python3

(/) Checking Jupyter engine render....Traceback (most recent call last):
  File "/opt/quarto/share/jupyter/jupyter.py", line 21, in <module>
    from notebook import notebook_execute, RestartKernel
  File "/opt/quarto/share/jupyter/notebook.py", line 18, in <module>
    from nbclient import NotebookClient
ModuleNotFoundError: No module named 'nbclient'
[✓] Checking Jupyter engine render....OK
@dmkaplan2000 dmkaplan2000 added the bug Something isn't working label Oct 23, 2023
@cscheid
Copy link
Collaborator

cscheid commented Oct 23, 2023

Yes, this sounds about right. Unfortunately, the fix for it is rather complex. We're going to do it in 1.5, but that's months away.

@cscheid cscheid added this to the v1.5 milestone Oct 23, 2023
@cscheid
Copy link
Collaborator

cscheid commented Oct 23, 2023

(Cf #6518)

@mcanouil
Copy link
Collaborator

@cderv showed a trick in a discussion if I recall by tweaking the output extension.
Don't know if it could be used here as a workaround. (Also can't search for the discussion with this right now)

@cderv
Copy link
Collaborator

cderv commented Oct 24, 2023

Using two format that output the same type of output will indeed create a conflict, which we does not prevent yet.
There are several issues about this, and closest one is:

This happens because Quarto creates the output file name when not provided explicitly to be the input file name + the extension of the output format. When using titlepage-pdf and pdf this is exactly the same. Intermediaries .tex files are also created using input file name only unfortunatly. output-file won't help here then... Improvement tracked by

So using those two formats will use the same .tex file as intermediary, and it conflicts badly. We're sorry for this and know that we'll tackle this in 1.5 as mentioned.

The current solution is to be explicit about the output conflict by using the modifiers in the format which is use in the file stem for intermediary and output file.

format: 
  titlepage-pdf: default
  pdf+other: default

This modifiers exists to have two variants of formats in same doc. For example to produce one HTML with toc, and another without.

format: 
  html: 
    toc: false
  html+toc: 
    toc: true

Anyhow, no solution really, just workaround when outputting two similar output type, while waiting for next big improvement in 1.5

@mcanouil
Copy link
Collaborator

(Oh that was the modifier/variant not the extension)

@dmkaplan2000
Copy link
Author

Huh, I was unaware of this format modifiers technique (i.e., pdf+other). Is this a new currently undocumented feature or is this described somewhere in the documentation?

@mcanouil
Copy link
Collaborator

mcanouil commented Oct 25, 2023

It's a Pandoc trick/hack and not really a feature.
The modifier/variants are usually Pandoc extensions and are described in Pandoc documentation.

@dmkaplan2000
Copy link
Author

It's a Pandoc trick/hack and not really a feature. The modifier/variants are usually Pandoc extensions and are described in Pandoc documentation.

Thanks. I will file it in the good to know, but probably shouldn't use it regularly folder...

@cderv
Copy link
Collaborator

cderv commented Oct 26, 2023

Is this a new currently undocumented feature or is this described somewhere in the documentation?

I would say this is an undocumented feature for now. We do handle specifically unknown Pandoc's extension as modifiers to differentiate format

// Format strings are of the form:
// baseName+<variants | modifiers>-<variants>[<extension>]
// Where modifiers and variants can be in any order
// and basename must start the string and extension must end the string
export const parseFormatString = (formatStr: string): FormatDescriptor => {
// acm-pdf+foo
// gfm-raw_html
// acm-2023-pdf+foobar
// pdf
// acm
// acm-gfm-raw_html <-- not allowed

It is related to this one that works now better on 1.4

as reference from past discussion to document better

We should probably document this better indeed.

@mcanouil mcanouil added the latex LaTeX engines related libraries and technologies label Oct 26, 2023
@cscheid cscheid modified the milestones: v1.5, Future Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working latex LaTeX engines related libraries and technologies
Projects
None yet
Development

No branches or pull requests

4 participants