quarto-dev / quarto-cli

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

allow abstract-title in yaml front matter for latex pdf output #6375

Open anielsen001 opened 1 year ago

anielsen001 commented 1 year ago

Bug description

When setting the abstract-title keyword in the front matter yaml, the abstract title is not actually changed in pdf output.

There is a work-around, which is redefine the name in the latex header using:

format: 
    pdf:
        documentclass: article
        include-in-header:
            text: |
                \renewcommand{\abstractname}{Executive Summary}

Steps to reproduce

Rendering the following quarto document creates a pdf with the abstract title set to "Abstract"

---
title: "quarto-abstract"
abstract: "Read the executive summary."
abstract-title: "Executive summary"
format: 
    pdf:
        documentclass: article
---

## Quarto

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

Expected behavior

The abstract title would be set to the keyword value in the front matter yaml, in this case "Executive Summary".

Actual behavior

The abstract title is set to "Abstract"

Your environment

Quarto check output

$ quarto check

[✓] 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: /opt/quarto/bin

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

[✓] Checking Python 3 installation....OK
      Version: 3.8.3
      Path: /home/apn/sw/bin/python3
      Jupyter: 4.10.0
      Kernels: julia-1.8, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.0
      Path: /usr/lib/R
      LibPaths:
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      knitr: (None)
      rmarkdown: (None)

      The rmarkdown package is not available in this R installation.
      Install with install.packages("rmarkdown")
mcanouil commented 1 year ago

abstract-title is not a pdf format option thus it has no effect, see https://quarto.org/docs/reference/formats/pdf.html.

You can look at the LaTeX template used by Quarto (which is mostly the one from Pandoc): https://quarto.org/docs/journals/templates.html#latex-partials

For short, your "workaround" is not a workaround but the actual solution you want.

anielsen001 commented 1 year ago

From a UI standpoint, it makes sense that a yaml option at the top level would apply to all the lower levels, which is what I assumed to be the case, but I will have to be more careful now.

mcanouil commented 1 year ago

Always double check the reference pages for valid options.

This being said, the template could be modified to make this option also work for LaTeX/PDF (note that the option is currently only defined in HTML format).

@anielsen001 Could you change the title to be more as a feature request, i.e., "allow abstract-title in pdf format"? Meanwhile, I am going to label this as en enhancement.

anielsen001 commented 1 year ago

I edited the title.

One thing I'm really keen on is reuse of the same qmd file as much as possible for different outputs. If I can make a webpage and a pdf using essentially the same front matter, that's a big plus for me. This particular abstract-title example came up in the context of creating a report for a sponsor. In other cases, when I'm teaching, I try to use the same source files to generate revealjs slides, a web page and pdf. This makes it really simple to keep slides, exercises and other information in sync if I make a change to the content somewhere.

mcanouil commented 1 year ago

You can already have one YAML front matter. If by "one" you mean without format specific options then it becomes unlikely (you are already using documentclass: article which has no equivalent in the html format). What's the issue with:

---
title: "quarto-abstract"
abstract: "Read the executive summary."
format: 
  pdf:
    documentclass: article
    include-in-header:
      - text: |
          \renewcommand{\abstractname}{Executive Summary}
  html:
    abstract-title: "Executive summary"
---