当我使用词汇表包(版本 4.50)时,单词前后会多出一个空格。以前,使用以下设置时不存在此问题。我今天更新了 TeX 发行版。
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
梅威瑟:
\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}
答案1
我不知道发生了什么变化(可能是词汇表中发生了一些变化)以至于现在很重要,但罪魁祸首是 xepersian。
其中hyperref-xepersian.def
向 hyperref 钩子添加了一些命令,\pdfstringdefDisableCommands
并在最后一行插入了一个虚假空格:
\pdfstringdefDisableCommands{%
\let\lr\@firstofone
\let\rl\@firstofone
\def\XePersian{XePersian} %<--------- spurious space here
}
应该报告此情况。作为解决方法,您可以在加载 xepersian 后修剪空间:
\usepackage{xepersian}
\ExplSyntaxOn
\tl_trim_spaces:N\pdfstringdefPreHook
\ExplSyntaxOff