2

When I use the glossaries package (version 4.50), there is an extra space before and after the word. Previously, this problem did not exist with the following settings. I updated the TeX distribution today.

xelatex
xindy -L persian-variant1 -C utf8 -I xindy -M main.xdy -t main.glg -o main.gls main.glo
xindy -L persian-variant1 -C utf8 -I xindy -M main.xdy -t main.blg -o main.bls main.blo
xelatex

MWE:

\begin{filecontents}[overwrite]{glossSettings.tex}
    % Persian to English style
    \newglossarystyle{myFaToEn}{%
        \renewenvironment{theglossary}{}{}%
        \renewcommand*{\glsgroupheading}[1]{%
            \subsection*{\glsgetgrouptitle{##1}}%
        }%
        \renewcommand*{\glossentry}[2]{%
            \noindent\glsentryname{##1}\space\dotfill\space\glsentrytext{##1}\par       
        }%
    }
    %  English to Persian style
    \newglossarystyle{myEntoFa}{%
        \renewenvironment{theglossary}{}{}%
        \renewcommand*{\glsgroupheading}[1]{%
            \begin{LTR}
                \subsection*{\glsgetgrouptitle{\lr{##1}}}
            \end{LTR}%
        }%
        \renewcommand*{\glossentry}[2]{%
            \noindent\glsentrytext{##1}\space\dotfill\space\glsentryname{##1}\par       
        }%
    }
    
    \newglossary[glg]{english}{gls}{glo}{واژه‌نامهٔ انگلیسی به فارسی}
    \newglossary[blg]{persian}{bls}{blo}{واژه‌نامهٔ فارسی به انگلیسی}
    \makeglossaries
    \glsdisablehyper
    
    \NewCommandCopy{\oldgls}{\gls}
    \NewCommandCopy{\oldglspl}{\glspl}
    
    \makeatletter
    \renewrobustcmd*{\gls}{\@ifstar\@msgls\@mgls}
    \newcommand*{\@mgls}[1]{%
        \ifthenelse{\equal{\glsentrytype{#1}}{english}}%
        {\oldgls{#1}\glsuseri{f-#1}}%
        {\lr{\oldgls{#1}}}%
    }
    \newcommand*{\@msgls}[1]{%
        \ifthenelse{\equal{\glsentrytype{#1}}{english}}%
        {\glstext{#1}\glsuseri{f-#1}}%
        {\lr{\glsentryname{#1}}}%
    }
    \renewrobustcmd*{\glspl}{\@ifstar\@msglspl\@mglspl}
    \newcommand*{\@mglspl}[1]{%
        \ifthenelse{\equal{\glsentrytype{#1}}{english}}%
        {\oldglspl{#1}\glsuseri{f-#1}}%
        {\oldglspl{#1}}%
    }
    \newcommand*{\@msglspl}[1]{%
        \ifthenelse{\equal{\glsentrytype{#1}}{english}}%
        {\glsplural{#1}\glsuseri{f-#1}}%
        {\glsentryplural{#1}}%
    }
    \makeatother
    
    \newcommand{\newword}[4]{%
        \newglossaryentry{#1}{%
            type={english},%
            name={\lr{#2}},%
            plural={#4},%
            text={#3},%
            description={}%
        }%
        \newglossaryentry{f-#1}{%
            type={persian},%
            name={#3},%
            text={\lr{#2}},%
            description={}%
        }%
    }
    
    \NewCommandCopy{\Oldprintglossary}{\printglossary}
    \renewcommand{\printglossary}{%
        \twocolumn
        \setglossarystyle{myEntoFa}%
        \Oldprintglossary[type=english]%
        \cleardoublepage
        \setglossarystyle{myFaToEn}%
        \Oldprintglossary[type=persian]%
        \onecolumn
    }
\end{filecontents}

\documentclass{report}

\usepackage[hidelinks]{hyperref} 
\usepackage[xindy,toc]{glossaries}

\usepackage{xepersian}
\settextfont{Amiri} % This font have been installed with TeX distribution

\input{glossSettings}

\newword{test}{Test}{آزمایش}{آزمایش‌ها}

\begin{document}
    
    .\gls{test}.
    
    \printglossary

\end{document}

enter image description here

1 Answer 1

4

I don't know what changed (probably something in glossaries) so that it matters now, but the culprit is xepersian.

In hyperref-xepersian.def it adds some commands to a hyperref hook with \pdfstringdefDisableCommands and inserts a spurious space in the last line:

\pdfstringdefDisableCommands{%
\let\lr\@firstofone
\let\rl\@firstofone
\def\XePersian{XePersian}    %<--------- spurious space here
}

This should be reported. As a work around you can trim the space after loading xepersian:

\usepackage{xepersian}
\ExplSyntaxOn
\tl_trim_spaces:N\pdfstringdefPreHook
\ExplSyntaxOff
3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .