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

Normalize floatscript math to text #2222

Merged

Conversation

dginev
Copy link
Collaborator

@dginev dginev commented Oct 3, 2023

This PR is an extension to the one originally developed in ar5iv-bindings#2.

It adds a single rewrite rule which detects cases of Math elements located anywhere in the final XML and containing:

  • only a single top-level floating superscript or subscript
  • with shallow/simple content, namely the script contains only XMTok elements

The DefRewrite then proceeds to replace that floating script with an instance of ltx:sup or ltx:sub, also using the font information implied by the script's Box.

As it turns out, a lot of our tests used this technique, and required a change. I also tested on a new TeX file with relevant examples - I haven't checked that in as a test, but I can do so if requested. I will attach the contents here:

Example TeX test
\documentclass{article}
\title{Test}
\author{Ariel Brown${}^{1}$ Chester Dolby${}^{1,2}$\\
${}^{1}$My Org, ${}^{2}$Their Org}
\begin{document}
\maketitle

\section{Normalize to text}
token-only complex float: ${}^{a \times b}$

chemistry floatscripts: ${}^{76}$ Ge

mixed mode to avoid mathrm: 10${}^{11}$M${}_{\odot}$

mixed mode to avoid mathrm (2): W${}^{1,p}$-estimate

mixed mode compound unit: g/cm${}^{3}$

custom notemark: some text${}^{3}$.

careful with the font: n$^{\mathit{th}}$

\section{Keep as-is}
Complex float: ${}^{x^2}$ or ${}^{\sqrt{x}}$

chemistry fully math mode: ${}^{76}\mathrm{Ge}$

\end{document}

Feedback is most welcome.

@dginev dginev force-pushed the normalize-floatscript-math-to-text branch from 78e4b59 to 93ea598 Compare December 28, 2023 19:16
@brucemiller brucemiller merged commit 8280f27 into brucemiller:master Jan 5, 2024
13 checks passed
@brucemiller brucemiller deleted the normalize-floatscript-math-to-text branch January 5, 2024 20:38
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.

2 participants