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

tagging produces an extra line above align environment if text line above is completely full (pdftex only) #803

Open
John02139 opened this issue Feb 19, 2025 · 4 comments
Labels
area: math bug Something isn't working in code we maintain (directly) enhancement New feature or request or otherwise some possible improvement

Comments

@John02139
Copy link
Contributor

The following occurs with pdftex, not lualatex, and requires that the text line above the display is completely full. (Removing one character stops an apparent overflow.)

\DocumentMetadata{
	testphase = {phase-III,math,table,title,firstaid},
	pdfstandard=ua-2,
	pdfversion=2.0,
	lang=en-US,
}
\documentclass{article}
\usepackage{amsmath}


\begin{document}

% the last line before align must be completely full.
Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna.
Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris. Pellentesque:
\begin{align}
\frac{d\Gamma}{dt} &= \frac{d}{dt} \int_{\mathcal{C}} \mathbf{u} \cdot d\mathbf{r}\\
				   &= \int_{\mathcal{C}} \frac{D\mathbf{u}}{Dt} \cdot d\mathbf{r} + \underbrace{\int_{\mathcal{C}} \mathbf{u}\cdot d\biggl( \frac{d\mathbf{r}}{dt}\biggr)}_{=\, 0} \\[-2pt]
                   &= \iint_{\mathcal{S}} \nabla \times \frac{D\mathbf{u}}{Dt}  \cdot d\mathbf{A}\\
                   &= \iint_{\mathcal{S}}  \nabla p \times \nabla \left( \frac{1}{\rho}\right) \cdot d\mathbf{A}
\end{align}

\end{document}

With tagging, an extra blank line above the equations:
Image

Without tagging:
Image

@u-fischer
Copy link
Member

u-fischer commented Feb 23, 2025

I think there is an \unskip missing, see below (alternatively hide the end of line with a percent char).

Beside this: please be aware that your code does not give an PDF/UA-2 conformant document automatically. PDF/UA-2 explicitly requires that mathematic expression should use MathML:

Mathematical expressions shall be represented using either structure types defined in presentation MathML, as specified in ISO 32000-2:2020, 14.8.6.3, or as presentation MathML via the Associated Files mechanism specified in ISO 32000-2:2020, 14.13.6, or both.

To fulfil the requirement you need to provide a MathML-version of the equation that can then be included as associated file (the latex-lab-math documentation contains instructions for this). Without such a MathML you should not claim conformance with UA-2.

If you want a MathML representation automatically you have to use lualatex + unicode-math.

\DocumentMetadata{
	testphase = {latest},
	pdfstandard=ua-2,
	pdfversion=2.0,
	lang=en-US,
}
\documentclass{article}
\usepackage{amsmath}
\ExplSyntaxOn
\cs_set_protected:Npn \__tag_tool_close_P:
  {
    \tag_if_active:T
     { \unskip %<-------------
       \tag_mc_end: %end P-chunk, should perhaps be \tag_mc_end_push: ...
         \__tag_gincr_para_end_int:
         \__tag_check_para_end_show:nn{red}{} %debug: show para
         \tag_struct_end:
     }
  }
\ExplSyntaxOff

\begin{document}

% the last line before align must be completely full.
Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna.
Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris. Pellentesque:
\begin{align}
\frac{d\Gamma}{dt} &= \frac{d}{dt} \int_{\mathcal{C}} \mathbf{u} \cdot d\mathbf{r}\\
				   &= \int_{\mathcal{C}} \frac{D\mathbf{u}}{Dt} \cdot d\mathbf{r} + \underbrace{\int_{\mathcal{C}} \mathbf{u}\cdot d\biggl( \frac{d\mathbf{r}}{dt}\biggr)}_{=\, 0} \\[-2pt]
                   &= \iint_{\mathcal{S}} \nabla \times \frac{D\mathbf{u}}{Dt}  \cdot d\mathbf{A}\\
                   &= \iint_{\mathcal{S}}  \nabla p \times \nabla \left( \frac{1}{\rho}\right) \cdot d\mathbf{A}
\end{align}

\end{document}

@FrankMittelbach
Copy link
Member

Mathematical expressions shall be represented using either structure types defined in presentation MathML, as specified in ISO 32000-2:2020, 14.8.6.3, or as presentation MathML via the Associated Files mechanism specified in ISO 32000-2:2020, 14.13.6, or both.

To fulfil the requirement you need to provide a MathML-version of the equation that can then be included as associated file (the latex-lab-math documentation contains instructions for this). Without such a MathML you should not claim conformance with UA-2.

maybe that should be auto-detected and actually generate a warning at the end of the run?

@John02139
Copy link
Contributor Author

Thanks, Ulrike. I should have set this a-4f, not ua-2, since I was switching between lualatex and pdftex.

The \unskip, I assume, needs to be added in latex-lab?

@FrankMittelbach
Copy link
Member

The \unskip, I assume, needs to be added in latex-lab?

yes

@FrankMittelbach FrankMittelbach added enhancement New feature or request or otherwise some possible improvement area: math bug Something isn't working in code we maintain (directly) labels Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: math bug Something isn't working in code we maintain (directly) enhancement New feature or request or otherwise some possible improvement
Projects
None yet
Development

No branches or pull requests

3 participants