%%
%% This is file `nevelok.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% nevelok.dtx  (with options: `package')
%% ----------------------------------------------------------------
%% nevelok --- LaTeX package for automatic definite articles for Hungarian
%% Author:  Zalan Bodo
%% E-mail:  zbodo@cs.ubbcluj.ro
%% License: Released under the LaTeX Project Public License v1.3c or later
%% See:     http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{nevelok}
    [2015/12/05 v1.03 LaTeX package for automatic definite articles for Hungarian]
\RequirePackage{xstring}
%%
\def\ifUnDefinedCs#1{\expandafter\ifx\csname#1\endcsname\relax}%
%%
%%
\DeclareRobustCommand{\aaz}[1]{%
  \ifUnDefinedCs{r@#1}%
    \PackageWarning{nevelok}{Reference not (yet) defined!}%
    a(z) ??%
  \else%
    \z@aaz{\ref{#1}}{a}{az}{}{}%
  \fi%
}%
%%
%%
\DeclareRobustCommand{\Aaz}[1]{%
  \ifUnDefinedCs{r@#1}%
    \PackageWarning{nevelok}{Reference not (yet) defined!}%
    a(z) ??%
  \else%
    \z@aaz{\ref{#1}}{A}{Az}{}{}%
  \fi%
}%
%%
%%
\DeclareRobustCommand{\aazx}[3]{%
  \ifUnDefinedCs{r@#1}%
    \PackageWarning{nevelok}{Reference not (yet) defined!}%
    a(z) ??%
  \else%
    \z@aaz{\ref{#1}}{a}{az}{#2}{#3}%
  \fi%
}%
%%
%%
\DeclareRobustCommand{\Aazx}[3]{%
  \ifUnDefinedCs{r@#1}%
    \PackageWarning{nevelok}{Reference not (yet) defined!}%
    a(z) ??%
  \else%
    \z@aaz{\ref{#1}}{A}{Az}{#2}{#3}%
  \fi%
}%
%%
%%
\DeclareRobustCommand{\aazt}[1]{%
  \z@aaz{#1}{a}{az}{}{}%
}%
%%
%%
\DeclareRobustCommand{\Aazt}[1]{%
  \z@aaz{#1}{A}{Az}{}{}%
}%
%%
%%
\newcount\nev@ind%
\newcount\nev@vege%
\newcount\nev@eppme%
\newcount\nev@az%
%%
\newcommand{\z@aaz}[5]{%
  \begingroup%
  \IfBeginWith{#1}{1}{% if the reference starts with 1,
                      % special care is required
    \StrLen{#1}[\nev@hossz]%
    \nev@ind=\nev@hossz%
    \nev@vege=0%
    \loop% loops while it does not find a digit at the end
         % (in \ref-s, strangely, an \hbox {} appears at the end;
         % this loop was actually written to remove these)
      \StrChar{#1}{\nev@ind}[\nev@kar]%
      \IfSubStr{1234567890}{\nev@kar}{\nev@vege=1}{}\relax%
      \ifnum\nev@vege=0%
        \advance\nev@ind by -1%
    \repeat%
    \StrLeft{#1}{\nev@ind}[\nev@paramuj]% \paramuj will contain the
                                        % ``cleaned'' parameter
    \StrPosition[1]{\nev@paramuj}{.}[\nev@elsopontpozicioja]%
    \StrLen{\nev@paramuj}[\nev@hossz]%
    \nev@eppme=\nev@elsopontpozicioja%
    \advance\nev@eppme by -1%
    \ifnum\nev@elsopontpozicioja=0%
      \StrLeft{\nev@paramuj}{\nev@hossz}[\nev@prefix]%
    \else%
      \StrLeft{\nev@paramuj}{\nev@eppme}[\nev@prefix]%
    \fi%
    \StrLen{\nev@prefix}[\nev@elsohossz]%
    \ifnum\nev@elsohossz=1\relax% 1
      #3%
    \else\ifnum\nev@elsohossz=2\relax% 10
      #2%
    \else\ifnum\nev@elsohossz=3\relax% 100
      #2%
    \else\ifnum\nev@elsohossz=4\relax% 1000
      #3%
    \fi\fi\fi\fi%
  }{%
    \StrChar{#1}{1}[\nev@kar]%
    \nev@az=0%
    \IfSubStr{2346789}{\nev@kar}{% digits that require ``a'';
                                 % this is redundant, but was kept for some reasons
      \nev@az=0\relax%
    }{%
      \IfSubStr{5AEIOUFLMNRSaeiouflmnrs}{\nev@kar}{% digits and letters
                                                   % that require ``az''
        \nev@az=1\relax%
      }{%
        \nev@az=0\relax%
      }%
    }%
    \ifnum\nev@az=1\relax%
      #3%
    \else%
      #2%
    \fi%
  }%
  \ #4#1#5%
  \endgroup%
}%
%%
%% 
%% Copyright (C) 2015 by Zalan Bodo <zbodo@cs.ubbcluj.ro>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in the file:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%% Zalan Bodo.
%% 
%% This work consists of the file nevelok.dtx and a Makefile.
%% Running make generates the derived files README.txt, nevelok.pdf and nevelok.sty.
%% Running make inst installs the files in the user's TeX tree.
%% Running make install installs the files in the local TeX tree.
%% 
%%
%% End of file `nevelok.sty'.
