pandocquarto

Why is the number-offset YAML option not working in Quarto PDF rendering?


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.

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

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.

Below is the code from the default Quarto document with a couple added level 1 headings that I'm rendering to PDF. It also has the HTML option to show that it's working. PDF number-offset is not working.

---
title: "Section Numbering Test"
format:
  html: 
    toc: true
    number-sections: true
    number-offset: 1
  pdf: 
    include-in-header:
      text: |
        \usepackage{fancyhdr}
        \pagestyle{fancy}
    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.

Solution

  • So I followed the suggestion of Julian and filed a bug. The problem I was experiencing is indeed a bug, particularly with Pandoc. I got a response with a workaround to change a setting in the YAML header. That solution is posted below:

    ---
    title: "Section Numbering Test"
    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
        include-in-header:
          text: |
            \setcounter{section}{-1}
    ---
    

    Instead of using number-offset: -1, which is currently not supported by Pandoc, the workaround uses the YAML options:

    ---
        include-in-header:
          text: |
            \setcounter{section}{-1}
    ---
    

    This works for the example I provided in my questions and it also works in other documents that I've tested.