mitex-rs / mitex

LaTeX support for Typst, powered by Rust and WASM. https://mitex-rs.github.io/mitex/
https://mitex-rs.github.io/mitex/tools/underleaf.html
Apache License 2.0
240 stars 8 forks source link

Expand spacing for `\boxed` #151

Closed Tweoss closed 3 months ago

Tweoss commented 3 months ago

In latex, something like $$\boxed{\frac12}$$ gives the below.

image

When just using typst's box, $#box($1/2$, stroke: 0.5pt)$ gives the below.

image

Ideally, the output would like this #box($1/2$, stroke: 0.5pt, inset: 6pt).

image

It seems that 6pt's of inset is enough to avoid clipping into contents: #box([abcd $1/2$ $1/2/2/2/2/2/2/2/2/2/2/2/(2/2)$], stroke: 0.5pt, inset: 6pt).

image

Does it make sense to change how \boxed is converted into typst to match the latex output, or is there a good workaround?

My thoughts for a workaround was to use an iftypst block to replace \boxed with my own call to #box, but I think that would then require another conversion inside of the #box argument from latex to typst.