quarto-dev / quarto-dev/quarto-cli

Incorrect size and spacing for left/right functions with typst and docx formats

Open
#10,424 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug math pandoc typst upstream
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Bug description
  1. Using the formats typst and docx cause \Vert to be rendered with too much space. This does not happen with the formats html or pdf which produce the correct output. This issue does not happen with other delimiters like floor and ceil.
  2. For some reason, \vert is rendered correctly with docx (and the other formats), but not with typst.
  3. \vert and \Vert are not expanded to their full size when using \left and \right in typst, but is correct with html, pdf, and docx.
  4. typst also seams to automatically enlarge other delimiters like floor even when \left and \right is not given. This may be the intended behavior for typst and I don't think anyone would complain about this, but I am pointing out that it is at least inconsistent with the other 3 formats.
Steps to reproduce
---
format: typst
---

`format: typst`

This is the absolute value of a number using `\lvert` and `\rvert`: $\lvert x \rvert$.

You could just use `\vert`: $\vert x\vert$.

This is the norm of a vector using the pair `\lVert` and `\rVert`: $\lVert v \rVert$.

You could just use `\Vert` and get this result: $\Vert v \Vert$.

Here is a big equation without `\left` and `\right`,

$$
\lVert \sum_{i=1}^n a_i \rVert,
$$

and now with `\left` and `\right`,
$$
\left\lVert \sum_{i=1}^n a_i \right\rVert.
$$

This is the floor and ceiling of a number $\lfloor x \rfloor \leq x \leq \lceil x \rceil$.

Here is the floor of a big equation without `\left` and `\right`,

$$
\lfloor \sum_{i=1}^n a_i \rfloor,
$$

and now with `\left` and `\right`,
$$
\left\lfloor \sum_{i=1}^n a_i \right\rfloor.
$$

Expected behavior

I expect all four formats to produce the same visual output.

With the format typst, correct spacing and height can be achieved with the raw code within Quarto:

```{=typst}
$norm(v)$
``` 

but of course this only works with the format typst and must be retyped when switching to other formats.

Actual behavior

Here are the outputs for the 4 formats.
typst
image
docx
image
html
image
pdf
image

Your environment
  • VSCode 1.91.1
  • Windows 11
Quarto check output
Quarto 1.5.55
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.5.55
      Path: C:\Program Files\Quarto\bin
      CodePage: 1252

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

[>] Checking LaTeX....................OK
      Tex:  (not detected)

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

[>] Checking Python 3 installation....OK
      Version: 3.11.9
      Path: C:/Users/Nicholas/AppData/Local/Programs/Python/Python311/python.exe
      Jupyter: 5.7.2
      Kernels: julia-1.10, python3

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

[>] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Quarto example with typst, docx, html, and pdf to reproduce the delimiter spacing and sizing differences. Trace the format-specific math rendering path and compare its handling of vert, Vert, left, right, floor, and ceil. Done means the documented expressions render consistently across the affected formats without format-specific raw markup.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.