%% ordinalrefdoc.tex
%% Copyright 2005 Glad Deschrijver
%%
%% ordinalref - A LaTeX package for using ordinal numbers in references
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
% This work consists of the files ordinalref.sty and ordinalrefdoc.tex.
%
% -----------------------------------------------------------------------
%
% Ordinalref seems to work with any of the following:
\documentclass{article}  % standard classes
%\documentclass{book}
%\documentclass{letter}
%\documentclass{report}
%\documentclass{memoir}   % memoir
%\documentclass{artikel1} % ntgclass
%\documentclass{artikel2}
%\documentclass{artikel3}
%\documentclass{boek}
%\documentclass{brief}
%\documentclass{rapport1}
%\documentclass{rapport3}

%\usepackage[english,dutch,french,spanish]{babel}
\usepackage[english]{ordinalref}
%\usepackage{ordinalref}
\newcounter{testcnt}

\begin{document}

\title{The \texttt{ordinalref} package}
\author{Glad Deschrijver}
\date{v0.2 (2005/08/01)}
\maketitle

%\tableofcontents

\section{Usage}

The package should be loaded in your LaTeX document with the command
\begin{verbatim}
  \usepackage{ordinalref}
\end{verbatim}

The package provides the commands:
\begin{itemize}
\item \verb+\ordinal+:\\
  replaces a string representing a number into its ordinal counterpart
  (ordinal numbers not greater than 10 are written in full, other
  numbers are abbreviated);

  e.g.\ \verb+\ordinal{2}+ gives second, \verb+\ordinal{23}+ gives 23rd;
\item \verb+\ordinalshort+:\\
  same as above, but abbreviates always;

  e.g.\ \verb+\ordinal{2}+ gives 2nd;
\item \verb+\ordinalref+:\\
  gives an ordinal version of the reference (unabbreviated if the
  number is not greater than 10, abbreviated otherwise);

  e.g.\
  \begin{tabular}[t]{@{}l@{}}
    if \verb+\ref{foo}+ would give 2, then \verb+\ordinalref{foo}+
    gives second;\\
    if \verb+\ref{foo}+ would give (xi), then \verb+\ordinalref{foo}+
    gives sixth;
  \end{tabular}
\item \verb+\ordinalshortref+:\\
  same as above, but abbreviates always.
\end{itemize}

The package is compatible with the package babel.  If babel is not
loaded, then ordinalref will use internal \verb+\iflanguage+ and
\verb+\selectlanguage+ commands.  If no optional argument is given, then
ordinalref uses the language that is used with babel if it is loaded,
otherwise ordinalref uses english.  If both are loaded, then any
optional arguments given to ordinalref must also be given to babel.
Any subsequent \verb+\selectlanguage+ will also change the language of
ordinalref.
Currently only english, french, dutch, spanish and italian are supported.

