Skip to content

Apply script-style to numbers consistently in math#6320

Merged
laurmaedje merged 1 commit intotypst:mainfrom
mkorje:script-style-numbers-math
Jun 4, 2025
Merged

Apply script-style to numbers consistently in math#6320
laurmaedje merged 1 commit intotypst:mainfrom
mkorje:script-style-numbers-math

Conversation

@mkorje
Copy link
Collaborator

@mkorje mkorje commented May 22, 2025

Closes #6318.

Not quite sure if we want to actually do this (EDIT: we will be matching *TeX if we do this). The changes to tests are shown below so you can see what it would look like with the changes.

Tests

issue-4828-math-number-multi-char:

Old New
issue-4828-math-number-multi-char old issue-4828-math-number-multi-char new

issue-5489-matrix-stray-linebreak:

Old New
issue-5489-matrix-stray-linebreak old issue-5489-matrix-stray-linebreak new

math-attach-kerning-mixed:

Old New
math-attach-kerning-mixed old math-attach-kerning-mixed new

math-attach-limit-long:

Old New
math-attach-limit-long old math-attach-limit-long new

math-attach-prescripts:

Old New
math-attach-prescripts old math-attach-prescripts new

math-frac-precedence:

Old New
math-frac-precedence old math-frac-precedence new

math-root-frame-size-index:

Old New
math-root-frame-size-index old math-root-frame-size-index new

math-root-large-index:

Old New
math-root-large-index old math-root-large-index new

@mkorje
Copy link
Collaborator Author

mkorje commented May 22, 2025

Some very quickly done examples of what LuaTeX is doing. As you can see, script-style is applied to all numbers.

LuaTeX

3
4

@MDLC01
Copy link
Collaborator

MDLC01 commented May 22, 2025

The "11" in the new version of the last test looks a bit ugly to me. Is that a font issue?

@mkorje
Copy link
Collaborator Author

mkorje commented May 23, 2025

I think so, it looks the same in LuaTeX:

LuaTeX

tex

\makeatletter
\renewcommand\@xipt{10}
\makeatother
\documentclass[10pt]{article}
\usepackage[paperheight=2cm,paperwidth=4cm,margin=0cm]{geometry}
\geometry{textwidth=\paperwidth, textheight=\paperheight, noheadfoot, nomarginpar}
\setlength{\topskip}{0mm}
\setlength{\parindent}{0mm}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{fontspec}
\usepackage[default]{fontsetup}
\begin{document}

\[ \sqrt{3} \quad \sqrt[123]{3} \]
\[ \sqrt[2]{x} \quad
   \sqrt[\frac{3}{\frac{2}{1}}]{x} \quad
   \sqrt[\frac{1}{11}]{x} \quad
   \sqrt[\frac{\frac{1}{2}}{3}]{1} \]

\end{document}

And here's how it looks with STIX Two Math:

STIX Two Math
Old New LuaTeX
old new tex
--- playground ---
#show math.equation: set text(font: "STIX Two Math")
$ sqrt(3) quad root(123, 3) $
$ root(2, x) quad
  root(3/(2/1), x) quad
  root(1/11, x) quad
  root(1/2/3, 1) $
\makeatletter
\renewcommand\@xipt{10}
\makeatother
\documentclass[10pt]{article}
\usepackage[paperheight=2cm,paperwidth=4cm,margin=0cm]{geometry}
\geometry{textwidth=\paperwidth, textheight=\paperheight, noheadfoot, nomarginpar}
\setlength{\topskip}{0mm}
\setlength{\parindent}{0mm}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{fontspec}
\setmathfont{STIXTwoMath-Regular}
\begin{document}

\[ \sqrt{3} \quad \sqrt[123]{3} \]
\[ \sqrt[2]{x} \quad
   \sqrt[\frac{3}{\frac{2}{1}}]{x} \quad
   \sqrt[\frac{1}{11}]{x} \quad
   \sqrt[\frac{\frac{1}{2}}{3}]{1} \]

\end{document}

@mkorje mkorje force-pushed the script-style-numbers-math branch from f24d76a to 6c6081c Compare May 27, 2025 04:09
@mkorje mkorje mentioned this pull request May 27, 2025
@mkorje mkorje force-pushed the script-style-numbers-math branch from 6c6081c to 5bc67e9 Compare June 4, 2025 03:54
@laurmaedje laurmaedje added this pull request to the merge queue Jun 4, 2025
@laurmaedje
Copy link
Member

Makes sense. Thanks!

@laurmaedje
Copy link
Member

I was about to leave a comment on further unifying number and non-number layout, but it's a moot point with #6336!

Merged via the queue into typst:main with commit 128c40d Jun 4, 2025
7 checks passed
@mkorje
Copy link
Collaborator Author

mkorje commented Jun 4, 2025

I was about to leave a comment on further unifying number and non-number layout, but it's a moot point with #6336!

IIRC It isn't really unified any further there yet, but is in #6365.

@mkorje mkorje deleted the script-style-numbers-math branch June 4, 2025 08:46
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

Successfully merging this pull request may close these issues.

Script-style is not applied to numbers consistently in math

3 participants