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

amsmath: (align/flalign)+fleqn issues with spacing and tags #1610

Open
nbeisert opened this issue Jan 6, 2025 · 3 comments
Open

amsmath: (align/flalign)+fleqn issues with spacing and tags #1610

nbeisert opened this issue Jan 6, 2025 · 3 comments

Comments

@nbeisert
Copy link

nbeisert commented Jan 6, 2025

Brief outline of the bug

This is to report some inconsistent spacing behaviour in align and flalign (full-length) of amsmath with fleqn (left-aligned equations). Related issues have been reported in #136, #156, #162. The below example highlights the behaviour in various situations and could be used as a testcase. Issues:

  • Tags for flalign with several columns and leqno are misplaced.
  • flalign with a single align structure resorts to the behaviour of align. Technically, this is necessary to avoid a division by zero due to no flexible space in this situation, but it leads to inconsistent spacing behaviour in fleqn mode (due to the design choices in the following issues).
  • The handling of the left margin differs between equation and align and flalign: equation grows into the left margin if and only as far as is needed for long equations. align never uses the left margin and flalign always uses the full left margin unless left tags are present. I think that equation takes the most natural approach while the others waste or improperly use the left margin depending on the situation.
  • flalign skips the left margin whereas the other amsmath environments never use it or use it only if the equations become very long. This appears intentional behaviour in flalign (full-length), but to only skip the right margin while preserving the left margin is a worthwhile behaviour as well. Moreover, skipping the left margin in general introduces a competition in the measuring process because left tags will (re)enforce the full margin while long equations may actually need it.
  • I agree that some of the above inconsistent spacing issues may have become established behaviour (and/or are marginal) and thus any changes would have the flavour of an enhancement which could be challenging to implement. Nevertheless I consider them worthwhile reporting.

Minimal example showing the bug

\RequirePackage{latexbug}
\documentclass{article}
\PassOptionsToPackage{leqno}{amsmath}
%\PassOptionsToPackage{reqno}{amsmath}
\usepackage[fleqn]{amsmath}
\textwidth12.1cm
\parindent0pt
\overfullrule5pt

\begin{document}

equation (short, unnumbered): for reference
\begin{equation}\nonumber
XXXXXXXXXX
\end{equation}
equation (short, numbered): for reference
\begin{equation}
XXXXXXXXXX
\end{equation}
align (short, single-column, unnumbered): for reference
\begin{align}\nonumber
XXXXXXXXXX
\end{align}
align (short, single-column, numbered): for reference
\begin{align}
XXXXXXXXXX
\end{align}
align (short, double-column, unnumbered): for reference
\begin{align}\nonumber
XXXXX & XXXXX & XXXXX & XXXXX
\end{align}
align (short, double-column, numbered): for reference
\begin{align}
XXXXX & XXXXX & XXXXX & XXXXX
\end{align}
flalign (short, single-column, unnumbered):
behaves like align (by design of exception),
but as such does not skip left margin
\begin{flalign}\nonumber
XXXXX & XXXXX
\end{flalign}
flalign (short, single-column, numbered):
behaves like align (by design of exception),
but as such does not skip left margin in \verb+reqno+ mode
\begin{flalign}
XXXXX & XXXXX 
\end{flalign}
flalign (short, double-column): works as intended
(no need to fill left margin)
\begin{flalign}\nonumber
XXXXX & XXXXX & XXXXX & XXXXX
\end{flalign}
flalign (short, double-column, numbered):
tag is clearly misplaced in \verb+leqno+ mode
\begin{flalign}
XXXXX & XXXXX & XXXXX & XXXXX
\end{flalign}

\newpage
\setcounter{equation}{0}
\rule{\textwidth}{5pt}
equation (short, unnumbered): for reference
\begin{equation}\nonumber
XXXXXXXXXX
\end{equation}
equation (long, unnumbered): for reference
\begin{equation}\nonumber
XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXX
\end{equation}
equation (short, numbered): for reference
\begin{equation}
XXXXXXXXXX
\end{equation}
equation (long, numbered): for reference
\begin{equation}
XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXX
\end{equation}
equation (very long, numbered): for reference
\begin{equation}
XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXX
\end{equation}
align (short, unnumbered): works as intended
\begin{align}\nonumber
XXXXX&XXXXX
\end{align}
align (long, unnumbered):
this could well stretch into the left margin
(as for equation)
\begin{align}\nonumber
XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&X&X
\end{align}
align (short, numbered):
works as intended
\begin{align}
XXXXX&XXXXX
\end{align}
align (long, numbered):
this could well stretch into the left margin
(as for equation)
\begin{align}
XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&X&X
\end{align}
align (very long, numbered):
this could well stretch into the left margin
when the tag is shifted up (as for equation)
\begin{align}
XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&XX&X
\end{align}
flalign (short, unnumbered):
this does not have to stretch into the left margin
(probably works as intended)
\begin{flalign}\nonumber
XXXXX&XXXXX&XXXXX&XXXXX
\end{flalign}
flalign (long, unnumbered):
this could stretch less into the left margin
and should not produce an overfull warning
\begin{flalign}\nonumber
XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&XXXXX&X&X
\end{flalign}

\end{document}

Log files and PDF files

bug2b-l.log
bug2b-l.pdf
bug2b-r.log
bug2b-r.pdf

@nbeisert
Copy link
Author

nbeisert commented Jan 6, 2025

Disclosure: I'm working on an stand-alone enhancement of the various equation structures supplied by amsmath, where I'm reconsidering the measurement process alongside several other enhancements (see #224, #230, #231). Unfortunately, the resulting code will depart too much from the original one, so that fixes of individual issues will likely not translate too well. Therefore, I'm reporting the issues I'm finding in the amsmath implementation here.

@u-fischer
Copy link
Member

Disclosure: I'm working on an stand-alone enhancement of the various equation structures supplied by amsmath

if you do that, please consider also support for the tagging project and ensure that your equation structures are properly tagged. See https://latex3.github.io/tagging-project/

@nbeisert
Copy link
Author

nbeisert commented Jan 6, 2025

@u-fischer thanks for the suggestion, sounds useful, I will consider it. I did not find immediately what it would take in practice to supply tagging for math or for aligned equations, but the code structures of the enhancement will be similar to the ones for align. I hope that's not too complex and does not exhaust my capabilities.

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

4 participants