1

I am using TeXworks to write my Phd thesis in Persian by use of xepersian package. Trying to print 3 glossaries at the end of thesis, I have p roblem with xindy. More specifically, in Persian to English glossary, when I try to group the glossary entries according to Persian alphabets, they are not grouped, and the group titles are not recognized right. I am quite new at Latex, and it is possible that I miss something simple, please help me. Following is the MWE:

\documentclass[twoside]{thesis}

\usepackage[xetex,colorlinks,bookmarksnumbered,citecolor=darkred,urlcolor=darkgreen]{hyperref}
\usepackage{multicol}
\usepackage[all]{hypcap}
\usepackage[xindy,nonumberlist=true,nomain]{glossaries}
\usepackage{url}

\usepackage[localise,extrafootnotefeatures]{xepersian}

\usepackage{xifthen}% Provides \isempty test which is used for glossary

\settextfont[Scale=1]{XB Zar}
\setlatintextfont[Scale=1]{Linux Libertine}
\setdigitfont{Yas}

% Glossary
\glsdisablehyper % disable hyperlinks

% ========================================================
% defining styles

\newglossarystyle{persian-to-english}{%
    \renewenvironment{theglossary}%
        {\begin{multicols}{2}\begingroup \flushright \linespread{1.8}\selectfont}
        {\endgroup \end{multicols}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{\begin{RTL} \subsection*{\rl{\glsgetgrouptitle{##1}}} \end{RTL}}   %
    \renewcommand*{\glsgroupskip}{}%
    % \glossaryentryfield{label}{formatted name}{description}{symbol}{number list}
    \renewcommand*{\glossaryentryfield}[5]{%
        \glstarget{##1}{##2}% persian term
        \dotfill%
        \space \lr{##3} \\%translation term
    }%
    \renewcommand*{\glossarysubentryfield}[6]{%
        \glossaryentryfield{##2}{##3}{##4}{##5}{##6}%
    }%
}
\newglossarystyle{english-to-persian}{%
    \renewenvironment{theglossary}%
        {\begin{multicols}{2}\begingroup \flushright \linespread{1.8}\selectfont}%
        {\endgroup \end{multicols}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{\begin{LTR} \subsection*{\glsgetgrouptitle{##1}} \end{LTR}}
    \renewcommand*{\glsgroupskip}{}%
    % \glossaryentryfield{label}{formatted name}{description}{symbol}{number list}
    \renewcommand*{\glossaryentryfield}[5]{%
        \glstarget{##1}{##2}%translation term
        \dotfill%
        \space \rl{##3} \\%persian term
    }%
    \renewcommand*{\glossarysubentryfield}[6]{%
        \glossaryentryfield{##2}{##3}{##4}{##5}{##6}%
    }%
}
\newglossarystyle{abbreviation-list}{%
    \renewenvironment{theglossary}{}{}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{\begin{LTR} \subsection*{\glsgetgrouptitle{##1}} \end{LTR}}%
    \renewcommand*{\glsgroupskip}{\vskip 10mm}%
    % \glossaryentryfield{label}{formatted name}{description}{symbol}{number list}
    \renewcommand*{\glossaryentryfield}[5]{%
        \glstarget{##1}{##3}%translation term
        \dotfill%
        \space \lr{##2} \\%persian term
    }%
    \renewcommand*{\glossarysubentryfield}[6]{%
        \glossaryentryfield{##2}{##3}{##4}{##5}{##6}%
    }%
}

% ========================================================
% defining glossary terms

\newglossary{p2e-terms}{fa.gls}{fa.glo}{واژه‌نامه‌ی فارسی به انگلیسی} % persian to english
\newglossary{e2p-terms}{en.gls}{en.glo}{واژه‌نامه‌ی انگلیسی به فارسی} % english to persian
\newglossary{ac-terms}{ac.gls}{ac.glo}{فهرست اختصارات} % abbreviation Glossary

\newcommand{\newterm}[5][]{% params: [key]{persian}{english}{persian-plural}{english-abbreviation}
\ifthenelse{\isempty{#1}}{\def\key{#2}}{\def\key{#1}}%
\newglossaryentry{ac:\key}{type={ac-terms}, name={#3}, description={#5}, sort={#5}}% abbreviation glossary
\newglossaryentry{en:\key}{type={e2p-terms}, name={#3}, description={#2}, sort={#3}}% english glossary
\newglossaryentry{fa:\key}{type={p2e-terms}, name={\rl{#2}}, plural={\rl{#4}}, description={#3}, user1={#5}, sort={#2}}% persian glossary
}

\defglsentryfmt[p2e-terms]{%
  \ifdefempty\glsinsert{% use word itself
    \ifglsused\glslabel{% subsequent usages
        \glsifplural{%
          \glscapscase{\glsentryplural{\glslabel}}%
            {\Glsentryplural{\glslabel}}%
            {\mfirstucMakeUppercase{\glsentryplural{\glslabel}}}%
        }%
        {%
          \glscapscase{\glsentrytext{\glslabel}}%
            {\Glsentrytext{\glslabel}}%
            {\mfirstucMakeUppercase{\glsentrytext{\glslabel}}}%
        }%
    }%
    {% first usage
       \glsifplural{%
          \glscapscase{\glsentryfirstplural{\glslabel}}%
            {\Glsentryfirstplural{\glslabel}}%
            {\mfirstucMakeUppercase{\glsentryfirstplural{\glslabel}}}%
        }%
        {%
          \glscapscase{\glsentryfirst{\glslabel}}%
            {\Glsentryfirst{\glslabel}}%
            {\mfirstucMakeUppercase{\glsentryfirst{\glslabel}}}%
        }%
        \space(\lr{\glsentryuseri{\glslabel}\LTRfootnote{\glsentrydesc{\glslabel}}})
      }%
    }%
  {% override word with glsinsert
    \ifglsused\glslabel{% subsequent usages
      \glsinsert%
    }%
    {% first usage
     \glsinsert\space(\lr{\glsentryuseri{\glslabel}\LTRfootnote{\glsentrydesc{\glslabel}}})
     }%
  }%
}%

%\term[نمونه‌های]{key}
\newcommand{\term}[2][]{%
\glsadd{en:#2}%
\glsadd{ac:#2}%
\ifthenelse{\isempty{#1}}{\gls{fa:#2}}{\gls{fa:#2}[#1]}%
}
\newcommand{\termpl}[2][]{%
\glsadd{en:#2}%
\glsadd{ac:#2}%
\ifthenelse{\isempty{#1}}{\glspl{fa:#2}}{\glspl{fa:#2}[#1]}%
}

% ========================================================
% defining \printpersianglossary \printenglishglossary \printabbreviationglossary

\newcommand{\printpersianglossary}[1][واژه‌نامه‌ی فارسی به انگلیسی]{%
    \phantomsection%
    \addcontentsline{toc}{chapter}{#1}%
    \renewcommand{\glossarymark}[1]{\markboth{##1}}%
    \RTLmulticolcolumns%
    \printglossary[type={p2e-terms},style={persian-to-english},title={\rl{#1}}]%
}
\newcommand{\printenglishglossary}[1][واژه‌نامه‌ی انگلیسی به فارسی]{%
    \phantomsection%
    \addcontentsline{toc}{chapter}{#1}%
    \renewcommand{\glossarymark}[1]{\markboth{##1}}%
    \begin{latin}%
    \LTRmulticolcolumns
    \printglossary[type={e2p-terms},style={english-to-persian},title={\rl{#1}}]%
    \end{latin}%
}
\newcommand{\printabbreviationglossary}[1][فهرست اختصارات]{%
    \phantomsection%
    \addcontentsline{toc}{chapter}{#1}%
    \renewcommand{\glossarymark}[1]{\markboth{##1}}%
    \begin{latin}%
    \LTRmulticolcolumns
    \printglossary[type={ac-terms},style={abbreviation-list},title={\rl{#1}}]%
    \end{latin}%
}

% ========================================================
%

\makeglossaries

\newterm[mac]{لایه کنترل دسترسی}{Medium access control}{}{MAC}
\newterm[wichan]{کانال بی‌سیم}{Wireless channel}{کانال‌های بی‌سیم}{WiChan}
\newterm[rn]{گره رله}{Relay node}{}{RN}

\begin{document}

به عنوان نمونه ترتیب کلمات زیر در واژه‌نامه فارسی به انگلیسی درست نیست. اصلاً گروه‌بندی نمی‌شوند.
\term{mac}
\term{wichan}
\term{rn}

{%
\cleardoublepage\setlength{\baselineskip}{1cm}\printpersianglossary%
\cleardoublepage\printenglishglossary%
\cleardoublepage\printabbreviationglossary%
}

\end{document} 
  • 1
    Welcome to TeX - LaTeX! Can you tell us which thesis.cls you are using (there are many different ones) or prefarably change the class to a standard one (e.g. report) if the problem is visible there. – Andrew Swann Jun 12 at 7:26
  • In fact, I use a '.cls' file which has been written by Dr. Vafa Khaleghi for my university (Sharif university of technology), that is 'sharifthesis.cls'. However, the problem is there in general case. I compiled the mini code above, and the problem shows. I think its some thing simple that I miss. – user190860 Jun 14 at 4:08
  • Can you show the commands you use to run xindy? – Andrew Swann Jun 14 at 7:06
  • I think at the very least you would need to tell the make glossary script which languagues to use. However, this is not something I know much about. – Andrew Swann Jun 14 at 15:17
  • I use the XeLaTeX from the 'Typeset' menu, then I use Makeglossaries, and again I use XeLaTeX twice. Makeglossaries runs the command makeglossaries with the input argument $basename. I suppose it runs xindy by default. I know that xindy with specific format should be run, but I don't know how to create such sequence of commands in TeXworks. Specially, since in the printed glossaries I don't see any problem in sorting English words, and even in in Persian words (by the order of Arabic alphabet), I guessed that xindy-persian is running. – user190860 Jun 14 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.