1

I produce in the end of a book written in arabic, a Right-To-Left language, two dictionaries of technical terms with their english version, using the glossaries package, one dictionary sorted by its arabic (numbered) entries and the other sorted by the english entries.

I want to make the output of the \gls commands, defined by \defglsentryfmt, as its number in the glossary if it have been used before and in footnote its english translation for the first use. The commands are good at all else if the entries are in boxes like those produced by tcolorbox, where the footnotes are not produced...

I found a solution for this problem (it seems to be!) by using the \ifglsused command, in a special use... Before every box, I set a test number, \TestGlossNumber, to 1, to indicate that the glossary entry will be used in a box and I recall it immediately after the box, then I put the output of the \gls entry under the condition {\TestGlossNumber=1} in the \ifglsused command, and then after the box, I recall the \TestGlossNumber to 0, for remaining the normal conditions..

Here is the .tex file used:

\documentclass{article}

\usepackage{multicol} % Multi-columning
\usepackage[most]{tcolorbox} %So called package for boxing and so...
\newtcolorbox{mybox}[1][]{enhanced,left=5pt,right=5pt,oversize,colframe=black,colback=white,boxrule=.5pt,breakable,
before=\par\smallskip\centering,width=\textwidth,arc=0pt,outer arc=0pt,#1}% 

\usepackage[entrycounter,nomain,nonumberlist,toc,section=section]{glossaries}
\usepackage{glossary-mcols}

%%%%%%%%%%%%%%  Arabic Commands and fonts
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmainfont[Script=Arabic,Scale=1.2]{Arial}
\newfontfamily\englishfont[Scale=1]{Times New Roman}
\setmonofont{Courier New}
\let\arabicfonttt\ttfamily
\setsansfont[Script=Arabic,Scale=1.5]{Arial}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%  Horizontal english LTR footnotes with the manyfoot package    
\usepackage[perpage,para*]{manyfoot}
\textwidthfootnoterule
%%%%%%%%%%%%  ENGLISH LTR
\SetFootnoteHook{\setLTR}
\DeclareNewFootnote[para]{C}
\makeatletter
\let\c@footnoteC\c@footnote
\makeatother
\def\Footnotetextbox#1#2{\footnotetextC[#1]{\hspace*{2pt}\LR{#2}}\stepcounter{footnoteC}}
\renewcommand{\thefootnoteC}{\textcolor{green}{\fnsymbol{footnoteC}}}

%%% The glossaries 
\newglossary[aoc]{ARDico}{aox}{aoo}{\LR{The entries in arabic order}}
\newglossary[eoc]{ENDico}{eox}{eoo}{\LR{The entries in english order}}

\makeglossaries

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  ORGANIZE ENTRIES AND GLOSSARIES OF FOOTNOTES
\newcommand*{\entrydico}[2]
{%
        \newglossaryentry{edic-#1}
    {type=ENDico,name={},sort={#2},
    description={\LR{
        \LR{#2}  \hfill\glsrefentry{adic-#1}
        \vspace*{1pt}\hrule\vspace*{1pt}}}
    }
    \newglossaryentry{adic-#1}
    {type=ARDico,name={},text={#2},sort={#1},
    description={#1  \hfill \LR{#2} \vspace*{2pt}\hrule\vspace*{2pt}}
    }
}

%%%%%%% The format of the output link   
\defglsentryfmt[ENDico]{}
\defglsentryfmt[ARDico]{
\ifglsused{\glslabel}%% For the used gls entries
{\ifthenelse{\equal{\TestGlossNumber}{1}}%% For use in a box
{\Footnotetextbox{\value{footnoteC}}{\glsentrytext{\glslabel}}} %% gls Entries in a box.. ifthenelse TRUE
{$^{\textcolor{red}{\glsrefentry{\glslabel}}}$} %% Usual gls entries...  ifthenelse FALSE
}
{%% For the unused gls entries
 \footnoteC{\glsentrytext{\glslabel}}$^{\textcolor{red}{\glsrefentry{\glslabel}}}$
}%
                    }

\newcommand{\putgls}[1]{\gls{adic-#1}\gls{edic-#1}} %% For calling the gls entries

%%% My glossary own style for writing 2-columns index in left-to-right mode
\newglossarystyle{LTRmcolindex}{%
\setglossarystyle{index}%
\renewenvironment{theglossary}%
{%
 \LTRmulticolcolumns
 \begin{multicols}{\glsmcols}
 \setlength{\parindent}{0pt}%
 \setlength{\parskip}{0pt plus 0.3pt}%
 \let\item\@idxitem}%
{\end{multicols}}%
                                }

\newcommand{\printARglossary}{\glsaddall%
\printglossary[type=ARDico,style=mcolindex]}
\newcommand{\printENglossary}{\glsaddall%
\printglossary[type=ENDico,style=LTRmcolindex,entrycounter=false]}

%% Some glossary entries
\entrydico{Aword1}{Eword1}\entrydico{Aword2}{Eword2}\entrydico{Aword3}{Eword3}\entrydico{Aword4}{Eword4}
\entrydico{Aword5}{Eword5}\entrydico{Aword6}{Eword6}
\begin{document}
\edef\TestGlossNumber{0}

\raggedright\LR{
A first entry\putgls{Aword1}. A second entry\putgls{Aword4}

A first repeated entry\putgls{Aword1}. A second repeated entry\putgls{Aword4}
}

\edef\SaveFootnoteNumber{\number\value{footnoteC}}
\edef\TestGlossNumber{1}
\begin{mybox}
\raggedright\LR{
Another entry\putgls{Aword3}. And another\putgls{Aword2}. 
}
\end{mybox}
\setcounter{footnoteC}{\SaveFootnoteNumber}
\stepcounter{footnoteC}
\putgls{Aword3}\putgls{Aword2}
\addtocounter{footnoteC}{-1}
\edef\Testglossnumber{0}
\vspace*{-\baselineskip} %%% To avoid the vertical space produced by \putgls commands..

\edef\TestGlossNumber{0}

\raggedright\LR{
And another\putgls{Aword5}. And another\putgls{Aword6}
}

%%%%        DICTIONARIES
\glsresetentrycounter
\printARglossary
\glsresetentrycounter
\printENglossary
\end{document}

and its compilation, after having produced the glossaries, in command prompt, by the usual commands... enter image description here

My questions are:

1/ Is there a problem for my purpose ? If not, is it the good way to do the job? More precisely, is there a macro doing that in a more elegant way, using the powerfull of the Latex programmation ?

2/ I don't understand whence came the commands \stepcounter{footnoteC} and, after, \addtocounter{footnoteC}{-1}, what I found by "groping"...

3/ Other question. Why the english glossary is opening with "idxitem" ? How can I eliminate it ?

  • Regarding your third question: In the line \let\item\@idxitem, the character @ is no letter, hence the line actually is the let statement \let\item\@ followed by the seven characters idxitem, which then appear in your document. You have to put the command \makeatletterbefore \newglossarystyle{LTRmcolindex} and the command \makeatother after the corresponding closing brace some lines below. Or even better, put all your definitions into a separate file called e.g. mydefs.sty and include it with \usepackage{mydefs} in the preamble. Then you don't need the \makeat... commands. – gernot Sep 5 '16 at 22:00
  • You are right. I tried it and it has good behavior now. Thanks. – Faouzi Bellalouna Sep 5 '16 at 22:06

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.