%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|
%This is MYLATV.STY, version 2.01 of Oct 1, 1996               |
%Modelled by J. Cirulis after 'esperant.sty' and 'german.sty', |
%                        with several ideas of Holger Nobach   |
%For  LaTeX 2.09, without NFSS and BABEL                       |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|

% \ifundefined{mylatvOn} or \mylatvOn=\relax
\expandafter\ifx\csname mylatvOn\endcsname\relax
% \then go ahead \else do nothing
\else \endinput \fi

% % % % % % % % % % % % % % % % % % % % % % % % %
\message{Document Style Option `mylatv' Version 2.01 of Oct 1, 1996}
% % % % % % % % % % % % % % % % % % % % % % % % %

%ifundefined{protect}   (plain TeX)
\ifx\protect\undefined
% \then define it
\let\protect=\relax \fi

%%%%%%%%%%%%%%%%%%%%%

\begingroup             % To keep catcode change local   -------|
 \catcode`\@=11         % \makeatletter                         |

\gdef\allowhyphens{\penalty\@M \hskip\z@skip}
                        % {\nobreak   \hskip 0pt plus 0pt\relax}

%%%%%%%%%%%%%%%%%%%%% Quotation marks
%		      (by H. Nobach)
%%%%%%%%%%%%%%%%%%%%%%
\gdef\set@low@box#1{\setbox\tw@\hbox{,}\setbox\z@\hbox{#1}%
  \setbox\z@\hbox{\dimen@\ht\z@ \advance\dimen@ -\ht\tw@
      \lower\dimen@\box\z@}%
  \ht\z@\ht\tw@ \dp\z@\dp\tw@}
\gdef\save@sf@q#1{{\ifhmode
  \edef\@SF{\spacefactor\the\spacefactor}\else
  \let\@SF\empty \fi \leavevmode #1\@SF}}

\gdef\@glqq{\save@sf@q{\set@low@box{''\/}\box\z@
             \kern-.04em\allowhyphens}}
