5

I'm building a complex index of dates & I'm using a lot of home commands. All is ok except using \datetime commands with argument for exemple

\newcommand*{\qd}[1]{\ordinalnum{#1}~siècle\index{\ordinalnum{#1}~siècle}}
\qd{8}

It don't made the entry in the index. I show you all my file :

% !TEX encoding = UTF-8 Unicode
\documentclass{scrbook}
\usepackage[frenchb]{babel} 
\usepackage[quiet]{fontspec}                    
\usepackage[automark,headsepline]{scrpage2}         
\usepackage[babel,french=guillemets*]{csquotes}
\usepackage{etoolbox}
\usepackage{ifthen}
\usepackage{ifmtarg}
\usepackage{fp}
\usepackage[dayofweek]{datetime} 
\usepackage[xindy={language=french, codepage=utf8}, style=altlist]{glossaries}
\usepackage[xindy, splitindex]{imakeidx}
\usepackage[itemlayout=singlepar]{idxlayout}
\setmainfont[Mapping=tex-text, Ligatures={Common, Rare}, Numbers={OldStyle}]{Adobe Garamond Pro}
\addtokomafont{disposition}{\normalfont}

\renewcommand{\fmtord}[1]{\up{#1}}
\makeatletter\patchcmd{\@ordinalMfrench}{eme}{ème}{}{}\makeatother

\makeglossaries
\def\xindylangopt{-M lang/french/utf8-lang -M style1.xdy}
\makeindex[name=can, title=Index des dates, options=\xindylangopt, intoc]

\newglossaryentry{Test 1}{name = Test 1, description = {Test 1 glossaire}}
\newglossaryentry{Test 2}{name = Test 2, description = {Test 2 glossaire}}

\newcommand*{\qds}[1]{\ordinalnum{#1}~siècle\index[can]{\ordinalnum{#1}~siècle}}
\newcommand*{\qdo}[1]{\ordinalnum{#1}~siècle\index[can]{{#1}~siècle}}

\begin{document}
\gls{Test 1}, \gls{Test 2}, 
\qds{8}, \qdo{9}, Test index\index[can]{Test index}
\printindex[can]
\printglossary
\end{document}

I compile with that :

% xelatex Date.tex
% makeglossaries Date
% xelatex -shell-escape Date.tex
% xelatex Date.tex

An idea ? How find a solution ? Thanks

2

Either it is a bug or a feature, but \ordinalnum fails somehow inside the \index[can]{...} command, it does not like [] due to some reason unknown to me.

The workaround is to use \ordinal which uses a counter. I defined a dummy counter, which is fed with the century number (1st argument) and then use \ordinal inside the commands qds and qdo.

\documentclass{scrbook}
\usepackage[frenchb]{babel} 
\usepackage[quiet]{fontspec}                    
\usepackage[automark,headsepline]{scrpage2}         
\usepackage[babel,french=guillemets*]{csquotes}
\usepackage{etoolbox}
\usepackage{ifthen}
\usepackage{ifmtarg}
\usepackage{fp}
\usepackage[dayofweek]{datetime} 
\usepackage[xindy={language=french, codepage=utf8}, style=altlist]{glossaries}
\usepackage[xindy, splitindex]{imakeidx}

\usepackage[itemlayout=singlepar]{idxlayout}
%%%% Commented out since font is not installed on my computer
%\setmainfont[Mapping=tex-text, Ligatures={Common, Rare}, Numbers={OldStyle}]{Adobe Garamond Pro}
\addtokomafont{disposition}{\normalfont}

\renewcommand{\fmtord}[1]{\up{#1}}%
\makeatletter\patchcmd{\@ordinalMfrench}{eme}{ème}{}{}\makeatother

\makeglossaries
\def\xindylangopt{-M lang/french/utf8-lang -M style1.xdy}
\makeindex[name=can, title={Index des dates}, options={\xindylangopt}, intoc]
\makeindex[name=can,title={Index des dates}]


\newglossaryentry{Test 1}{name = Test 1, description = {Test 1 glossaire}}
\newglossaryentry{Test 2}{name = Test 2, description = {Test 2 glossaire}}


%%%%%% My additions and workaround ---> instead of using the number directly
%%%%%% store the number to a dummy counter and use \ordinal instead of \ordinalnum


\newrobustcmd{\ProvideOrdinalCounter}[1]{%
\ifltxcounter{#1}{%
}{%
\newcounter{#1}%
}%
}% End Of \ProvideOrdinalCounter


\newcommand{\qds}[1]{%
\setcounter{CenturyCounter}{#1}%
\ordinal{CenturyCounter}~siècle\index[can]{\ordinal{CenturyCounter}~siècle}%
}%

\newcommand{\qdo}[1]{%
  \setcounter{CenturyCounter}{#1}%
  \ordinal{CenturyCounter}~siècle\index[can]{\ordinal{CenturyCounter}~siècle}%
}%

\AtBeginDocument{%
 \ProvideOrdinalCounter{CenturyCounter}%
}%



\begin{document}
\gls{Test 1}, \gls{Test 2}, 
\qds{8}, \qdo{9}, Test index\index[can]{Test index}
\printindex[can]
\printglossary
\end{document}

enter image description here

1
  • Thank you for your idea. I'll test… It's a good way using counters ! – Zouib May 9 '14 at 15:05
4

The fix is easy:

\newcommand*{\qds}[1]{%
  \ordinalnum{#1}~siècle%
  \index[can]{\protect\ordinalnum{#1}~siècle}%
}

Here's the index (I removed the style1, of course, and also the call \qdo{8} call).

enter image description here

And here's the .ind file

\begin{theindex}
  \providecommand*\lettergroupDefault[1]{}
  \providecommand*\lettergroup[1]{%
      \par\textbf{#1}\par
      \nopagebreak
  }

  \lettergroupDefault{default}
  \item \ordinalnum {8}~siècle, 1

  \indexspace

  \lettergroup{T}
  \item Test index, 1

\end{theindex}
1
  • It's the easier answer. Thank you very much – Zouib May 9 '14 at 17:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.