quarto-dev / quarto-cli

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

Typst: Use `margin-xxx` instead of `margin`? #7837

Open cwickham opened 7 months ago

cwickham commented 7 months ago

Currently format: typst uses the margin option to set page margins, whereas most of our other formats (e.g. HTML, PDF) use the margin-left, margin-right, etc. options. From what I can tell RevealJS is the only other format to use margin.

I see that Typst can be a bit more flexible in setting margins than just left, right, top and bottom, but it feels like being more flexible here, makes it harder for users to translate between formats.

cderv commented 7 months ago

Currently format: typst uses the margin option to set page margins, whereas most of our other formats (e.g. HTML, PDF) use the margin-left, margin-right, etc. options. From what I can tell RevealJS is the only other format to use margin.

Just for context, this is here also a Pandoc's naming choice, where margin is a Tyspt Pandoc variable : https://pandoc.org/MANUAL.html#variables-for-typst

We could do something about it in Quarto by changing this variable and patching the template, however I feel it would be worth also reporting to Pandoc too, so that they can consider adding more variables to be like other formats that allows it. Which would directly benefit us.

cderv commented 7 months ago

This is what is done in Pandoc https://github.com/quarto-dev/quarto-cli/blob/45a830ef3ae0a7b86f780e2820c7f6905349092c/src/resources/formats/typst/pandoc/quarto/typst-show.typ#L28-L30

So I guess they use margin to be really flexible in how to set it as you do

format: 
  typst:
    margin:
      top: <The top margin.>
      right: <The right margin.>
      bottom: <The bottom margin.>
      left: <The left margin.>
      inside: <The margin at the inner side of the page>
      x: <The horizontal margins.>
      y: <The vertical margins.>
      rest: <The margins on all sides except those for which the dictionary explicitly sets a size.>

So we could support

format: 
  typst:
    margin-top: 
    margin-left:
    margin-right:
    margin-top:

and map it to the right value, but it seems less coherent, than providing it below margin field.

or maybe we should use

margin:
    top:
    bottom:
    right: 
    left: 

for all format ? And map it to the correct variable in Pandoc ?

Just sharing thought to help clarifying the situation and do the right choice.

cwickham commented 7 months ago

Thanks for adding the context @cderv

I like the second option, use margin and then map to the right variables in Pandoc. It feels much more coherent and allows us to do things like take a single value and apply it to all margins, or allow x and y for formats other than Typst.