When using french, you can give an optional argument which determines
the gender of the ordinal number.  If the corresponding substantive is
feminine, then you should use \verb+\ordinal{...}[f]+, when the
corresponding substantive is masculine, then use \verb+\ordinal{...}[m]+;\\
  e.g.\
  \begin{tabular}[t]{@{}l@{}}
    \verb+le \ordinal{1}[m] livre+ gives: le premier livre;\\
    \verb+la \ordinalref{firstsection}[f] section+ gives:
    la premi\`ere section.
  \end{tabular}\\
Similarly, for spanish the following options exist:
  \begin{itemize}
  \setlength{\itemsep}{0em}
  \item \verb+f+: female singular (to obtain plural, use e.g.\
    ``\verb+las \ordinal{1}[f]s+'')
  \item \verb+m+: male singular
  \item \verb+bm+: male singular ordinal number put before the noun;
    this can be used to obtain ``el primer libro'' instead of ``el
    primero libro''.
  \end{itemize}
For italian, the following options are available:
  \begin{itemize}
  \setlength{\itemsep}{0em}
  \item \verb+f+: female singular
  \item \verb+m+: male singular
  \item \verb+fp+: female plural
  \item \verb+mp+: male plural
  \end{itemize}

Warning: in order to let \verb+\ordinalref+ and \verb+\ordinalshortref+
work, the commands \verb+\@newl@bel+, \verb+\label+ and
\verb+\refstepcounter+ are redefined.  This may lead to incompatibilities
with other packages.

% History:
% 0.1: original version
% 0.2: - ordinalref can be used without babel
%      - added spanish and italian language support


\section{Examples}

The following code produces the output given below.

\begin{verbatim}
\setcounter{testcnt}{18}
The \ordinal{\thetestcnt} test.
The \ordinal{21} test.
The \ordinalshort{\thetestcnt} test.
The \ordinalshort{21} test.\\
The \ordinalshort{2147483647} test. % Largest number for which
                                    % it works (on my system)

\section{Test} \label{s1}
\section{Test} \label{s2}
\section{Test} \label{s3}

\begin{enumerate}
\renewcommand{\theenumi}{(\roman{enumi})}
\renewcommand{\labelenumi}{\theenumi}
\item \label{t1} Test
\item \label{t2} Test
\item \label{t3} Test
\item \label{t4} Test
\item \label{t5} Test
\item \label{t6} Test
\end{enumerate}

\begin{figure}
  Test \caption{Test} \label{f1}
\end{figure}

The \ordinalref{s2} section,
the \ordinalref{t4} case,
the \ordinalref{f1} figure.
The \ordinalshortref{s2} section,
the \ordinalshortref{t4} case,
the \ordinalshortref{f1} figure.

\selectlanguage{dutch}

De \ordinalref{s2} sectie,
het \ordinalref{t4} puntje,
de \ordinalref{f1} figuur.
De \ordinalshortref{s2} sectie,
het \ordinalshortref{t4} puntje,
de \ordinalshortref{f1} figuur.

\selectlanguage{french}

La \ordinal{1}[f] section.
Le \ordinal{1}[m] cas.
La \ordinalref{s2} section,
le \ordinalref{t1}[m] cas,
le \ordinalref{t4} cas,
la \ordinalref{f1} figure,
la \ordinal{1}[f].
La \ordinalshortref{s2} section,
le \ordinalshortref{t1}[m] cas,
le \ordinalshortref{t4} cas,
la \ordinalshortref{f1} figure,
la \ordinalshort{1}[f].

\selectlanguage{spanish}

El \ordinal{1}[m] plato.
La \ordinal{1}[f] divisi\'on.
La \ordinalref{s2} secci\'on,
el \ordinalref{t1}[bm] caso,
el \ordinalref{t4}[m] caso,
la \ordinalref{f1} figura,
la \ordinal{1}[f].
La \ordinalshortref{s2} secci\'on,
el \ordinalshortref{t1}[bm] caso,
el \ordinalshortref{t4}[m] caso,
la \ordinalshortref{f1} figura,
la \ordinalshort{1}[f].
El \ordinalref{t1}[bm] caso,
el \ordinal{2}[bm] caso,
el \ordinal{3}[bm] caso,
el \ordinalref{t4}[bm] caso,
los cuatro \ordinal{1}[m]s d\'{\i}as.

\selectlanguage{italian}

Il \ordinal{1}[m] piato.
La \ordinal{1}[f] parte.
La \ordinalref{s2} parte,
il \ordinalref{t1}[m] caso,
il \ordinalref{t4} caso,
la \ordinalref{f1} figura,
la \ordinal{1}[f].
La \ordinalshortref{s2} parte,
il \ordinalshortref{t1}[m] caso,
il \ordinalshortref{t4} caso,
la \ordinalshortref{f1} figura,
la \ordinalshort{1}[f].
Le tre \ordinalref{t4}[fp] opzioni,
i cuatro \ordinal{1}[mp] giorni.
\end{verbatim}

\subsection*{Output of the above code}

\setcounter{testcnt}{18}
The \ordinal{\thetestcnt} test.
The \ordinal{21} test.
The \ordinalshort{\thetestcnt} test.
The \ordinalshort{21} test.\\
The \ordinalshort{2147483647} test. % Largest number for which it works
                                    % (on my system)

\section{Test} \label{s1}
\section{Test} \label{s2}
\section{Test} \label{s3}

\begin{enumerate}
\renewcommand{\theenumi}{(\roman{enumi})}
\renewcommand{\labelenumi}{\theenumi}
\item \label{t1} Test
\item \label{t2} Test
\item \label{t3} Test
\item \label{t4} Test
\item \label{t5} Test
\item \label{t6} Test
\end{enumerate}

\begin{figure}
  Test \caption{Test} \label{f1}
\end{figure}

The \ordinalref{s2} section,
the \ordinalref{t4} case,
the \ordinalref{f1} figure.
The \ordinalshortref{s2} section,
the \ordinalshortref{t4} case,
the \ordinalshortref{f1} figure.

\selectlanguage{dutch}

De \ordinalref{s2} sectie,
het \ordinalref{t4} puntje,
de \ordinalref{f1} figuur.
De \ordinalshortref{s2} sectie,
het \ordinalshortref{t4} puntje,
de \ordinalshortref{f1} figuur.

\selectlanguage{french}

La \ordinal{1}[f] section.
Le \ordinal{1}[m] cas.
La \ordinalref{s2} section,
le \ordinalref{t1}[m] cas,
le \ordinalref{t4} cas,
la \ordinalref{f1} figure,
la \ordinal{1}[f].
La \ordinalshortref{s2} section,
le \ordinalshortref{t1}[m] cas,
le \ordinalshortref{t4} cas,
la \ordinalshortref{f1} figure,
la \ordinalshort{1}[f].

\selectlanguage{spanish}

El \ordinal{1}[m] plato.
La \ordinal{1}[f] divisi\'on.
La \ordinalref{s2} secci\'on,
el \ordinalref{t1}[bm] caso,
el \ordinalref{t4}[m] caso,
la \ordinalref{f1} figura,
la \ordinal{1}[f].
La \ordinalshortref{s2} secci\'on,
el \ordinalshortref{t1}[bm] caso,
el \ordinalshortref{t4}[m] caso,
la \ordinalshortref{f1} figura,
la \ordinalshort{1}[f].
El \ordinalref{t1}[bm] caso,
el \ordinal{2}[bm] caso,
el \ordinal{3}[bm] caso,
el \ordinalref{t4}[bm] caso,
los cuatro \ordinal{1}[m]s d\'{\i}as.

\selectlanguage{italian}

Il \ordinal{1}[m] piato.
La \ordinal{1}[f] parte.
La \ordinalref{s2} parte,
il \ordinalref{t1}[m] caso,
il \ordinalref{t4} caso,
la \ordinalref{f1} figura,
la \ordinal{1}[f].
La \ordinalshortref{s2} parte,
il \ordinalshortref{t1}[m] caso,
il \ordinalshortref{t4} caso,
la \ordinalshortref{f1} figura,
la \ordinalshort{1}[f].
Le tre \ordinalref{t4}[fp] opzioni,
i cuatro \ordinal{1}[mp] giorni.

\end{document}

