%%
%% This is file `ordinalpt.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ordinalpt.dtx 
%% 
%% Copyright (C) 2007 Miguel V. S. Frasson (mvsfrasson@gmail.com)
%% 
%% This file is part of the `ordinalpt' package.
%% 
%% This package may be distributed under the terms of the LaTeX
%% Project Public License, as described in lppl.txt in the base
%% LaTeX distribution, either version 1.2 or (at your option)
%% any later version.
%% 
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%% 
%% \CheckSum{242}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ordinalpt}[2007/02/08 v2.1 Ordinal numbers in Portuguese]
\newif\if@ordpt@twelveshort
\newif\if@ordpt@thirteenshort
\@ordpt@twelveshorttrue
\@ordpt@thirteenshortfalse
\DeclareOption{11-12-curtos}{%
  \@ordpt@twelveshorttrue
  \@ordpt@thirteenshortfalse}
\DeclareOption{11-13-curtos}{%
  \@ordpt@twelveshorttrue
  \@ordpt@thirteenshorttrue}
\DeclareOption{11-13-longos}{%
  \@ordpt@twelveshortfalse
  \@ordpt@thirteenshortfalse}
\ExecuteOptions{11-12-curtos}
\DeclareOption{tricentesimo}{\def\@ordpt@tricent{i}}
\DeclareOption{trecentesimo}{\def\@ordpt@tricent{e}}
\ExecuteOptions{tricentesimo}
\DeclareOption{sexcentesimo}{\def\@ordpt@sexcent{x}}
\DeclareOption{seiscentesimo}{\def\@ordpt@sexcent{is}}
\ExecuteOptions{sexcentesimo}
\DeclareOption{noningentesimo}{\def\@ordpt@noningent{in}}
\DeclareOption{nongentesimo}{\def\@ordpt@noningent{}}
\ExecuteOptions{noningentesimo}
\ProcessOptions
\newcommand{\@ordpt@lowercase}[2]{#1#2}
\newcommand{\@ordpt@capitalize}[2]{\uppercase{#1}#2}
\newcommand{\@ordpt@uppercase}[2]{\uppercase{#1#2}}
\newcommand{\@ordpt@printunits}[3]{%
  \ifcase#3 \or
    #1{p}{rimeir#2}\or
    #1{s}{egund#2}\or
    #1{t}{erceir#2}\or
    #1{q}{uart#2}\or
    #1{q}{uint#2}\or
    #1{s}{ext#2}\or
    #1{s}{\'etim#2}\or
    #1{o}{itav#2}\or
    #1{n}{on#2}%
  \fi}
\newcommand{\@ordpt@printtens}[4]{%
  \ifx#31%
    \ifx#41%
      \if@ordpt@twelveshort
        #1{u}{nd\'ecim#2}%
      \else
        #1{d}{\'ecim#2}\space#1{p}{rimeir#2}%
      \fi
    \else
      \ifx#42%
        \if@ordpt@twelveshort
          #1{d}{uod\'ecim#2}%
        \else
          #1{d}{\'ecim#2}\space#1{s}{egund#2}%%
        \fi
      \else
        \ifx#43%
          \if@ordpt@thirteenshort
            #1{t}{red\'ecim#2}%
          \else
            #1{d}{\'ecim#2}\space#1{t}{erceir#2}%%
          \fi
        \else
          #1{d}{\'ecim#2}%
          \ifx#40%
          \else
            \space\@ordpt@printunits#1#2#4%
          \fi
        \fi
      \fi
    \fi
  \else
    \ifcase#3 \or\or
      #1{v}{ig\'esim#2}\or
      #1{t}{rig\'esim#2}\or
      #1{q}{uadrag\'esim#2}\or
      #1{q}{uinquag\'esim#2}\or
      #1{s}{exag\'esim#2}\or
      #1{s}{eptuag\'esim#2}\or
      #1{o}{ctog\'esim#2}\or
      #1{n}{onag\'esim#2}%
    \fi
    \ifx#40%
    \else
      \space\@ordpt@printunits#1#2#4%
    \fi
  \fi}
\newcommand{\@ordpt@printhundreds}[5]{%
  \ifcase#3 \or
    #1{c}{ent\'esim#2}\or
    #1{d}{ucent\'esim#2}\or
    #1{t}{r\@ordpt@tricent cent\'esim#2}\or
    #1{q}{uadringent\'esim#2}\or
    #1{q}{uingent\'esim#2}\or
    #1{s}{e\@ordpt@sexcent cent\'esim#2}\or
    #1{s}{eptingent\'esim#2}\or
    #1{o}{ctingent\'esim#2}\or
    #1{n}{on\@ordpt@noningent gent\'esim#2}%
  \fi
  \ifx#40%
    \ifx#50%
    \else
      \space\@ordpt@printunits#1#2#5%
    \fi
  \else
    \space\@ordpt@printtens#1#2#4#5%
  \fi}
\newcommand{\@ordpt@printthousands}[6]{%
  \ifcase#3 \or
    #1{m}{il\'esim#2}%
  \fi
  \ifx#40%
    \ifx#50%
      \ifx#60%
      \else
        \space\@ordpt@printunits#1#2#6%
      \fi
    \else
      \space\@ordpt@printtens#1#2#5#6%
    \fi
  \else
    \space\@ordpt@printhundreds#1#2#4#5#6
  \fi}
\newcommand{\@ordpt@print}{}
\def\@ordpt@print#1#2#3#4#5#6#7!{%
  \ifx#4?%
    \@ordpt@printunits#1#2#3%
  \else
    \ifx#5?%
      \@ordpt@printtens#1#2#3#4%
    \else
      \ifx#6?%
        \@ordpt@printhundreds#1#2#3#4#5%
      \else
        \@ordpt@printthousands#1#2#3#4#5#6%
      \fi
    \fi
  \fi}
\newcommand{\@ordpt@ordinal}[3]{%
  \ifnum\csname c@#3\endcsname<1
    \@ctrerr
  \else
    \ifnum\csname c@#3\endcsname>1999
      \@ctrerr
    \else
      \expandafter\@ordpt@print
      \expandafter#1\expandafter#2\the\csname c@#3\endcsname????!%
    \fi
  \fi}
\newcommand{\ordptmasc}[1]{\@ordpt@ordinal\@ordpt@lowercase o{#1}}
\newcommand{\Ordptmasc}[1]{\@ordpt@ordinal\@ordpt@capitalize o{#1}}
\newcommand{\ORDPTMASC}[1]{\@ordpt@ordinal\@ordpt@uppercase o{#1}}
\newcommand{\ordptfem}[1]{\@ordpt@ordinal\@ordpt@lowercase a{#1}}
\newcommand{\Ordptfem}[1]{\@ordpt@ordinal\@ordpt@capitalize a{#1}}
\newcommand{\ORDPTFEM}[1]{\@ordpt@ordinal\@ordpt@uppercase a{#1}}
\endinput
%%
%% End of file `ordinalpt.sty'.
