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

Bug tagging glossaries #48

Open
YellowJacketLinux opened this issue Dec 16, 2023 · 5 comments
Open

Bug tagging glossaries #48

YellowJacketLinux opened this issue Dec 16, 2023 · 5 comments
Labels
bug in external package Something isn't working but needs correction elsewhere

Comments

@YellowJacketLinux
Copy link

With testphase=phase-III there is some kind of tagging bug when the glossaries package from CTAN is used. The bug only happens after makeglossaries has been run. TeXLive 2023 current.
The bug:

! Package tagpdf Error: The number of automatic begin (9) and end (8)
(tagpdf)                text-unit para hooks differ!

For immediate help type H <return>.
 ...                                              
                                                  
l.33 \end{document}

Minimal example:

\DocumentMetadata{
 uncompress,
 pdfversion=1.7,
 lang=en-US,
 testphase=phase-III
}
\documentclass{article}
\usepackage{fontspec}
\setromanfont{TeX Gyre Termes}
\setmonofont{TeX Gyre Cursor}
\usepackage{glossaries}
\makeglossaries
\newacronym{ce}{\textsc{c.e.}}{Common Era}
\newglossaryentry{vulgate}
{
  name={Latin Vulgate},
  description={foo foo fee foo}
}

\begin{document}
To compile (works with \texttt{testphase=phase-II} but not \texttt{testphase=phase-III}):
\begin{verbatim}
lualatex-dev glossary-bug.tex
makeglossaries glossary-bug
lualatex-dev glossary-bug.tex
lualatex-dev glossary-bug.tex
\end{verbatim}

The \gls{vulgate} is a late fourth century \gls{ce} translation of the Christian Bible.

\printglossary[title=Glossary]

\end{document}
@YellowJacketLinux
Copy link
Author

Tagging @nlct who I believe is the maintainer of the glossaries package.

@u-fischer u-fischer transferred this issue from latex3/pdfresources Dec 16, 2023
@u-fischer
Copy link
Member

u-fischer commented Dec 16, 2023

This is quite similar to a problem with \printbibliography described here plk/biblatex#1279

glossaries hides the list used to print the glossary inside a group and the \@doenpe needed for the correct tagging of the list can't escape. This can be corrected similar to the biblatex case. Be aware that this changes the indentation of text directly following \printglossary command: similar to text directly after a list it will not be indented anymore. If this is not wanted the code could also use \par\egroup instead.

\DocumentMetadata{
 uncompress,
 pdfversion=1.7,
 lang=en-US,
 testphase=phase-III
}
\documentclass{article}
\usepackage{fontspec}
\setromanfont{TeX Gyre Termes}
\setmonofont{TeX Gyre Cursor}
\usepackage{glossaries}
\makeglossaries
\newacronym{ce}{\textsc{c.e.}}{Common Era}
\newglossaryentry{vulgate}
{
  name={Latin Vulgate},
  description={foo foo fee foo}
}

\makeatletter
\renewcommand{\@printglossary}[2]{%
  \def\@glo@type{\glsdefaulttype}%
  \def\glossarytitle{\csname @glotype@\@glo@type @title\endcsname}%
  \def\glossarytoctitle{\glossarytitle}%
  \let\org@glossarytitle\glossarytitle
  \def\@glossarystyle{%
    \ifx\@glossary@default@style\relax
      \GlossariesWarning{No default glossary style provided \MessageBreak
        for the glossary `\@glo@type'. \MessageBreak
        Using fallback. \MessageBreak
        To fix this set the style with \MessageBreak
        \string\setglossarystyle\space or use the \MessageBreak
        style key=value option}%
    \fi
  }%
  \def\gls@dotoctitle{\glssettoctitle{\@glo@type}}%
  \let\@org@glossaryentrynumbers\glossaryentrynumbers
  \bgroup
   \@printgloss@setsort
   \setkeys{printgloss}{#1}%
   \@printgloss@checkexists{\@glo@type}%
   {%
    \ifx\glossarytitle\org@glossarytitle
    \else
      \expandafter\let\csname @glotype@\@glo@type @title\endcsname
                    \glossarytitle
    \fi
    \let\currentglossary\@glo@type
    \let\org@glossaryentrynumbers\glossaryentrynumbers
    \let\glsnonextpages\@glsnonextpages
    \let\glsnextpages\@glsnextpages
    \let\nopostdesc\@nopostdesc
    \gls@dotoctitle
    \@glossarystyle
    \let\gls@org@glossaryentryfield\glossentry
    \let\gls@org@glossarysubentryfield\subglossentry
    \renewcommand{\glossentry}[1]{%
      \protected@xdef\glscurrententrylabel{\glsdetoklabel{##1}}%
      \gls@org@glossaryentryfield{##1}%
    }%
    \renewcommand{\subglossentry}[2]{%
      \protected@xdef\glscurrententrylabel{\glsdetoklabel{##2}}%
      \gls@org@glossarysubentryfield{##1}{##2}%
    }%
    \@gls@preglossaryhook
    #2%
   }%
  %\egroup %<-----------------old
  \expandafter\egroup\if@endpe\@doendpe\fi %<---------------- new
  \global\let\glossaryentrynumbers\@org@glossaryentrynumbers
  \global\let\warn@noprintglossary\relax
}


\begin{document}
To compile (works with \texttt{testphase=phase-II} but not 
\texttt{testphase=phase-III}): 
\begin{verbatim}
lualatex-dev glossary-bug.tex
makeglossaries glossary-bug
lualatex-dev glossary-bug.tex
lualatex-dev glossary-bug.tex
\end{verbatim}

The \gls{vulgate} is a late fourth century \gls{ce} translation of the 
Christian Bible. 

\printglossary[title=Glossary] 
xxxx %not indented anymore!
\end{document}

@nlct
Copy link

nlct commented Dec 16, 2023

Is this specific to the default list style (and those based on it) that uses the description environment or is this fix required for all glossary styles, including the tree, index, multicol and tabular-like styles?

@u-fischer
Copy link
Member

u-fischer commented Dec 16, 2023

@nlct As mentioned in the biblatex issue every LaTeX environment ends with \expandafter\endgroup\if@endpe\@doendpe\fi and so executes if needed \@doendpe. You do not need to care if you have a list inside or not. Above I didn't add the fix to some special style but to the general printing command. If you want to end a glossary with a \par anyway, you could also simply use \par\egroup.

@nlct
Copy link

nlct commented Dec 16, 2023

Okay, thanks. I'll fix it after I've finished rewriting datatool.

@u-fischer u-fischer added the bug in external package Something isn't working but needs correction elsewhere label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug in external package Something isn't working but needs correction elsewhere
Projects
None yet
Development

No branches or pull requests

3 participants