% \iffalse meta-comment
%
% Copyright 1989-2004 Johannes L. Braams and any individual authors
% listed elsewhere in this file.  All rights reserved.
% 
% This file is part of the Babel system.
% --------------------------------------
% 
% It 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 has the LPPL maintenance status "maintained".
% 
% The Current Maintainer of this work is Johannes Braams.
% 
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.bbl. See also `legal.bbl' for additional
% information.
% 
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
% \fi
% \CheckSum{546}
%
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{icelandic.dtx}
%</dtx>
%<code>\ProvidesLanguage{icelandic}
%\fi
%\ProvidesFile{icelandic.dtx}
        [2004/02/20 v1.1g Icelandic support from the babel system]
%\iffalse
%% File iceland.dtx
%% Babel package for LaTeX version 2e
%% Copyright (C) 1989--2004
%%           by Johannes Braams, TeXniek
%
%% Icelandic Language Definition File
%% Copyright (C)  1996--2004
%%           by Einar \'Arnason <einar@lif.hi.is>
%%              Johannes Braams, TeXniek
%
%% Please report errors to: Einar \'Arnason
%%                          einar at lif.hi.is
%% or to:                   J.L. Braams
%%                          babel at braams.cistron.nl
%%
%
%<*filedriver>
\documentclass{ltxdoc}
\usepackage{t1enc}
\usepackage[icelandic,english]{babel}
\font\manual=logo10 % font used for the METAFONT logo, etc.
\newcommand*\MF{{\manual META}\-{\manual FONT}}
\newcommand*\TeXhax{\TeX hax}
\newcommand*\babel{\textsf{babel}}
\newcommand*\langvar{$\langle \it lang \rangle$}
\newcommand*\note[1]{}
\newcommand*\Lopt[1]{\textsf{#1}}
\newcommand*\file[1]{\texttt{#1}}
\begin{document}
\begin{center}
  \textbf{\Large A Babel language definition file for 
          Icelandic}\\[3mm]^^A\]
  Einar \'Arnason\\
  \texttt{einar@lif.hi.is}
\end{center}
 \DocInput{icelandic.dtx}
\end{document}
%</filedriver>
%\fi
% \GetFileInfo{iceland.dtx}
%
%
% \changes{icelandic-1.1c}{1997/05/21}{Removed code already present in
%    \file{babel.def}} 
%
%  \section{The Icelandic language}
%
%  \subsection{Overview}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate. }  defines all the language definition macros for 
%    the Icelandic language
%
%    Customization for the Icelandic language was made following
%    several official and semiofficial publications~\cite{74:_augl,
%    77:_augl,88:_reglur,94:_si,97:_forst_fs}. These publications  do
%    not always agree and we indicate those instances.
%
%    For this language the character |"| is made active. In
%    table~\ref{tab:icelandic-extras} an overview is given of its
%    purpose. 
%    \begin{table}[htb]
%     \begin{center}
%     \begin{otherlanguage*}{icelandic}
%     \begin{tabular}{lp{8cm}}
%      \verb="|= & disable ligature at this position.              \\
%      |"-| & an explicit hyphen sign, allowing hyphenation
%             in the rest of the word.                             \\
%      |""| & like |"-|, but producing no hyphen sign
%             (for compund words with hyphen, e.g.\ |x-""y|).      \\
%      |"~| & for a compound word mark without a breakpoint.       \\
%      |"=| & for a compound word mark with a breakpoint, allowing
%             hyphenation in the composing words.                  \\
%      |"`| & for Icelandic left double quotes (looks like ,,).    \\
%      |"'| & for Icelandic right double quotes.                   \\
%      |">| & for Icelandic `french' left double quotes 
%             (similar to $>>$).\\
%      |"<| & for Icelandic `french' right double quotes
%             (similar to $<<$).\\
%      |"o| & for old Icelandic "o \\
%      |"O| & for old Icelandic "O \\
%      |"ó| & for old Icelandic "ó \\
%      |"Ó| & for old Icelandic "Ó \\
%      |"e| & for old Icelandic "e \\
%      |"E| & for old Icelandic "E \\
%      |"é| & for old Icelandic "é \\
%      |"É| & for old Icelandic "É \\
%      |\tala| & for typesetting numbers\\
%      |\grada| & for the `degree' symbol\\
%      |\gradur| & for `degrees', e.g. 5~\gradur C\\
%      |\upp| & for textsuperscript \\
%     \end{tabular}
%     \end{otherlanguage*}
%     \caption{The shorthands and extra definitions made
%              by \file{icelandic.ldf}}\label{tab:icelandic-extras}
%     \end{center}
%    \end{table}
%    The shorthands in table~\ref{tab:icelandic-extras} can also be 
%    typeset by using the commands in 
%    table~\ref{tab:icelandic-commands}.
%    \begin{table}[htb]
%     \begin{center}
%     \begin{otherlanguage*}{icelandic}
%     \begin{tabular}{lp{8cm}}
%      |\ilqq|  & for Icelandic left double quotes 
%                 (looks like ,,).   \\
%      |\irqq|  & for Icelandic right double quotes 
%                 (looks like ``).  \\
%      |\ilq|   & for Icelandic left single quotes
%                 (looks like ,).    \\
%      |\irq|   & for Icelandic right single quotes 
%                 (looks like `).   \\
%      |\iflqq| & for Icelandic `french' left double quotes 
%                 (similar to $>>$).\\
%      |\ifrqq| & for Icelandic `french' right double quotes 
%                 (similar to $<<$).\\
%      |\ifrq|  & for Icelandic `french' right single quotes 
%                 (similar to $<$).\\
%      |\iflq|  & for Icelandic `french' left single quotes 
%                 (similar to $>$). \\
%      |\dq|    & the original quotes character (|"|).        \\
%      |\oob|   & for old Icelandic "o \\
%      |\Oob|   & for old Icelandic "O \\
%      |\ooob|  & for old Icelandic "ó \\
%      |\OOob|  & for old Icelandic "Ó \\
%      |\eob|   & for old Icelandic "e \\
%      |\Eob|   & for old Icelandic "E \\
%      |\eeob|  & for old Icelandic "é \\
%      |\EEob|  & for old Icelandic "É \\
%     \end{tabular}
%     \end{otherlanguage*}
%     \caption{Commands which produce quotes and old Icelandic
%       diacritics, defined by 
%     \file{icelandic.ldf}}\label{tab:icelandic-commands}
%     \end{center}
%    \end{table}
%
%    \begin{thebibliography}{1}
%    
%    \bibitem{88:_reglur}
%    Alþingi.
%    \newblock {\em Reglur um frágang þingskjala og prentun umræðna},
%    1988. 
%    
%    \bibitem{74:_augl}
%    Auglýsing um greinarmerkjasetningu.
%    \newblock Stj.tíð B, nr. 133/1974, 1974.
%    
%    \bibitem{77:_augl}
%    Auglýsing um breyting auglýsingu nr. 132/1974 um íslenska
%    stafsetningu. 
%    \newblock Stj.tíð B, nr. 261/1977, 1977.
%    
%    \bibitem{unknown72:_first_gramm_treat}
%    Einar Haugen, editor.
%    \newblock {\em First Grammatical Treatise}.
%    \newblock Longman, London, 2 edition, 1972.
%    
%    \bibitem{97:_forst_fs}
%    Staðlaráð Íslands og Fagráð í upplýsingatækni, Reykjavík.
%    \newblock {\em Forstaðall FS 130:1997}, 1997.
%    
%    \bibitem{94:_si}
%    STRÍ Staðlaráð Íslands.
%    \newblock {\em SI - kerfið}, 2 edition, 1994.
%    
%    \end{thebibliography}
%     
% \StopEventually{}
%
%
%  \subsection{\TeX{}nical details}
%
%    When this file was read through the option \Lopt{icelandic} we make
%    it behave as if \Lopt{icelandic} was specified.
%
%    \begin{macrocode}
\def\bbl@tempa{icelandic}
\ifx\CurrentOption\bbl@tempa
  \def\CurrentOption{icelandic}
\fi
%    \end{macrocode}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
%    \begin{macrocode}
%<*code>
\LdfInit\CurrentOption{captions\CurrentOption}
%    \end{macrocode}
%
%    When this file is read as an option, i.e., by the |\usepackage|
%    command, \texttt{icelandic} will be an `unknown' language, so we
%    have to make it known.  So we check for the existence of
%    |\l@icelandic| to see whether we have to do something here.
%
%    \begin{macrocode}
\ifx\l@icelandic\@undefined
  \@nopatterns{Icelandic}
  \adddialect\l@icelandic0
\fi
%    \end{macrocode}
%
%  \begin{macro}{\if@Two@E}
%    We will need a new `if' : |\if@Two@E| is true if and only if
%    \LaTeXe{} is running \emph{not} in compatibility mode. It is
%    used in the definitions of the command |\tala| and |\upp|.
%    The definition is somewhat complicated, due to the fact that
%    |\if@compatibility| is not recognized as a |\if| in
%    \LaTeX-2.09 based formats.
%    \begin{macrocode}
\newif\if@Two@E \@Two@Etrue
\def\@FI@{\fi}
\ifx\@compatibilitytrue\@undefined
  \@Two@Efalse \def\@FI@{\relax}
\else
  \if@compatibility \@Two@Efalse \fi
\@FI@
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\extrasicelandic}
%  \begin{macro}{\noextrasicelandic}
%
%    The macro |\extrasicelandic| 
%    will perform all the extra definitions needed for the Icelandic
%    language. The macro |\noextrasicelandic| is used to cancel the
%    actions of |\extrasicelandic|. 
%
%    For Icelandic  the \texttt{"} character is
%    made active. This is done once, later on its definition may vary.
%    \begin{macrocode}
\initiate@active@char{"}
\@namedef{extras\CurrentOption}{%
  \languageshorthands{icelandic}}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \bbl@activate{"}}
%    \end{macrocode}
%    Don't forget to turn the shorthands off again.
% \changes{icelandic-1.1e}{1999/12/17}{Deactivate shorthands ouside of
%    Icelandic}
%    \begin{macrocode}
\addto\noextrasicelandic{\bbl@deactivate{"}}
%    \end{macrocode}
%
%    The icelandic hyphenation patterns can be used with
%    |\lefthyphenmin| and |\righthyphenmin| set to~2.
% \changes{icelandic-1.1f}{2000/09/22}{Now use \cs{providehyphenmins}
%    to provide a default value}
%    \begin{macrocode}
\providehyphenmins{\CurrentOption}{\tw@\tw@}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%    The code above is necessary because we need an extra active
%    character. This character is then used as indicated in
%    table~\ref{tab:icelandic-commands}.
%
%    To be able to define the function of |"|, we first define a
%    couple of `support' macros.
%
%  \subsection{Captionnames and date}
%
%    The next step consists of defining the Icelandic equivalents for
%    the \LaTeX{} captionnames.
%
%  \begin{macro}{\captionsicelandic}
%    The macro |\captionsicelandic| will define all strings used
%    used in the four standard document classes provided 
%    with \LaTeX.
% \changes{icelandic-1.1f}{2000/09/20}{Added \cs{glossaryname}}
% \changes{icelandic-1.1g}{2002/01/00}{Only use 7-bit ASCII characters
%    in order to keep the texts input encoding independant}
% \changes{icelandic-1.1g}{2002/01/09}{Added translation for Glossary}
%    \begin{macrocode}
\@namedef{captions\CurrentOption}{%
  \def\prefacename{Form\'{a}li}%
  \def\refname{Heimildir}%
  \def\abstractname{\'{U}tdr\'{a}ttur}%
  \def\bibname{Heimildir}%
  \def\chaptername{Kafli}%
  \def\appendixname{Vi{\dh}auki}%
  \def\contentsname{Efnisyfirlit}%
  \def\listfigurename{Myndaskr\'{a}}%
  \def\listtablename{T\"{o}fluskr\'{a}}%
  \def\indexname{Atri{\dh}isor{\dh}askr\'{a}}%
  \def\figurename{Mynd}%
  \def\tablename{Tafla}%
  \def\partname{Hluti}%
  \def\enclname{Hj\'{a}lagt}%
  \def\ccname{Samrit}% 
  \def\headtoname{Til:}% in letter
  \def\pagename{Bla{\dh}s\'{\i}{\dh}a}%
  \def\seename{Sj\'{a}}%
  \def\alsoname{Sj\'{a} einnig}%
  \def\proofname{S\"{o}nnun}%
  \def\glossaryname{Or{\dh}alisti}%
 }
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\dateicelandic}
%    The macro |\dateicelandic| redefines the command |\today|
%    to produce Icelandic dates.
% \changes{icelandic-1.1c}{1997/10/01}{Use \cs{edef} to define
%    \cs{today} to save memory}
% \changes{icelandic-1.1c}{1998/03/28}{use \cs{def} instead of \cs{edef}}
%    \begin{macrocode}
\def\dateicelandic{%
  \def\today{\number\day.~\ifcase\month\or
    jan\'{u}ar\or febr\'{u}ar\or mars\or apr\'{\i}l\or ma\'{\i}\or 
    j\'{u}n\'{\i}\or j\'{u}l\'{\i}\or \'{a}g\'{u}st\or september\or
    okt\'{o}ber\or n\'{o}vember\or desember\fi
    \space\number\year}}
%    \end{macrocode}
% \end{macro}
%
%
%  \subsection{Icelandic quotation marks}
%
%
%  \begin{macro}{\dq}
%    We save the original double quote character in |\dq| to keep
%    it available, the math accent |\"| can now be typed as |"|.
%    \begin{macrocode}
\begingroup \catcode`\"12
\def\x{\endgroup
  \def\@SS{\mathchar"7019 }
  \def\dq{"}}
\x
%    \end{macrocode}
%  \end{macro}
%
%    Now we can define the icelandic and icelandic `french' quotes.
%    The icelandic `french' guillemets are the reverse of french 
%    guillemets. We define single icelandic `french' quotes for
%    compatibility. Shorthands are provided for a number of different 
%    quotation marks, which make them useable both outside and 
%    inside mathmode.
%
%    \begin{macrocode}
\let\ilq\grq
\let\irq\grq
\let\iflq\frq
\let\ifrq\flq
\let\ilqq\glqq
\let\irqq\grqq
\let\iflqq\frqq
\let\ifrqq\flqq
%    \end{macrocode}
%
%    \begin{macrocode}
\declare@shorthand{icelandic}{"`}{\glqq}
\declare@shorthand{icelandic}{"'}{\grqq}
\declare@shorthand{icelandic}{">}{\frqq}
\declare@shorthand{icelandic}{"<}{\flqq}
%    \end{macrocode}
%    and some additional commands:
%    \begin{macrocode}
\declare@shorthand{icelandic}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{icelandic}{"|}{%
  \textormath{\nobreak\discretionary{-}{}{\kern.03em}%
              \bbl@allowhyphens}{}}
\declare@shorthand{icelandic}{""}{\hskip\z@skip}
\declare@shorthand{icelandic}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{icelandic}{"=}{\nobreak-\hskip\z@skip}
%    \end{macrocode}
%
%
%  \subsection{Old Icelandic}
%  \label{oldicelandic}
%
% \changes{icelandic-1.1}{1997/04/24}{Added definitions for old
%    icelandic.}
%
%    In old Icelandic some letters have special diacritical marks, 
%    described for example in \emph{First Grammatical
%    Treatise}~\cite{unknown72:_first_gramm_treat,97:_forst_fs}. We
%    provide these in the \texttt{T1} encoding with the `ogonek'. The
%    ogonek is placed with the letters `o', and `O', `ó' and `Ó', `e'
%    and `E', and `é' and `É'. Shorthands are provided for these as
%    well. 
%
%    The following code by Leszek Holenderski lifted from 
%    \texttt{polish.dtx} is  designed to position the diacritics 
%    correctly for every font in every size. These macros need a 
%    few extra dimension variables.
%
%    \begin{macrocode}
\newdimen\pl@left
\newdimen\pl@down
\newdimen\pl@right
\newdimen\pl@temp
%    \end{macrocode}
%
%  \begin{macro}{\sob}
%    The macro |\sob| is used to put the `ogonek' in the right
%    place.
%
%    \begin{macrocode}
\def\sob#1#2#3#4#5{%parameters: letter and fractions hl,ho,vl,vo
  \setbox0\hbox{#1}\setbox1\hbox{\k{}}\setbox2\hbox{p}%
  \pl@right=#2\wd0 \advance\pl@right by-#3\wd1
  \pl@down=#5\ht1 \advance\pl@down by-#4\ht0
  \pl@left=\pl@right \advance\pl@left by\wd1
  \pl@temp=-\pl@down \advance\pl@temp by\dp2 \dp1=\pl@temp
  \leavevmode
  \kern\pl@right\lower\pl@down\box1\kern-\pl@left #1}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\oob}
%  \begin{macro}{\Oob}
%  \begin{macro}{\ooob}
%  \begin{macro}{\OOob}
%  \begin{macro}{\eob}
%  \begin{macro}{\Eob}
%  \begin{macro}{\eeob}
%  \begin{macro}{\EEob}
%    \begin{macrocode}
\DeclareTextCommand{\oob}{T1}{\sob {o}{.85}{0}{.04}{0}}
\DeclareTextCommand{\Oob}{T1}{\sob {O}{.7}{0}{0}{0}}
\DeclareTextCommand{\ooob}{T1}{\sob {ó}{.85}{0}{.04}{0}}
\DeclareTextCommand{\OOob}{T1}{\sob {Ó}{.7}{0}{0}{0}}
\DeclareTextCommand{\eob}{T1}{\sob {e}{1}{0}{.04}{0}}
\DeclareTextCommand{\Eob}{T1}{\sob {E}{1}{0}{.04}{0}}
\DeclareTextCommand{\eeob}{T1}{\sob {é}{1}{0}{.04}{0}}
\DeclareTextCommand{\EEob}{T1}{\sob {É}{1}{0}{.04}{0}}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%    \begin{macrocode}
\declare@shorthand{icelandic}{"o}{\oob}
\declare@shorthand{icelandic}{"O}{\Oob}
\declare@shorthand{icelandic}{"ó}{\ooob}
\declare@shorthand{icelandic}{"Ó}{\OOob}
\declare@shorthand{icelandic}{"e}{\eob}
\declare@shorthand{icelandic}{"E}{\Eob}
\declare@shorthand{icelandic}{"é}{\eeob}
\declare@shorthand{icelandic}{"É}{\EEob}
%    \end{macrocode}
%
%  \subsection{Formatting numbers}
%  \label{numbers}
%
% \changes{icelandic-1.1a}{1997/04/26}{Added definitions for 
%    formatting numbers in Icelandic and some extra utilities.}
%    This section is lifted from \texttt{frenchb.dtx} by D. Flipo.
%    In English the decimal part starts with a point and thousands
%    should be separated by a comma: an approximation of $1000\pi$
%    should be inputed as |$3{,}141.592{,}653$| in math-mode and
%    as |3,141.592,653| in text.
% \changes{icelandic-1.1b}{1997/05/05}{Added references to various
%    publications used} 
%    
%    In Icelandic the decimal part starts with a comma and thousands
%    should be separated by a space~\cite{88:_reglur} or by a
%    period~\cite{97:_forst_fs}; we have the space. The above 
%    approximation of $1000\pi$ should be inputed as
%    |$3\;141{,}592\;653$| in math-mode and as something like 
%    |3~141,592~653| in text. Braces are mandatory around the comma in
%    math-mode, the reason is mentioned in the \TeX{}book p.~134:
%    the comma is of type |\mathpunct| (thus normally followed by a 
%    space) while the point is of type |\mathord| (no space added).
%
%    Thierry Bouche suggested that a second type of comma, of type
%    |\mathord| would be useful in math-mode, and proposed to
%    introduce a command (named |\decimalsep| in this package),
%    the expansion of which would depend on the current language.
%
%    Vincent Jalby suggested a command |\nombre| to conveniently
%    typeset numbers: inputting |\nombre{3141,592653}| either in
%    text or in math-mode will format this number properly according
%    to the current language (Icelandic or non-Icelandic). We use 
%    |\nombre| to define command |\tala| in Icelandic.
%
%    |\tala| accepts an optional argument which happens to be
%    useful with the extension `dcolumn', it specifies the decimal
%    separator used in the \emph{source code}:
%    |\newcolumntype{d}{D{,}{\decimalsep}{-1}}| \\
%    |\begin{tabular}{|d|}\hline    |    \\
%    |  3,14 \\                     |    \\
%    |  \tala[,]{123,4567} \\     |    \\
%    |  \tala[,]{9876,543}\\\hline|    \\
%    |\end{tabular}                 |    \\
%    will print a column of numbers aligned on the decimal point
%    (comma or point depending on the current language), each slice
%    of 3 digits being separated by a space or a comma according to
%    the current language.
%
%  \begin{macro}{\decimalsep}
%  \begin{macro}{\thousandsep}
%    We need a internal definition, valid in both text and math-mode,
%    for the comma (|\@comma@|) and another one for the unbreakable
%    fixed length space (no glue) used in Icelandic (|\f@thousandsep|).
%
%    The commands |\decimalsep| and |\thousandsep| get default
%    definitions (for the English language) when |icelandic| is loaded;
%    these definitions will be updated when the current language is
%    switched to or from Icelandic.
%    \begin{macrocode}
\mathchardef\m@comma="013B \def\@comma@{\ifmmode\m@comma\else,\fi}
\def\f@thousandsep{\ifmmode\mskip5.5mu\else\penalty\@M\kern.3em\fi}
\newcommand{\decimalsep}{.}  \newcommand{\thousandsep}{\@comma@}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
            \def\decimalsep{\@comma@}%
            \def\thousandsep{\f@thousandsep}}
\expandafter\addto\csname noextras\CurrentOption\endcsname{%
            \def\decimalsep{.}%
            \def\thousandsep{\@comma@}}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\tala}
%    The decimal separator used when \emph{inputing} a number
%    with |\tala| \emph{has to be a comma}.
%    |\tala| splits the inputed number into two parts: what
%    comes before the first comma will be formatted by
%    \cs{@integerpart} while the rest (if not  empty) will be
%    formatted by \cs{@decimalpart}. Both parts, once formatted
%    separately will be merged together with between them, either
%    the decimal separator \cs{decimalsep} or (in \LaTeXe{}
%    \emph{only}) the optional argument of |\tala|.
%
%    \begin{macrocode}
\if@Two@E
  \newcommand{\tala}[2][\decimalsep]{%
         \def\@decimalsep{#1}\@tala#2\@empty,\@empty,\@nil}
\else
  \newcommand{\tala}[1]{%
         \def\@decimalsep{\decimalsep}\@tala#1\@empty,\@empty,\@nil}
\fi
\def\@tala#1,#2,#3\@nil{%
       \ifx\@empty#2%
         \@integerpart{#1}%
       \else
         \@integerpart{#1}\@decimalsep\@decimalpart{#2}%
       \fi}
%    \end{macrocode}
%    The easiest bit is the decimal part:
%    We attempt to read the first four digits of the decimal part, if
%    it has less than 4 digits, we just have to print them, otherwise
%    |\thousandsep| has to be appended after the third digit, and the
%    algorithm is applied recursively to the rest of the decimal part.
%    \begin{macrocode}
\def\@decimalpart#1{\@@decimalpart#1\@empty\@empty\@empty}
\def\@@decimalpart#1#2#3#4{#1#2#3%
  \ifx\@empty#4%
  \else
    \thousandsep\expandafter\@@decimalpart\expandafter#4%
  \fi}
%    \end{macrocode}
%    Formatting the integer part is more difficult because the slices
%    of 3 digits start from the \emph{bottom} while the number is
%    read from the top!
%    This (tricky) code is borrowed from David Carlisle's comma.sty.
%    \begin{macrocode}
\def\@integerpart#1{\@@integerpart{}#1\@empty\@empty\@empty}
\def\@@integerpart#1#2#3#4{%
  \ifx\@empty#2%
    \@addthousandsep#1\relax
  \else
    \ifx\@empty#3%
      \@addthousandsep\@empty\@empty#1#2\relax
    \else
      \ifx\@empty#4%
        \@addthousandsep\@empty#1#2#3\relax
      \else
        \@@integerpartafterfi{#1#2#3#4}%
      \fi
    \fi
  \fi}
\def\@@integerpartafterfi#1\fi\fi\fi{\fi\fi\fi\@@integerpart{#1}}
\def\@addthousandsep#1#2#3#4{#1#2#3%
  \if#4\relax
  \else
    \thousandsep\expandafter\@addthousandsep\expandafter#4%
  \fi}
%    \end{macrocode}
%  \end{macro}
%
%  \subsection{Extra utilities}
%
%    We now provide the Icelandic user with some extra utilities.
%
%  \begin{macro}{\upp}
%    |\upp| is for typesetting superscripts.  |\upp| relies on
%  \begin{macro}{\upp@size}
%    The internal macro |\upp@size| holds the size at which the
%    superscript will be typeset. The reason for this is that we have
%    to specify it differently for different formats.
%    \begin{macrocode}
\ifx\sevenrm\@undefined
  \ifx\@ptsize\@undefined
    \let\upp@size\small
  \else
    \ifx\selectfont\@undefined
%    \end{macrocode}
%    In this case the format is the original \LaTeX-2.09:
%    \begin{macrocode}
      \ifcase\@ptsize
        \let\upp@size\ixpt\or
        \let\upp@size\xpt\or
        \let\upp@size\xipt
      \fi
%    \end{macrocode}
%    When |\selectfont| is defined we probably have NFSS available:
%    \begin{macrocode}
    \else
      \ifcase\@ptsize
        \def\upp@size{\fontsize\@ixpt{10pt}\selectfont}\or
        \def\upp@size{\fontsize\@xpt{11pt}\selectfont}\or
        \def\upp@size{\fontsize\@xipt{12pt}\selectfont}
      \fi
    \fi
  \fi
\else
%    \end{macrocode}
%    If we end up here it must be a plain based \TeX{} format, so:
%    \begin{macrocode}
    \let\upp@size\sevenrm
\fi
%    \end{macrocode}
%  \end{macro}
%    Now we can define |\upp|. When \LaTeXe{} runs in
%    compatibility mode (\LaTeX-2.09 emulation), |\textsuperscript| is
%    also defined, but does no good job, so we give two different
%    definitions for |\upp| using |\if@Two@E|.
%    \begin{macrocode}
\if@Two@E
  \DeclareRobustCommand*{\upp}[1]{\textsuperscript{#1}}
\else
  \DeclareRobustCommand*{\upp}[1]{%
    \leavevmode\raise1ex\hbox{\upp@size#1}}
\fi
%    \end{macrocode}
%
%  \end{macro}
%
%    Some definitions for special characters. 
%    |\grada| needs a special treatment: it is |\char6|
%    in T1-encoding and |\char23| in OT1-encoding.
%    \begin{macrocode}
\ifx\fmtname\LaTeXeFmtName
  \DeclareTextSymbol{\grada}{T1}{6}
  \DeclareTextSymbol{\grada}{OT1}{23}
\else
  \def\T@one{T1}
  \ifx\f@encoding\T@one
    \newcommand{\grada}{\char6}
  \else
    \newcommand{\grada}{\char23}
  \fi
\fi
%    \end{macrocode}
%
%  \begin{macro}{\gradur}
%    Macro for typesetting the abbreviation for `degrees' (as in
%    `degrees Celsius'). As the bounding box of the character `degree'
%    has \emph{very} different widths in CMR/DC and PostScript fonts,
%    we fix the width of the bounding box of |\gradur| to 0.3\,em,
%    this lets the symbol `degree' stick to the preceding
%    (e.g., |45\gradur|) or following character (e.g., |20~\gradur C|).
%    \begin{macrocode}
\DeclareRobustCommand*{\gradur}{%
                       \leavevmode\hbox to 0.3em{\hss\grada\hss}}
%    \end{macrocode}
%  \end{macro}
%
%    The macro |\ldf@finish| takes care of looking for a
%    configuration file, setting the main language to be switched on
%    at |\begin{document}| and resetting the category code of
%    \texttt{@} to its original value.
%    \begin{macrocode}
\ldf@finish\CurrentOption
%</code>
%    \end{macrocode}
%
% \Finale
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\endinput
