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

Italic digits do not work in math. #4139

Open
1 task done
matj1 opened this issue May 15, 2024 · 14 comments
Open
1 task done

Italic digits do not work in math. #4139

matj1 opened this issue May 15, 2024 · 14 comments
Labels
feature request New feature or request math Related to math syntax, layout, etc.

Comments

@matj1
Copy link

matj1 commented May 15, 2024

Description

If I try to typeset an italic mathematical digit like $italic("1")$, it shows that digit but upright, and I want it italic.

It is not a font issue; it behaves that way with multiple fonts (as shown in the linked project), and it works as expected in LATEX with multiple fonts.

Typst example (wrong)

$1$ $italic(1)$ $upright(1)$ \
1 #text(style: "italic")[1] #text(style: "normal")[1]

Snímek obrazovky 2024-05-15 171422

LATEX example (as expected)

\documentclass{minimal}
\usepackage{parskip}
\begin{document}
  $1$ $\mathit{1}$ $\mathrm{1}$ \\
  1 \textit{1} \textrm{1}
\end{document}

Snímek obrazovky 2024-05-15 171400

Reproduction URL

https://typst.app/project/rcsyUogPKHnzEMkcoaL4yE

Operating system

Web app

Typst version

  • I am using the latest version of Typst
@matj1 matj1 added the bug Something isn't working label May 15, 2024
@Enivex
Copy link
Collaborator

Enivex commented May 15, 2024

Because numbers are conventionally written upright in math, there are simply no italic numerals in Unicode. There's not much typst can do about that, other than potentially faking italics or using the text font.

Exactly what LaTeX is doing in this situation is not clear to me.

@Enivex Enivex removed the bug Something isn't working label May 15, 2024
@Enivex Enivex closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@Enivex
Copy link
Collaborator

Enivex commented May 15, 2024

See #394

@Enivex Enivex reopened this May 15, 2024
@Enivex Enivex added feature request New feature or request math Related to math syntax, layout, etc. labels May 15, 2024
@matj1
Copy link
Author

matj1 commented May 15, 2024

Because numbers are conventionally written upright in math, there are simply no italic numerals in Unicode.

Exactly what LaTeX is doing in this situation is not clear to me.

AFAIK, italicity is mainly a property of the font, not the character set. I expect that italics in math work the same way as in text, that it uses the italic glyph from the font. That is what LATEX does, I think.

@Enivex
Copy link
Collaborator

Enivex commented May 15, 2024

I expect that italics in math work the same way as in text

They do not

@matj1
Copy link
Author

matj1 commented May 16, 2024

They do not

The problem is that Typst's math doesn't use various font styles (¿at all?); it uses just Unicode characters with the default style. That has a (significant IMO) limitation that not every letter has Unicode variants in various styles (normal, bold, italic…). For example, if I have a variable named “š”, I want it italic, but Typst sets it upright because Unicode doesn't have an italic š.

I would appreciate that Typst would apply font styles to math so also characters without styled Unicode characters would be styled.

Although, if I designed a math typesetting system, it would ignore styled Unicode characters and use the normal characters with styled font glyphs for consistency across characters.

@Enivex
Copy link
Collaborator

Enivex commented May 16, 2024

They do not

The problem is that Typst's math doesn't use various font styles (¿at all?); it uses just Unicode characters with the default style. That has a (significant IMO) limitation that not every letter has Unicode variants in various styles (normal, bold, italic…). For example, if I have a variable named “š”, I want it italic, but Typst sets it upright because Unicode doesn't have an italic š.

I would appreciate that Typst would apply font styles to math so also characters without styled Unicode characters would be styled.

Although, if I designed a math typesetting system, it would ignore styled Unicode characters and use the normal characters with styled font glyphs for consistency across characters.

I'm not sure where you're going with this. Typst has to deal with the reality of how math fonts work. The glyphs you're talking about simply do not exist.

@Enivex
Copy link
Collaborator

Enivex commented May 16, 2024

I could add that while there is no italic š, you can add a caron accent to an italic s

$ š upright(caron(s)) \ italic(š) italic(caron(s)) $

renders as
page-1

They do not look identical (in this font), but it's at least a partial solution.

(In some fonts they do in fact look nearly identical)

@matj1
Copy link
Author

matj1 commented May 16, 2024

I'm not sure where you're going with this. Typst has to deal with the reality of how math fonts work. The glyphs you're talking about simply do not exist.

Excuse me, I am frustrated with how math typesetting works. I thought that moving beyond LATEX and using Unicode and OpenType would enable convenient and consistent typesetting of whichever characters, but it seems that it doesn't. I don't know where the main problem is, but I dislike it.

@matj1
Copy link
Author

matj1 commented May 16, 2024

I could add that while there is no italic š, you can add a caron accent to an italic s

$ š upright(caron(s)) \ italic(š) italic(caron(s)) $

That doesn't work in longer variable names like “šířka”, which I would use more probably than just “š”.

@khaledhosny
Copy link

Exactly what LaTeX is doing in this situation is not clear to me.

LaTeX’s \mathit{} (despite the misleading name) uses text font (the same goes for other \math* font commands).

@khaledhosny
Copy link

That doesn't work in longer variable names like “šířka”, which I would use more probably than just “š”.

Multi-letter variables should be set using the text font, the math font will give bad spacing since it is designed/optimized for single-letter variables that are the most common in math.

@Enivex
Copy link
Collaborator

Enivex commented May 16, 2024

That doesn't work in longer variable names like “šířka”, which I would use more probably than just “š”.

Multi-letter variables should be set using the text font, the math font will give bad spacing since it is designed/optimized for single-letter variables that are the most common in math.

It's not quite that clear cut. This is why unicode-math provides both \math* and \sym* commands to provide both options (as I'm sure you know).

It may for instance be that the text and math fonts are very different.

@khaledhosny
Copy link

I don’t see the relation between the presence of \sym* commands and multi-letter variables. You can always do whatever you want, but if you want good typography that is the way to go.

@Enivex
Copy link
Collaborator

Enivex commented May 16, 2024

I don’t see the relation between the presence of \sym* commands and multi-letter variables. You can always do whatever you want, but if you want good typography that is the way to go.

I don't necessarily disagree, but if the option isn't there, people will still ask for it.

(I personally never use multi-letter variable names anyway)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request math Related to math syntax, layout, etc.
Projects
None yet
Development

No branches or pull requests

3 participants