quarto-dev / quarto-cli

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

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

Open njericha opened 3 months ago

njericha commented 3 months ago

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](https://github.com/user-attachments/assets/8ac03aed-a9e2-4510-aaa2-535330e7f1f7)
**docx**
![image](https://github.com/user-attachments/assets/137382c1-be64-4bab-bd0d-1ca151409643)
**html**
![image](https://github.com/user-attachments/assets/447c56fd-8dd0-4458-9139-c0d1738ed162)
**pdf**
![image](https://github.com/user-attachments/assets/6cf456de-a066-4ebf-9629-84ab83d8c21a)

### Your environment

- VSCode 1.91.1
- Windows 11

### Quarto check output

```bash
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/
njericha commented 3 months ago

I want to add that typst incorrectly handles subscripting of norms.

---
format: typst
---

Here is the $2$-norm of a vector: $\lVert v \rVert_2$

This is the rendered output using the format typst image

It should look like this (rendered with html) image

mcanouil commented 2 months ago

I want to add that typst incorrectly handles subscripting of norms.

---
format: typst
---

Here is the $2$-norm of a vector: $\lVert v \rVert_2$

This is the rendered output using the format typst image

It should look like this (rendered with html) image

That's not a Quarto issue. Please report to Typst: https://github.com/typst/typst

Here is the $2$-norm of a vector: $parallel v parallel_2$
typst compile index.typ
image
mcanouil commented 2 months ago

Maths are handled by Pandoc. You can see that the math produced is not the correct one for Typst (https://typst.app/docs/reference/math/lr) using keep-typ: true and investigating the typ file. Docx system is not that simple.

This is a Pandoc issue.

njericha commented 2 months ago

Looks like it was strictly a texmath bug which should now be fixed, so I am happy to close this issue once the change is reflected downstream to Pandoc and subsequently Quarto.