Bug Tracker
I’m currently working on a major new version of the datatool package. This may take a while. Please be patient. (Experimental version available for testing.)
ID | 189🔗 |
---|---|
Submitted by: | Peter Müller |
Date: | 2021-11-05 00:57:29 |
Last update: | 2022-10-19 18:33:45 |
Status | Closed (Fixed) |
Category | glossaries |
Version | 4.49 |
Summary | spurious space in math mode after line break before \gls{…} |
Cross Ref | 175 |
Sign in to subscribe to notifications about this report.
Description
Feeding\documentclass{article} \pagestyle{empty} \usepackage[makeindex,nomain]{glossaries-extra} \newglossary[nlg]{notation}{not}{ntn}{Symbols} \makeglossaries \newglossaryentry{not:booleanValues}{type=notation, name=B, text=B, description={The set of Boolean values.}} \newglossaryentry{not:powerset}{type=notation, name=P, text=P, description={The power set of the set \(Z\) is denoted by \(P(Z)\).}} \begin{document}% \newlength{\myLen}\setlength{\myLen}{33em}% \noindent 1st line. Good:\\ \hspace*{\myLen}\(\Sigma\to B\)\\ \noindent 4th line. Bad:\\ \hspace*{\myLen}\(\Sigma\to\gls{not:booleanValues}\)\\ \noindent 7th line. Good:\\ \hspace*{\myLen}\(\Sigma\to P(\Sigma)\)\\ \noindent 10th line. Bad:\\ \hspace*{\myLen}\(\Sigma\to\gls{not:powerset}(\Sigma)\)\\ \noindent 13th line \printglossaries \end{document}to the loop
pdflatex mwe && makeglossaries mwe
until stabilization leads to spurious spaces after automatic line breaks in output lines 6 and 12: [Link]. This bug has been introduced by glossaries-extra v1.46; it was not there in v1.45. I think it also occurs if \usepackage[makeindex,nomain]{glossaries-extra}
is replaced with \usepackage[makeindex,nomain]{glossaries}
and using v4.49 of glossaries
.The bug also occurs with
lualatex
instead of pdflatex
.I would be happy if I could ask for improvement.
Thank you in advance!
Peter
MWE
Download (809B)
\documentclass{article} \pagestyle{empty} \usepackage[makeindex,nomain]{glossaries-extra} \newglossary[nlg]{notation}{not}{ntn}{Symbols} \makeglossaries \newglossaryentry{not:booleanValues}{type=notation, name=B, text=B, description={The set of Boolean values.}} \newglossaryentry{not:powerset}{type=notation, name=P, text=P, description={The power set of the set \(Z\) is denoted by \(P(Z)\).}} \begin{document}% \newlength{\myLen}\setlength{\myLen}{33em}% \noindent 1st line. Good:\\ \hspace*{\myLen}\(\Sigma\to B\)\\ \noindent 4th line. Bad:\\ \hspace*{\myLen}\(\Sigma\to\gls{not:booleanValues}\)\\ \noindent 7th line. Good:\\ \hspace*{\myLen}\(\Sigma\to P(\Sigma)\)\\ \noindent 10th line. Bad:\\ \hspace*{\myLen}\(\Sigma\to\gls{not:powerset}(\Sigma)\)\\ \noindent 13th line \printglossaries \end{document}
Evaluation
Since the problem occurs with just the base glossaries package, I've changed the category from glossaries-extra to glossaries (and the version number from 1.46 to 4.49). It also occurs with the 4.46 rollback:
\usepackage[makeindex,nomain]{glossaries}[=v4.46]I'm not sure why the problem doesn't show with glossaries-extra v1.45. Version 1.46 was released 2021-09-20, but that was also the same date as the glossaries v4.47 release so it maybe that it was the update to glossaries that introduced the problem.
Update: I think I've found out why the problem doesn't show with glossaries-extra v1.45. If I add a empty group in front of \gls
:
\(\Sigma\to{}\gls{not:booleanValues}\)then the space disappears. This simulates the issue reported in bug #175 where glossaries-extra was erroneously inserting grouping within the internal command used by
\gls
, \glslink
etc. This bug was counteracting an existing bug in the base glossaries package. When issue #175 was fixed, the underlying base glossaries bug shows up again.
Update: it looks like it's caused by the whatsit created by the indexing. This can be simulated with:
\hspace*{\myLen}\(\Sigma\to \write\glswrite{Test}B\)If you are using glossaries-extra the simplest workaround is to perform the indexing after the link text. For example, using the
wrgloss
attribute:
\glssetcategoryattribute{general}{wrgloss}{after}or add
wrgloss=after
for a specific instance. For example:
\(\Sigma\to\gls[wrgloss=after]{not:booleanValues}\)Alternatively, add
wrgloss=after
to the default set of options, which will ensure that the indexing is always afterwards:
\GlsXtrSetDefaultGlsOpts{wrgloss=after}Note this problem isn't specific to glossaries but also occurs with general indexing:
\documentclass{article} \usepackage{makeidx} \makeindex \begin{document}% \newlength{\myLen}\setlength{\myLen}{33em}% \noindent 1st line. Good:\\ \hspace*{\myLen}\(\Sigma\to B\)\\ \noindent 4th line. Before:\\ \hspace*{\myLen}\(\Sigma\to \index{B}B\)\\ \noindent nth line. After:\\ \hspace*{\myLen}\(\Sigma\to B\index{B}\)\\ \printindex \end{document}Unfortunately, there are also problems associated with having the indexing occurring afterwards, so I don't think this bug can be fixed without adversely affecting other existing documents that rely on the indexing occurring before the link text.
Update 2021-11-22: this has now been patched in glossaries-extra v1.48. If there are no problems encountered, the same patch will be applied to the base glossaries package.
Update 2022-10-19: this should now be fixed in glossaries v4.50. When you update glossaries, make sure you also update to mfirstuc v2.08 and glossaries-extra v1.49.
Comments
11 comments.
Date: 2021-11-06 02:14:20
Setting wrgloss=after doesn't work locally: feeding
\documentclass{article} \pagestyle{empty} \usepackage{amssymb} \usepackage[unicode,hidelinks]{hyperref} \usepackage[makeindex,nomain]{glossaries-extra} \newglossary[nlg]{notation}{not}{ntn}{Symbols} \makeglossaries \newcommand{\booleanSetSymbol}{\mathbb{B}}%%% for pdflatex %\newcommand{\booleanSetSymbol}{𝔹}%%% for lualatex \newcommand{\powerSetSymbol}{\mathfrak{P}}%%% for pdflatex %\newcommand{\powerSetSymbol}{𝒫}%%% for lualatex %\usepackage{unicode-math}%%% for lualatex \newglossaryentry{not:booleanValues}{type=notation, name=\(\booleanSetSymbol\), text=\booleanSetSymbol, description={The set of Boolean values.}} \newglossaryentry{not:powerset}{type=notation, name=\(\powerSetSymbol\), text=\powerSetSymbol, description={The power set of the set \(Z\) is denoted by \(\powerSetSymbol(Z)\).}} \newglossaryentry{not:function}{type=notation, name={\(\_\mathord{\to}\_\)}, text={\_\to\_}, sort={function}, description={The notation \(X{\to}Y\) means the set of all functions with domain \(X\) and codomain \(Y\). Following Bourbaki, we see a function as a triple (function graph, domain, codomain); a function \(f\allowbreak\in\allowbreak X{\to}Y\), traditionally written as \(f\colon\allowbreak X\penalty1\to\penalty1 Y\), is thus \(\bigl(\mskip-1mu plus.5mu minus.5mu\{(x,f\mskip-.4mu plus.2mu minus.2mu (x\mskip-.3mu plus.15mu minus.15mu)\mskip-.5mu plus.25mu minus.25mu)\penalty2\mid\penalty1 x\mskip-3mu plus1mu minus1mu\in\mskip-3mu plus1mu minus1mu X \penalty3\land\penalty3 y\mskip-3mu plus1mu minus1mu\in\mskip-3mu plus1mu minus1mu Y\},\allowbreak X,\allowbreak Y\mskip-.3mu plus.15mu minus.15mu\bigr)\).}, user1={function}, user2={functions}, user3={map}, user4={maps}, user5={\colon}, user6={\to}} \begin{document}% \newlength{\myLen}\setlength{\myLen}{33em}% \noindent Line 1. Without gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\booleanSetSymbol\)\\ \noindent Line 4. With gls and wrgloss=after:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls[wrgloss=after]{not:booleanValues}\)\\ \noindent Line 7. With gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls{not:booleanValues}\)\\ \noindent Line 10. Without gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\powerSetSymbol(\Sigma)\)\\ \noindent Line 13. With gls and wrgloss=after:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls[wrgloss=after]{not:powerset}(\Sigma)\)\\ \noindent Line 16. With gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls{not:powerset}(\Sigma)\)\\ \noindent Line 19. \printglossaries \end{document}to the pdflatex-makeglossaries loop leads to [Link].
If you'd set it globally, you'd also get it after the arrow (as after all “glossarized” symbols).
Date: 2021-11-06 09:59:09
I'll look into it further. If the page numbers aren't important (for example, if you are only indexing to ensure the symbols appear in the list but are using nonumberlist
to suppress the number list) then the savewrites
package option might solve the problem. This defers the file writes to the end of the document. The main drawback with this option is that the page numbers can be off by one due to TeX's asynchronous output routine.
Date: 2021-11-06 16:51:04
Repying to: Nicola Talbot 🦜 2021-11-06 09:59:09
Thank you in advance!
Page numbers are important to me: it's a long book.
In the preamble, I have
\PassOptionsToPackage{mainaux,starttoc,index,glossary}{rerunfilecheck} \ifxetexorluatex \usepackage[unicode,pdftitle={\bookTitleInOneLine},hidelinks,pdfauthor={\authorList}]{hyperref} \else \ifpdf \usepackage[unicode,pdftitle={\bookTitleInOneLine},hidelinks,pdfauthor={\authorList}]{hyperref} \else \usepackage[unicode,pdftitle={\bookTitleInOneLine},hidelinks,breaklinks=true,pdfauthor={\authorList}]{hyperref}%%& In DVI, we want to wrap links properly. \usepackage[hyphenbreaks]{breakurl} \fi \fifollowed by
\usepackage[makeindex,toc,nogroupskip,nomain]{glossaries-extra} \setglossarystyle{long3col} \renewcommand{\glspagelistwidth}{7.35em}%%% Adjust this value manually such that it fits. \GlsSetQuote{+} %%% Hack to work with "makeindex -g", cf. http://tug.ctan.org/tex-archive/macros/latex/contrib/glossaries/glossaries-user.html#sec:languagesThe back matter contains
{\makeatletter\setlength\tabcolsep{5\p@}\makeatother% \let\oldarraystretch\arraystretch% \renewcommand{\arraystretch}{2}% \renewenvironment{theglossary}% {\begin{longtable}% {@{}lp{\glsdescwidth}>{\smaller}p{\glspagelistwidth}@{}}% }{% \end{longtable}% }% \LTpre=0.0pt%%%% Cf. http://tex.stackexchange.com/a/482259. Original \LTpre value is \bigskipamount . \printglossaries}As of now, I put braces around
\gsl
.Date: 2021-11-06 16:53:23
Typo.
I feel that it's not the user's main text that has to deal with hyphenation issuesshould read
I feel that it's not the user's main text that has to deal with line-breaking issues
Date: 2021-11-06 17:22:14
Following on from David's suggestion on TeX.SX to group \index
you could try the following (untested):
\renewcommand*{\glswriteentry}[2]{% \ifglsindexonlyfirst \ifglsused{#1}{}{{#2}}% \else {#2}% \fi }
Date: 2021-11-11 22:38:24
The option you've suggested cures the standard setting at least in the original minimal example. The setting wrgloss=after
is as ineffective (or as broken) as it was before. Feeding
\documentclass{article} \pagestyle{empty} \usepackage{amssymb} \usepackage[unicode,hidelinks]{hyperref} \usepackage[makeindex,nomain]{glossaries-extra} \renewcommand*{\glswriteentry}[2]{% \ifglsindexonlyfirst \ifglsused{#1}{}{{#2}}% \else {#2}% \fi } \newglossary[nlg]{notation}{not}{ntn}{Symbols} \makeglossaries \newcommand{\booleanSetSymbol}{\mathbb{B}}%%% for pdflatex %\newcommand{\booleanSetSymbol}{𝔹}%%% for lualatex \newcommand{\powerSetSymbol}{\mathfrak{P}}%%% for pdflatex %\newcommand{\powerSetSymbol}{𝒫}%%% for lualatex %\usepackage{unicode-math}%%% for lualatex \newglossaryentry{not:booleanValues}{type=notation, name=\(\booleanSetSymbol\), text=\booleanSetSymbol, description={The set of Boolean values.}} \newglossaryentry{not:powerset}{type=notation, name=\(\powerSetSymbol\), text=\powerSetSymbol, description={The power set of the set \(Z\) is denoted by \(\powerSetSymbol(Z)\).}} \newglossaryentry{not:function}{type=notation, name={\(\_\mathord{\to}\_\)}, text={\_\to\_}, sort={function}, description={The notation \(X{\to}Y\) means the set of all functions with domain \(X\) and codomain \(Y\). Following Bourbaki, we see a function as a triple (function graph, domain, codomain); a function \(f\allowbreak\in\allowbreak X{\to}Y\), traditionally written as \(f\colon\allowbreak X\penalty1\to\penalty1 Y\), is thus \(\bigl(\mskip-1mu plus.5mu minus.5mu\{(x,f\mskip-.4mu plus.2mu minus.2mu (x\mskip-.3mu plus.15mu minus.15mu)\mskip-.5mu plus.25mu minus.25mu)\penalty2\mid\penalty1 x\mskip-3mu plus1mu minus1mu\in\mskip-3mu plus1mu minus1mu X \penalty3\land\penalty3 y\mskip-3mu plus1mu minus1mu\in\mskip-3mu plus1mu minus1mu Y\},\allowbreak X,\allowbreak Y\mskip-.3mu plus.15mu minus.15mu\bigr)\).}, user1={function}, user2={functions}, user3={map}, user4={maps}, user5={\colon}, user6={\to}} \begin{document}% \newlength{\myLen}\setlength{\myLen}{33em}% \noindent Line 1. Without gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\booleanSetSymbol\)\\ \noindent Line 4. With gls and wrgloss=after:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls[wrgloss=after]{not:booleanValues}\)\\ \noindent Line 7. With gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls{not:booleanValues}\)\\ \noindent Line 10. Without gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\powerSetSymbol(\Sigma)\)\\ \noindent Line 13. With gls and wrgloss=after:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls[wrgloss=after]{not:powerset}(\Sigma)\)\\ \noindent Line 16. With gls:\\ \hspace*{\myLen}\(\Sigma\mathrel{\glsuservi{not:function}}\gls{not:powerset}(\Sigma)\)\\ \noindent Line 19. \printglossaries \end{document}to the standard
pdflatex
-makeglossaries
loop leads to [Link].Date: 2021-11-12 08:21:13
I will add a patch to glossaries-extra first. If that doesn’t have any unexpected side effects reported I’ll also add it to the base package.
Date: 2021-11-12 17:46:14
Thanks in advance!
In fact,
The option you've suggested cures the standard setting at least in the original minimal example.is probably unintelligible the way stated. I tremendously apologize. It should better read
The solution (or the hack, depending on the viewpoint) you've suggested cures the problem in the original minimal example.Perhaps, you might wish to make sure first that
wrgloss=after
also solves the original problem. (After all, according to David and egreg, putting \index
after the indexed term solves the corresponding problem for standard non-glossaries indexing.)Cheers,
Peter
Date: 2021-11-12 17:56:36
… or, perhaps, there might be a way to somehow sidestep the whatsits in math mode completely favour of some other feature of (Lua)(La)TeX. When I think about it, I use pdflatex
for a draft version and lualatex
for a clean version of my book (and xelatex
is dead), so, ultimately, I care more about lualatex
now.
Date: 2021-11-12 17:56:45
My suggestion was just a stopgap measure until the issue can be properly fixed. While wrgloss=after
may address the problem for documents such as yours where \gls
only produces short content (such as a mathematical symbol), longer content (such as phrases) may need to have the indexing performed at the start in the event that the content crosses a page-break. So the issue needs fixing for both cases.
The modification that I've applied (which will be in the next release of glossaries-extra) fixes the problem in your original MWE. This follows the suggestions on TeX.SX to group both the indexing and the text (regardless of which side of the text the indexing occurs).
There are some other unrelated changes being made to glossaries-extra. Once they are finished I'll upload the new version.
Add Comment
Page permalink: https://www.dickimaw-books.com/bugtracker.php?key=189
Date: 2021-11-06 00:57:09
I see. Would putting indexing afterwards for PARTICULAR commands (e.g., the set of Booleans 𝔹 or the power set 𝒫) in NEW documents have an adverse effect? I might imagine suboptimal kerning if punctuation follows, though I was unable to construct an example. In any case, we might wish to continue to have a choice of where to put the indexing command: to the front or to the back for other reasons (say, hyphenation points or calling from a macro).
As for the issue with
Output: [Link] .\index
, I now found some other workarounds (thanks to David, cf. [TeX.SX Link]):Here, I used the fact (which I skipped in the original minimal example due to its minimality) that the letter for the set of Boolean values I really use is 𝔹, not 𝐵.
I have a similar situation in my slightly less minimal example. Namely, I have enclosing
to\mathbb
(forpdflatex
),\mathfrak
(forpdflatex
), and evenhyperref
links (for bothpdflatex
andlualatex
). Feedingpdflatex
-makeglossaries
results in [Link].Having said that, I wonder whether we might invoke the internal indexing commands from some internal set of braces (ideally, coming from
hyperref
, and if not, from\mathbb
or\mathfrak
)? I feel that it's not the user's main text that has to deal with hyphenation issues, butglossaries
, orglossaries-extra
, or the preamble of the user's LaTeX document at worst.