Skip to content

Commit

Permalink
add testfile for phantom issue
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Jan 25, 2025
1 parent 386298a commit caf249c
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions required/latex-lab/math-tagging-issues/phantom.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
\DocumentMetadata{uncompress,testphase=latest,pdfversion=2.0}
\documentclass{article}
\usepackage{unicode-math}
\tagpdfsetup{math/mathml/structelem}
\begin{document}

% lots of warning about structures without parent,
% wrong output
%abc $x_1^2 \mathstrut_1^2 \vphantom{\int}_1^2 $


\makeatletter\ExplSyntaxOn
\sys_if_engine_luatex:T
{
\def\ph@nt#1{%
\ifmmode
\ifcase\mathstyle
\mathph@nt\displaystyle{#1}\or
\mathph@nt\displaystyle{#1}\or
\mathph@nt\textstyle{#1}\or
\mathph@nt\textstyle{#1}\or
\mathph@nt\scriptstyle{#1}\or
\mathph@nt\scriptstyle{#1}\or
\mathph@nt\scriptscriptstyle{#1}\or
\mathph@nt\scriptscriptstyle{#1}\or
\fi
\else
\expandafter\makeph@nt
\fi}

\cs_set:Npn \mathph@nt #1 #2 {%
%
\setbox \z@ = \hbox {
$
\m@th
#1
{\SuspendTagging{phantom}#2}
\luamml_save:nNn {mathphant} #1 {mphantom}
$
}
\luamml_annotate:nen {1} {
nucleus = true,
core = {[0] = 'mpadded',
\ifh@\else
width = 0,
\fi
\ifv@\else
height = 0, depth = 0,
\fi
consume_label'mathphant',
}
} {
\finph@nt
}
%
}
}
\ExplSyntaxOff

abc $x_1^2 \mathstrut_1^2 \vphantom{\int}_1^2 $

%$ \vphantom{x\mathstrut} $ gives
% Package tagpdf Warning: structure with label 20 has already been used
% and faulty structure


\end{document}

0 comments on commit caf249c

Please sign in to comment.