\gdef\glqq{\protect\@glqq}                      %german left qquotes ,,
\gdef\@grqq{\save@sf@q{\kern-.07em``\kern.07em}}
\gdef\grqq{\protect\@grqq}                      %german right qquotes ``
\gdef\@glq{\save@sf@q{\set@low@box{'\/}\box\z@
            \kern-.04em\allowhyphens}}
\gdef\glq{\protect\@glq}                        %german left quote ,
\gdef\@grq{\save@sf@q{\kern-.0125em`\kern.07em}}
\gdef\grq{\protect\@grq}                        %german right quote `
\gdef\@flqq{\relax\ifmmode \ll \else \save@sf@q{\penalty\@M
    \raise .2ex\hbox{$\scriptscriptstyle \ll $}\allowhyphens}\fi}
\gdef\flqq{\protect\@flqq}                      %french left qquotes <<
\gdef\@frqq{\relax\ifmmode \gg \else \save@sf@q{\penalty\@M
    \raise .2ex\hbox{$\scriptscriptstyle \gg $}\allowhyphens}\fi}
\gdef\frqq{\protect\@frqq}                      %french right qquotes >>
\gdef\@flq{\relax\ifmmode <\else \save@sf@q{\penalty\@M
    \raise .2ex\hbox{$\scriptscriptstyle <$}\allowhyphens}\fi}
\gdef\flq{\protect\@flq}                        %french left quote <
\gdef\@frq{\relax\ifmmode >\else \save@sf@q{\penalty\@M
    \raise .2ex\hbox{$\scriptscriptstyle >$}\allowhyphens}\fi}
\gdef\frq{\protect\@frq}                        %french right quote >
\gdef\@llqq{\save@sf@q{\set@low@box{''\/}\box\z@
             \kern-.04em\allowhyphens}}
\gdef\llqq{\protect\@llqq}                      %latvian left qquotes ,,
%\typeout{kuku}
\gdef\@lrqq{\save@sf@q{\kern-.07em''\kern.07em}}
\gdef\lrqq{\protect\@lrqq}                      %latvian right qquotes ``
\gdef\@llq{\save@sf@q{\set@low@box{'\/}\box\z@
            \kern-.04em\allowhyphens}}
\gdef\llq{\protect\@llq}                        %latvian left quote ,
\gdef\@lrq{\save@sf@q{\kern-.0125em'\kern.07em}}
\gdef\lrq{\protect\@lrq}                        %latvian right quote `
%%%%%%%%%%%%%%%%%%%%% End of Quotation marks

%%%%%%%%%%%%%%%%%%%%% Accents redefined
%       Definitions of \@h und \@k  for µ (\=A) and ô (\c{K}) resp.
%       (by H. Nobach)
%%%%%%%%%%%%%%%%%%%%%%
\global\let\@lh=\=%               %% Æ (\=a) ñ (\=e) ù (\=o) Ý (\=u)
                                 %% µ (\=A) ð (\=E) ½ (\=O) Þ (\=U)
\gdef\@lkoalign#1{\leavevmode \vtop{\baselineskip \z@skip
  \lineskip .05ex\ialign {##\crcr #1\crcr }}}
\gdef\@lioalign#1{\leavevmode \vtop{\baselineskip \z@skip
  \lineskip-1.8ex\ialign {##\crcr #1\crcr }}}           %-1.9
\gdef\@lIoalign#1{\leavevmode \vtop{\baselineskip \z@skip
  \lineskip-2.4ex\ialign {##\crcr #1\crcr }}}
\gdef\@lgoalign#1{\leavevmode \vtop{\baselineskip \z@skip
  \lineskip-2.3ex\ialign {##\crcr #1\crcr }}}
\gdef\@lkg#1{\@lgoalign {#1\crcr \hidewidth \char96\hidewidth }}  % Ö (\`g)
\gdef\@lkk#1{\@lkoalign {#1\crcr \hidewidth ,\hidewidth }}%          
      %% ó (\c{k}) õ (\c{l}) · (\c{n})%                
	%% ò (\c{G}) ô (\c{K}) ö (\c{L}) ü (\c{N})
\gdef\@k#1{\ifx#1g\@lkg#1\else \@lkk#1\fi}
\gdef\@lhI{\@lh I}                            %% × (\=I)
\gdef\@lhi{\@lioalign {\i\crcr \hidewidth \char45\hidewidth }}  %Ø (\={\i})
\gdef\@h#1{\ifx#1i\@lhi \else \ifx#1I\@lhI \else \@lh #1\fi \fi}
%%%%%%%%%%%%%%%%%%%%% End of Accents redefined

%%%%%%%%%%%%%%%%%%%%%
\begingroup             % add the quotes to the definitions of dospecials and
 \def\do{\noexpand\do\noexpand}%                        % sanitize
                        % 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
%%%%%%%%%%%%%%%%%%%%%

\gdef\modifiedquoteson{\catcode`\"\active}
\gdef\modifiedquotesoff{\catcode`\"12 }

{\modifiedquotesoff
%\gdef\@UMLAUT{\"}
%\gdef\@MATHUMLAUT{\mathaccent"707F}
\gdef\dq{"}
}

%%%%%%%%%%%%%%%%%%%%% Accented letters
{\modifiedquoteson
\gdef"{\protect\active@dq}
\gdef\active@dq{\futurelet\next@after@dq\first@active@dq}
%                              %First letters with an accent
\gdef\first@active@dq#1{%                
		\ifx \next@after@dq\bgroup\dq {#1}%
        \else \expandafter\ifx \space\next@after@dq\dq\space #1 \else
                %  The two lines above are needed before everything else, to
                % take care of {empty or non-empty} groups and spaces after the
                % active quote
                %  Now the real thing
       \ifmmode \ #1   \else
       \ifx #1a\@h a\allowhyphens%
 \else \ifx #1e\@h e\allowhyphens%
 \else \ifx #1i\@h #1\allowhyphens%
 \else \ifx #1o\@h o\allowhyphens%
 \else \ifx #1u\@h u\allowhyphens%
%
 \else \ifx #1A\@h A\allowhyphens
 \else \ifx #1E\@h E\allowhyphens
 \else \ifx #1I\@h I\allowhyphens
 \else \ifx #1O\@h O\allowhyphens
 \else \ifx #1U\@h U\allowhyphens
%
 \else \ifx #1c\v c\allowhyphens
 \else \ifx #1s\v s\allowhyphens
 \else \ifx #1z\v z\allowhyphens
%
 \else \ifx #1C\v C\allowhyphens
 \else \ifx #1S\v S\allowhyphens
 \else \ifx #1Z\v Z\allowhyphens
%
 \else \ifx #1g\@k g\allowhyphens
 \else \ifx #1k\@k k\allowhyphens
 \else \ifx #1l\@k l\allowhyphens
 \else \ifx #1n\@k n\allowhyphens
 \else \ifx #1r\@k r\allowhyphens
%
 \else \ifx #1G\@k G\allowhyphens
 \else \ifx #1K\@k K\allowhyphens
 \else \ifx #1L\@k L\allowhyphens
 \else \ifx #1N\@k N\allowhyphens
 \else \ifx #1R\@k R\allowhyphens
%
 \else \ifx #1-\discretionary{-}{}{}\allowhyphens
 \else \ifx #1|\discretionary{-}{}{\kern.03em}\allowhyphens
 \else \ifx #1-\active@dq\hskip\z@skip
 \else  \dq #1%
%
\fi\fi\fi\fi
\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi \fi\fi\fi \fi\fi\fi
\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi
\fi\fi
}
}
%%%%%%%%%%%%%%%%%%%%% End of Accented letters

%%%%%%%%%%%%%%%%%%%%% Dates
{\modifiedquoteson
\gdef\datelatvian{\def\today{\number\year.~g.\space\number\day.~\ifcase\month%
\or janv"ar"i\or febru"ar"\or mart"a\or apr"il"i\or
maij"a\or j"unij"a\or j"ulij"a\or august"a\or septembr"i\or
oktobr"i\or novembr"i\or  decembr"i\fi}%
\global\let\datumaa=\today}

\gdef\datums{\number\year.~g.\space\number\day.~%
\ifcase\month\or janv"aris\or febru"aris\or marts\or apr"ilis\or maijs\or 
j"unijs\or j"ulijs\or augusts\or septembris\or oktobris\or novembris\or 
decembris\fi}
}

\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 6\th\or 7th\or 8th\or 9th\or 10th\or
 11th\or 12th\or 13th\or 14th\or 15th\or 16\th\or 17th\or 18th\or 19th\or 20th\or
 21st\or 22nd\or 23rd\or 24th\or 25th\or 26\th\or 27th\or 28th\or 29th\or 30th\or
 31\st\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\day, \number\year}}

%%%%%%%%%%%%%%%%%%%%% End of Dates

%%%%%%%%%%%%%%%%%%%%% Captions
\modifiedquoteson
\gdef\captionslatvian{%
\def\prefacename{PriekývÆrds}%
\def\refname{LiteratÝra}%         %arØ: LiteratÝras rÆdØtÆjs
\def\abstractname{AnotÆcija}%
\def\bibname{BibliogrÆfija}%
\def\chaptername{nodaõa}%
\def\appendixname{Pielikums}%
\def\contentsname{Saturs}%        %arØ: Satura rÆdØtÆjs
\def\listfigurename{Attñlu saraksts}%   %arØ: Attñlu rÆdØtÆjs
\def\listtablename{Tabulu saraksts}%    %arØ: Tabulu rÆdØtÆjs
\def\indexname{Priekýmetu rÆdØtÆjs}%
\def\figurename{zØm.}%
\def\tablename{tabula}%
\def\partname{daõa}%
\def\enclname{PielikumÆ}%
\def\ccname{Kopija(s)}%
\def\headtoname{}%
\def\pagename{lpp.}%
\def\seename{skat.}%
\def\alsoname{skat. arØ}%
     %%%% Latvian syntax:
        % section numbering
\def\thechapter      {\arabic{chapter}.}
\def\thesection      {\ifx\chapter\undefined{\arabic{section}.}\else
                        {\thechapter\arabic{section}.}\fi}
\def\thesubsection   {\thesection\arabic{subsection}.}
\def\thesubsubsection{\thesubsection\arabic{subsubsection}.}
\def\theparagraph    {\thesubsubsection\arabic{paragraph}.}
\def\thesubparagraph {\theparagraph\arabic{subparagraph}.}
        % end of section numbering
        % chapterhead
\def\@makechapterhead##1{\vspace*{50pt}
    {\parindent 0pt \raggedright
      \ifnum \c@secnumdepth >\m@ne
      \huge\bf \thechapter\  \@chapapp{}
     \par
     \vskip 20pt \fi 
     \Huge \bf ##1\par \nobreak \vskip 40pt } }
        % end of chapterhead
         % theoremlike environments
\def\@thmcountersep{}
\gdef\@makethmnumber##1##2{\bf\if\thmnoleft0{##1\ ##2}\else {##2. ##1}\fi}
\def\@begintheorem##1##2{\it\trivlist
        \item[\hskip\labelsep \hskip\parindent 
				{\@makethmnumber{##1}{##2}}.]}
\def\@opargbegintheorem##1##2##3{\it\trivlist
         \item[\hskip\labelsep \hskip\parindent {\@makethmnumber{##1}{##2} 
				(##3).}]}\def\thmnoleft{0}
        % end oftheoremlike environments
        % minicaptions
\def\fnum@figure{\thefigure.~\figurename}
\def\fnum@table{\thetable.~\tablename} % kÆ bÝs punkts rÆdØtÆjÆ?
        % end of minicaptions
}
\modifiedquotesoff

\gdef\captionsgerman{%
\def\prefacename{Vorwort}%
\def\refname{Literatur}%
\def\abstractname{Zusammenfassung}%
\def\bibname{Literaturverzeichnis}%
\def\chaptername{Kapitel}%
\def\appendixname{Anhang}%
\def\contentsname{Inhaltsverzeichnis}% % oder nur: Inhalt
\def\listfigurename{Abbildungsverzeichnis}%
\def\listtablename{Tabellenverzeichnis}%
\def\indexname{Index}%
\def\figurename{Abbildung}%
\def\tablename{Tabelle}%  % oder: Tafel
\def\partname{Teil}%
\def\enclname{Anlage(n)}% % oder: Beilage(n)
\def\ccname{Verteiler}%   % oder: Kopien an
\def\headtoname{An}%
\def\pagename{Seite}%
\def\seename{siehe}%
\def\alsoname{siehe auch}}

\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}

\gdef\captionsfrench{%
\def\prefacename{Pr\'eface}%
\def\refname{R\'ef\'erences}%
\def\abstractname{R\'esum\'e}%
\def\bibname{Bibliographie}%
\def\chaptername{Chapitre}%
\def\appendixname{Annexe}%
\def\contentsname{Table des mati\`eres}%
\def\listfigurename{Liste des figures}%
\def\listtablename{Liste des tableaux}%
\def\indexname{Index}%
\def\figurename{Figure}%
\def\tablename{Tableau}%
\def\partname{Partie}%
\def\enclname{P.~J.}%
\def\ccname{Copie \`a}%
\def\headtoname{A}%
\def\pagename{Page}%
\def\seename{voir}%
\def\alsoname{voir aussi}}%
%%%%%%%%%%%%%%%%%%%%% End of Captions

%%%%%%%%%%%%%%%%%%%%% Section numbers
%\input{numer}		%incorporated in Captions
%%%%%%%%%%%%%%%%%%%%% End of Section numbers

%%%%%%%%%%%%%%%%%%%%% Alphabet
%\input{alphabet}
%%%%%%%%%%%%%%%%%%%%% End of Alphabet
%
%%%%%%%%%%%%%%%%%%%%% Selecting language
\newcount\l@nguage
        %This will be redeclared as \language for TeX version < 3
        % \ifundefined{language}
\expandafter\ifx\csname language\endcsname\relax
\global\let\language=\l@nguage
\fi
%
\newcount\USenglish     \global\USenglish=0
\newcount\latvian       \global\latvian=1
%\newcount\english       \global\english=2
%\newcount\german        \global\german=3
%
\gdef\selectlanguage#1{%
        \expandafter\ifcase #1\relax
        \dateUSenglish \captionsenglish
        \or \datelatvian   \captionslatvian       %Latvian syntax
%        \or \dateenglish   \captionsenglish
%        \or \dategerman    \captionsgerman
        \fi
%       \language=#1\relax      %Latvian hyphenation does not exist
        }
%%%%%%%%%%%%%%%%%%%%% End of Selecting language

\gdef\mylatvOff{\modifiedquotesoff}
\gdef\mylatvOn{\modifiedquoteson \selectlanguage{\latvian}}
\endgroup		%		-----------------|
\mylatvOn
