quarto-dev / quarto-cli

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

number-offset in PDF output for Quarto is not working. #6842

Open Cody-Kerr opened 1 year ago

Cody-Kerr commented 1 year ago

Bug description

When rendering a Quarto document to PDF, the number-offset YAML header is not working.

Steps to reproduce

---
title: "Section Numbering Test"
author: \vspace{-3cm}
format:
  html: 
    toc: true
    number-sections: true
    number-offset: 1
  pdf: 
    toc: true
    toc-depth: 3
    geometry:
      - top=1.90cm
      # - bottom=1.27cm
      - left=1.27cm
      - right=1.27cm
    mainfont: TimesNewRomanPSMT
    fontsize: 11pt
    number-sections: true
    number-offset: -1
---

# INTRO

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

# SPECIFIC STUFF

## Running Code

When you click the **Render** button a document will be generated that includes both content and the output of embedded code.

Expected behavior

Using the number-offset YAML option should offset the numbering in a PDF output.

Actual behavior

I'm trying to offset the section/heading numbers so that the first level 1 heading starts at 0. The default starts at 1. When I set number-offset: -1 for the PDF output option, it doesn't work. I've also tied a positive offset to test such as number-offset: 2. That doesn't work either. I read on one site that this was a bug on PDF outputs (https://github.com/quarto-dev/quarto-cli/issues/3126) but that it would be fixed in version 1.3. I'm assuming that meant Quarto version 1.3. When using the same YAML option for HTML output, the number offset works, but it is still not working for PDF outputs.

I know there is a version of pandoc available that is 3.1.8 but I haven't tried that yet as I've read that RStudio comes bundled with a pandoc version and that changing to a non-bundled version could cause issues.

Your environment

Here are the versions I'm running: R: 4.3.1 RStudio: 2323.06.2 +561 Quarto: 1.3.450 Pandoc: 3.1.1

Quarto check output

[>] 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.450 Path: C:\Users\Cody\AppData\Local\Programs\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.3.1 Path: C:/PROGRA~1/R/R-43~1.1 LibPaths:

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

mcanouil commented 1 year ago

There were two things: one was an error when using the option which as fixed using a workaround in Quarto and the fact that LaTeX format template does not support the option in Pandoc (https://github.com/jgm/pandoc/issues/4764).

A workaround:

---
format:
  pdf:
    number-sections: true
    include-in-header:
      text: |
        \setcounter{section}{-1}
---

## test
Cody-Kerr commented 1 year ago

Thank you so much! The solution you posted works in my test document and in the primary document I need to render for my project.

Do you know if there's a plan in the future to have Pandoc support the number-offset for PDF rendering in Quarto?

mcanouil commented 1 year ago

There is an open issue as I said. Now, it would be better for Pandoc to fix this than for Quarto to do this downstream.

Cody-Kerr commented 1 year ago

Thank you.

mcanouil commented 1 year ago

Let's keep this open.

mcanouil commented 10 months ago

We probably need to update Quarto reference page to stop listing number-offset as a valid option for pdf format until this is resolved update:

salim-b commented 2 days ago

A workaround:

---
format:
  pdf:
    number-sections: true
    include-in-header:
      text: |
        \setcounter{section}{-1}
---

## test

This doesn't seem to work for book projects (at least with Quarto 1.5.57).