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

Changes in horizontal spacing in some equations #1319

Closed
jovyntls opened this issue Mar 27, 2024 · 3 comments
Closed

Changes in horizontal spacing in some equations #1319

jovyntls opened this issue Mar 27, 2024 · 3 comments

Comments

@jovyntls
Copy link

Brief outline of the bug

The spacing of characters in some equations has changed from the TeXLive 2022 distribution to TeXLive 2023 distribution.
It seems to occur for equations using ~ with an operator like - or \leq.

Minimal example showing the bug

\RequirePackage{latexbug}
\documentclass{article}

\begin{document}

	\begin{equation}
	  -1,~-2
	\end{equation}
  
\end{document}

Log file (required) and possibly PDF file

main.log

PDF file from TeXLive 2022:
main2022.pdf

PDF file from TeXLive 2023:
main2023.pdf

Using the diff-pdf tool to superimpose both PDF files shows the difference in alignment (red is 2022, blue is 2023):
outdiff.pdf
image

@muzimuzhi
Copy link
Contributor

In LaTeX2e 2023-11-01 (see e98027d), to make it safe in csnames, definition of active tilde was changed from

\def~{\nobreakspace{}}

to

latex2e/base/ltspace.dtx

Lines 1229 to 1234 in 4472861

\protected\edef~{%
\noexpand\ifincsname\noexpand\expandafter\string~%
\noexpand\else
\noexpand\expandafter\noexpand\nobreakspace
\noexpand\fi
}

The new definition acts like \nobreakspace without trailing pair of braces when used in non-csnames, for example in math equations.

There's even a code comment (added by a4df9c4) which explains why the {} is now unneeded.

latex2e/base/ltspace.dtx

Lines 1217 to 1220 in 4472861

% The fragile version of |~| needs a brace group after \cs{nobreakspace}
% to prevent loss of spaces if it occurs in an expansion context. That's
% not an issue with the updated \cs{protected} definition, so we keep the
% code shorter and avoid that.

I think current behavior of ~ in math is more correct. Note the spacing (actually the math class of minus sign) between minus sign and number 2 was interfered by the trailing {} in ~ prior to LaTeX2e 2023-11-01.

Also maybe math spacing commands \,, \:, and \; are more recommended than ~.

\RequirePackage{latexbug}
\documentclass{article}

\begin{document}
Before \LaTeXe{} 2023-11-01
\begingroup
\def~{\nobreakspace{}}
\begin{equation}
  -1,~ -2
\end{equation}
\endgroup

Starting from \LaTeXe{} 2023-11-01
\begin{equation}
  -1,~ -2
\end{equation}

image

@jovyntls
Copy link
Author

I see, thank you so much for the detailed explanation! Should I close this issue?

@FrankMittelbach
Copy link
Member

FrankMittelbach commented Mar 28, 2024

I would say so, but not the other one you opened up in colortbl because while releated that nevertheless might need some actions.

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

No branches or pull requests

3 participants