Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few remarks #2

Open
laurmaedje opened this issue Mar 25, 2023 · 8 comments
Open

A few remarks #2

laurmaedje opened this issue Mar 25, 2023 · 8 comments

Comments

@laurmaedje
Copy link
Contributor

Hey, I'm one of the Typst developers. This is great!

A few remarks:

  • The thing with the script letters is interesting. Are they even part of Unicode?
  • Widehat is available, it's automatic if you write $hat(x+y)$
  • doteq is $dot(eq)$ because the dot is an accent
  • Maybe there can be an explanation for scaling: They scale by default if the symbol is entered directly as a codepoint, they don't scale automatically if you use symbol notation like $angle.l$
  • The examples for the h function are missing a hashtag because the function consists only of a single letter
  • The alignment example is a bit weird since it would look the same without alignment, but I guess that goes for the original LaTeX version, too
  • $"9.8" "m/s"^2$ would work for the units thing, but it's obviously hacky and not good. Typst needs to support this better.

PS: Would you be fine with us posting this on Twitter with the Typst account?

@johanvx
Copy link
Owner

johanvx commented Mar 25, 2023

Thanks for your attention! Feel free to share and use this anywhere!

Reply on the remarks:

The thing with the script letters is interesting. Are they even part of Unicode?

I didn't think about this. So I've just search on Compart (https://www.compart.com/en/unicode/) and found that they are Unicode letters. For example, the letter $\mathscr{P}$ \mathscr{P} is actually Mathematical Script Capital P \u{1D4AB}. Script letters and calligraphic letters are the same (handwriting letters with different fonts?) according to this Chinese post on Zhihu. Need to check https://www.ctan.org/pkg/mathrsfs and https://ctan.org/pkg/unicode-math.

Widehat is available, it's automatic if you write $hat(x+y)$

Oh, nice! I didn't even try this. I'll update the document then.

doteq is $dot(eq)$ because the dot is an accent

I've tried this but didn't adopt it. I don't remember why though. Maybe the spacing is not identical with the LaTeX \doteq? I'll check this soon.

Maybe there can be an explanation for scaling: They scale by default if the symbol is entered directly as a codepoint, they don't scale automatically if you use symbol notation like $angle.l$.

Yeah, I think there should be some explanations. I'll add this comment by creating a co-authored commit.

The examples for the h function are missing a hashtag because the function consists only of a single letter

Oh yes, mentioning single letter functions without a hashtag may be ambiguous. Thanks for pointing this out.

The alignment example is a bit weird since it would look the same without alignment, but I guess that goes for the original LaTeX version, too

I just tried to mimic the original LaTeX version 😝 and didn't think much on this.

$"9.8" "m/s"^2$ would work for the units thing, but it's obviously hacky and not good. Typst needs to support this better.

I have no idea here because I'm not familiar with the ~ spacing in LaTeX. I'll add this (with a 💦 annotation as this is hacky) in a co-authored commit.

@johanvx
Copy link
Owner

johanvx commented Mar 25, 2023

I've tried this but didn't adopt it. I don't remember why though. Maybe the spacing is not identical with the LaTeX \doteq? I'll check this soon.

So here's a simple test.

LaTeX | Typst

doteq comparison between LaTeX and Typst (from left to right), the spacing between dot and eq in Typst is larger

with LaTeX code

\documentclass[10pt]{article}
\usepackage{mathtools, amssymb, amsthm}
\begin{document}
\[ \doteq \]
\end{document}

and Typst code

#set text(10pt)
$ dot(eq) $

@user202729
Copy link

user202729 commented Mar 25, 2023

Remark on script characters: The font files are in a typical LaTeX distribution (CTAN: /tex-archive/fonts/rsfs), but they're postscript type 1 font, and I think Typst only support opentype font.

Maybe something in https://stackoverflow.com/questions/9322635/how-can-i-convert-postscript-type-1-font-to-otf-or-ttf can convert them to a Typst-compatible format.

https://tex.stackexchange.com/questions/659025/context-lmtx-how-to-use-the-rsfs-font?noredirect=1&lq=1#comment1640490_659025 also has some discussion but nothing too useful.


On the doteq issue, I attempt to build the symbol myself a bit but I still don't understand how the box model work in Typst (compared to that in TeX), as well as the issue of spacing between math symbols/mathstyle (mathchoice):

#let doteq1 = box(baseline: -0.5pt, align(center, stack(spacing: -2pt, sym.dot, sym.eq)))

$ a dot(eq) b, a = b, a doteq1 b $

$ 2^(a dot(eq) b, a = b, a doteq1 b) $

image

@johanvx
Copy link
Owner

johanvx commented Mar 26, 2023

I wrote something weird but maybe usable.

#let eqdot = $\u{2A66}$
#let doteq2 = style(styles => {
  let ex = measure("x", styles).height
  box(baseline: -ex, align(center, stack(spacing: (0.3455 - 1 + 0.1874 * 2) * ex, $dot$, $eq$)))
})

