%  This is ESPERANT.TEX or ESPERANT.DOC or ESPERANT.STY, 
%  Vers. 1.1.a  10-DEC-1991,
%
%  (c) 1991 J"org Knappen
%  knappen@vkpmzd.kph.uni-mainz.de
%
%  Usage conditions: GNU-licence, Version 1.0
%  This includes the right to copy this file free and distribute the 
%  copies, as long as no money is taken for it and as long as this file 
%  remains unchanged. 
%
%  by J. Knappen, Uni Mainz, using GERMAN.STY 2.3d, collected by 
%  H. Partl, TU Wien, deutsch.sty by J. Schrod, Darmstadt, 
%  and espo.sty (anonymous). 
%  Contributers to these files are included by reference.
%
%  Thanks to Derk Ederveen and E. T. Grimley-Evans for correcting the terms 
%  in \captionsesperanto
%
%  DOCUMENT STYLE OPTION for writing esperanto texts
%  with TeX version 2.x (Plain TeX) or with LaTeX version 2.09.
%
% It can be called via
%    \input esperant
% or (with LaTeX) via
%    \documentstyle[esperant]{anystyle}
%
% The name ``esperant.sty'' (without o) is choosen purposefully, because 
% there are a lot of computers out there, which cannot handle filenames
% consisting of more than 8 letters.
%
% This file is different from ``esperanto.sty'' by J. L. Braams, to be used 
% with the babel system 
%
% Commands to be used by the end users:
%
% ^c, ^g, ^h, ^j, ^s   create the esperanto circumflexed consonants
% ^C, ^G, ^H, ^J, ^S   ditto, uppercase versions
% ^u, ^U               create the esperanto u-breve (\u{u})
%                      if you need an u-circumflex, write \^u
% ^|                   Morpheme boundary to assist correct hyphenation
%  
% \captionsesperanto   switches the captions to esperanto
% \dateesperanto       switches \today to produce the date in e-o
% \hodiau              produces the current date in esperanto
% \hodiaun             produces the current date in esperanto, accusative
%
% \captionsenglish     switches the captions back to english
% \dateUSenglish       does the same for the date
% \dateenglish         switches to british english date
%
% You can change each caption if you want. E. g. if you prefer
% ``vd. anka^u'' instead of ``vidu anka^u'', say
% \renewcommand{\seealsoname}{vd.~anka\u{u}}
%
% \Esper, \esper       allow you to count by the letters of the esperanto
%                      alphabet (A, B, C, ^C, D, ...). You can redefine
%                      \Alph into \Esper by
%                      \let\Alph=\Esper  % I leave this purposefully to
%                      you as the end user and don't turn it on as default
%
% Notes:
%
% This file can be used both with Plain TeX and with LaTeX and other
% macro packages, and with the original TeX and LaTeX fonts. Usage
% of esperanto hyphenation patterns is recommended to accompany this
% style file when writing esperanto texts.
%
% Derk Ederveen (D.Ederveen@pttrl.nl) has prepared esperanto hyphenation 
% patterns, supporting the ``cx''-notation. Obviously, these ones are not 
% optimal, but a good try. Alternatively, you might try
% italian or portugese hyphenation patterns. (Both are available on several
% servers.) 
%
% The file should be read in vertical mode only (usually at the
% beginning of the document) to avoid spurious spaces.
%
% \undefined must be an undefined control sequence.
%
% Multiple calls of this file (e.g. at the beginning of each subfile)
% will do no harm. Only the first call (i.e., if \EsperantoOn is undefined)
% performs all the definitions and settings. Later calls only switch
% to \EsperantoOn.
%
% The catcode of @ remains unchanged after processing of this file.
% All definitions are global, the switching on of the esperanto options
% is local.
%
% The commands  \EsperantoOn, \EsperantoOff, \modifiedhaton, modifiedhatoff and
% \selectlanguage are ``fragile'' with LaTeX and should not be used
% within arguments of macro calls.
%
% In Plain TeX, `\protect' should be \let to `\relax' normally and to
% something like `\string' inside the arguments of `\write' or `\message'
% (see LaTeX.TEX for all the details).
%
% The current version has been designed for TeX versions 1 and 2.
% When used with TeX version 3 or with MLTeX by M.Ferguson, the
% setting of the \language counter and/or calls of \setlanugage
% have to be inserted into the definition of the \selectlanguage
% command, with values that are appropriate for the hyphenation patterns
% loaded into the FMT file by IniTeX.
%
% Since ^ has a different catcode (\active) and a different meaning
% than in original TeX, special care has to be taken if ^ is to be
% used in its original meaning. 
%
% WARNINGS:
%
% If you want to use `verbatim.sty' by R. Schoepf, this must be read before
% you read in `esperant.sty'. The same is true for every style option which
% makes use of the ^^-Notation.
%
% If you use `endnotes.sty' by J. Lavigno, you should read it before
% esperant.sty. Otherwise, it will overwrite \notesname again.
%       
% \ifundefined{EsperantoOn} or \EsperantoOn=\relax
\expandafter\ifx\csname EsperantoOn\endcsname\relax
% \then go ahead \else do nothing
\else \endinput \fi
 
\message{Document Style Option `esperant'  Version 1.1a of 10-OKT-1991}
 
% \ifundefined{protect}  (plain TeX)
\ifx\protect\undefined
% \then define it
\let\protect=\relax \fi
 
{% begin a group ...
  \catcode`\@=11 % \makeatletter

% Part one: 
% Define the \allowhyphens hack   
\gdef\allowhyphens{\penalty\@M \hskip\z@skip}
%                 {\nobreak    \hskip 0pt plus 0pt\relax}
%
% Part two
% add the ^ to the definitions of dospecials and sanitize:
% Don't ask me on the meaning of this! (JK)
%
\begingroup
\def\do{\noexpand\do\noexpand}%
% note that "\xdef" means "\global\edef"
\xdef\dospecials{\dospecials\do\^}%
% not ( \ifundefined{@sanitize} or \@sanitize=\relax ) = if LaTeX
\expandafter\ifx\csname @sanitize\endcsname\relax \else
  \def\@makeother{\noexpand\@makeother\noexpand}%
  \xdef\@sanitize{\@sanitize\@makeother\^}%
\fi
\endgroup

% Part three:
% define all the funny things the hat does

\gdef\modifiedhaton{\catcode`\^\active}
\gdef\modifiedhatoff{\catcode`\^7 }
 
{\modifiedhaton
\gdef^{\protect\ph@t}
\gdef\ph@t#1{\ifmmode\sp{#1}
        \else\ifx#1u\u u\allowhyphens%             ^u gives breve on u
	\else\ifx#1U\u U\allowhyphens%             and ^U gives one on U (rare)
        \else\ifx#1h{h\llap{\^{}}}\allowhyphens%   ^h mustn't be too tall
        \else\ifx#1j{\^\j}\allowhyphens%           ^j requires undotted j
        \else\ifx#1|\discretionary{-}{}{}\allowhyphens%   morpheme boundary
        \else{\^{#1}}\allowhyphens%                 Normal circumflexing
\fi\fi\fi\fi\fi\fi} 
} % end of \modifiedhaton

% Part four:
% Define the date and the captions of LaTeX

\gdef\dateesperanto{\def\today{la \number\day a de \ifcase\month\or
  januaro\or februaro\or marto\or aprilo\or majo\or junio\or
  julio\or a\u{u}gusto\or septembro\or oktobro\or novembro\or decembro\fi,\space
  \number\year}%
\global\let\hodiau=\today}
\gdef\hodiaun{la \number\day an de \ifcase\month\or
  januaro\or februaro\or marto\or aprilo\or majo\or junio\or
  julio\or a\u{u}gusto\or septembro\or oktobro\or novembro\or decembro\fi,\space
  \number\year}

\gdef\dateUSenglish{\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}}

\gdef\dateenglish{\def\today{\ifcase\day\or
  1st\or 2nd\or 3rd\or 4th\or 5th\or
  6th\or 7th\or 8th\or 9th\or 10th\or
  11th\or 12th\or 13th\or 14th\or 15th\or
  16th\or 17th\or 18th\or 19th\or 20th\or
  21st\or 22nd\or 23rd\or 24th\or 25th\or
  26th\or 27th\or 28th\or 29th\or 30th\or
  31st\fi
  ~\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space \number\year}}

% Skip this block, if you allready have LaTeX 2.09 from 1-DEC-1991 or 
% any newer version. If not, read it carefully.
%
% Here is, how you can modify the LaTeX document style files and option
% files, to benefit from the following \captionsxxxxx commands. Def's like
%     \def\tableofcontents{\section*{Contents\markboth{CONTENTS}{CONTENTS}}
%     \@starttoc{toc}}
% should be redefined by def's like
%     \def\contentsname{Contents} % <---
%     \def\tableofcontents{\section*{\contentsname
%     \markboth{\uppercase{\contentsname}}{\uppercase{\contentsname}}}
%     \@starttoc{toc}}
%
% (it's best to put all these new lines to the end of the original files),
% and of course, you should modify the change date in the file header and
% in the \typeout command.
% You need not do this yourself - rather, retrieve "International LaTeX"
% (e.g. from the DANTE server LISTSERV@DHDURZ1 on Bitnet) !
% Or via ftp from 129.69.1.12 (Stuttgart) or any other of the well-known 
% TeXservers. 
%
% If your LaTeX dates from 1-Dec-1991 or later, you don't need ILateX
% any longer -- and if not, update your LaTeX.
%   
% The list of names is based on the proposal of H. Partl, but is enlarged 
% by the following ones
% \seename, \seealsoname, and prefacename  (J. Schrod, deutsch.sty)
% \subjectname,
% and \notesname.
%
\gdef\captionsesperanto{%
\def\contentsname{Enhavo}%       
\def\listfigurename{Listo de figuroj}%
\def\listtablename{Listo de tabeloj}%
\def\abstractname{Resumo}%
\def\partname{Parto}%
\def\chaptername{\^Capitro}%
\def\prefacename{Anta\u{u}parolo}%
\def\appendixname{Apendico}%
\def\refname{Cita\^joj}% 
\def\bibname{Bibliografio}% 
\def\indexname{Indekso}%         
\def\figurename{Figuro}%
\def\tablename{Tabelo}%
\def\pagename{Pa\^go}%
\def\seename{vidu}%    a^u: vd.
\def\alsoname{vidu anka\u{u}}% a^u: vd. anka\u{u}
\def\notesname{Rimarkoj}%  endnotes.sty
\def\enclname{Aldono(j)}% 
\def\ccname{Kopie al}%  
\def\headtoname{Al}% 
\def\subjectname{Temo}%
}

\gdef\captionsenglish{%
\def\prefacename{Preface}%
\def\refname{References}%
\def\abstractname{Abstract}%
\def\bibname{Bibliography}%
\def\chaptername{Chapter}%
\def\appendixname{Appendix}%
\def\contentsname{Contents}%
\def\listfigurename{List of Figures}%
\def\listtablename{List of Tables}%
\def\indexname{Index}%
\def\figurename{Figure}%
\def\tablename{Table}%
\def\partname{Part}%
\def\enclname{encl}%
\def\ccname{cc}%
\def\headtoname{To}%
\def\pagename{Page}%
\def\seename{see}%
\def\alsoname{see also}%
\def\notesname{Notes}%
\def\subjectname{Subject}%  
}

% Part four a:
% Define \Esper and \esper
\gdef\esper#1{\@esper{\@nameuse{c@#1}}}   
\gdef\Esper#1{\@Esper{\@nameuse{c@#1}}}   
\gdef\@esper#1{\ifcase#1\or a\or b\or c\or \^c\or d\else\@iesper{#1}\fi}
\gdef\@iesper#1{\ifcase#1\or \or \or \or \or \or 
   \or e\or f\or g\or \^g\or h\or h\llap\^{}\or i\or j\or \^\j\or k%
   \or l\or m\or n\or o\or p\or r\or s\or \^s\or t\or u\or \u{u}\or v%
   \or z\else\@ctrerr\fi}
\gdef\@Esper#1{\ifcase#1\or A\or B\or C\or \^C\or D\else\@Iesper{#1}\fi}
\gdef\@Iesper#1{\ifcase#1\or \or \or \or \or \or E\or F\or G\or \^G\or H%
  \or \^H\or I\or J\or \^J\or K\or L\or M\or N\or O\or P\or R\or S\or \^S\or T%
  \or U\or \u{U}\or V\or Z\else\@ctrerr\fi}


% Part five:
% Define the new counter language to switch date and captions
\newcount\l@nguage
%
% This will be re-declared as \language if the latter has not yet been
% declared neither by Ferguson's ``Multilingual T^eX'' nor by TeX 3:
% \ifundefined{language}
\expandafter\ifx\csname language\endcsname\relax
\global\let\language=\l@nguage
\fi
% 
\newcount\USenglish  \global\USenglish=0
\newcount\esperanto  \global\esperanto=1
\newcount\english    \global\english=2
%
\gdef\selectlanguage#1{%
  \expandafter\ifcase #1\relax
  \dateUSenglish  \captionsenglish   \or
  \dateesperanto  \captionsesperanto \or
  \dateenglish    \captionsenglish   \fi}
% Note: If used with TeX version 3 or with multi-lingual TeX by M.Ferguson,
% commands like
%     \language=#1\relax
% and/or
%     \setlanguage{...}
% should be inserted into the above definition in order to switch on the
% correct hyphenation patterns.
% 
% \ifundefined{setlanguage} (= TeX version < 3 )
\expandafter\ifx\csname setlanguage\endcsname\relax
\global\let\setlanguage=\selectlanguage
\fi
%

% Part six:
% Define the switches between esperanto and original TeX
     
\gdef\EsperantoOff{\modifiedhatoff}
\gdef\EsperantoOn{\modifiedhaton}
 
} % ... return to previous catcodes
% 
% Now, switch on what is appropriate for esperanto:
% 
\EsperantoOn
\selectlanguage{\esperanto}
                
% This is the end of ESPERANTO.STY/DOC/TEX.
\endinput