$ doteq2 = eqdot quad a doteq2 b, a = b, a eqdot b \
  2^(doteq2 = eqdot quad a doteq2 b, a = b, a eqdot b) $

Output of the above Typst code

Sad to find out that eqdot is a Unicode character (Equals Sign with Dot Below) while doteq is not.

@user202729
Copy link

user202729 commented Mar 26, 2023

See, the problem is that your doteq2 does not respect mathstyle. In superscript doteq still keeps some spacing around it, while = and eqdot doesn't.

In TeX this would be solved with \mathchoice. Not sure about this, maybe there's some way to extract the information whether the current text is in superscript or not from the style?

Unfortunately repr(style) just return .., it's opaque.

@johanvx johanvx pinned this issue Apr 7, 2023
@johanvx
Copy link
Owner

johanvx commented Apr 7, 2023

It turns out that doteq is \u{2250} (see #9). Here's a new demo with typst 0.1.0 (94e052b8):

#let eqdot = "\u{2A66}"
#let doteq = "\u{2250}"

Customized symbols defined with `"..."`:

$ doteq = eqdot quad a doteq b, a = b, a eqdot b \
  2^(doteq = eqdot quad a doteq b, a = b, a eqdot b) $

#let eqdot = $\u{2A66}$
#let doteq = $\u{2250}$

Customized symbols defined with `$...$`:

$ doteq = eqdot quad a doteq b, a = b, a eqdot b \
  2^(doteq = eqdot quad a doteq b, a = b, a eqdot b) $

Customized symbols defined with " and $, the former is good, while the latter contains trailing spacing


Update

With typst 0.4.0 (f692a5ef), there's no difference any more.

@kokic
Copy link

kokic commented Apr 28, 2024

The width of hat is not always suitable e.g. hat(x_i) or hat(x y) . This has forced me to write hat(space x_i space).

@johanvx
Copy link
Owner

johanvx commented May 7, 2024

The width of hat is not always suitable e.g. hat(x_i) or hat(x y) . This has forced me to write hat(space x_i space).

Good point! I hope that readers can do this with the help of Section Spacing in mathematics.

Just out of curiosity: in what context are these use cases?

For me:

  • $\Large \widehat{x_i}$ (hat(space x_i space) in Typst / \widehat{x_i} in LaTeX) is really rare. Almost always use $\Large \hat{x}_i$ (hat(x)_i/\hat{x}_i).
  • Never met $\Large \widehat{x y}$, but a similar thing without extra space $\Large (\widehat{\vec{u}, \vec{v}})$ ((hat(arrow(u)\, arrow(v)))1/(\widehat{\vec{u}, \vec{v}})) is OK.

Footnotes

  1. actually, maybe something like paren.l hat(#h(0.1em) arrow(u)\, arrow(v) #h(0.1em)) paren.r is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants