% \iffalse meta-comment
%
% Copyright 1989-2005 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 Babel system 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{517}
%
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{catalan.dtx}
%</dtx>
%<code>\ProvidesLanguage{catalan}
%\fi
%\ProvidesFile{catalan.dtx}
        [2005/03/29 v2.2p Catalan support from the babel system]
%\iffalse
%% File `catalan.dtx'
%% Babel package for LaTeX version 2e
%% Copyright (C) 1989 - 2005
%%           by Johannes Braams, TeXniek
%
%% Catalan Language Definition File
%% Copyright (C) 1991 - 2005
%%           by Goncal Badenes <badenes at imec.be>
%%              Johannes Braams, TeXniek
%
%% Please report errors to: J.L. Braams babel at braams.cistron.nl
%%
%    This file is part of the babel system, it provides the source
%    code for the Catalan language definition file.
%    This file was developped out of spanish.sty and suggestions by
%    Goncal Badenes <badenes at imec.be> and Joerg Knappen
%    <knappen at vkpmzd.kph.uni-mainz.de>.
%
%    The file spanish.sty was written by Julio Sanchez,
%    (jsanchez@gmv.es) The code for the catalan language has been
%    removed and now is in this file.
%<*filedriver>
\documentclass{ltxdoc}
\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}
 \DocInput{catalan.dtx}
\end{document}
%</filedriver>
%\fi
%
% \GetFileInfo{catalan.dtx}
%
% \changes{catalan-2.0b}{1993/09/23}{Incorporated the changes from
%    \file{spanish.sty}}
% \changes{catalan-2.1}{1994/02/27}{Update for \LaTeXe}
% \changes{catalan-2.1d}{1994/06/26}{Removed the use of \cs{filedate}
%    and moved identification after the loading of \file{babel.def}}
% \changes{catalan-2.2b}{1995/07/04}{Made the activation of the grave
%    and acute accents optional}
% \changes{catalan-2.2c}{1995/07/08}{Removed the use of the tilde for
%    catalan}
% \changes{catalan-2.2f}{1996/07/13}{Replaced \cs{undefined} with
%    \cs{@undefined} and \cs{empty} with \cs{@empty} for consistency
%    with \LaTeX}
% \changes{catalan-2.2g}{1996/10/10}{Moved the definition of
%    \cs{atcatcode} right to the beginning.}
% \changes{catalan-2.2k}{1999/05/05}{A wrong \cs{changes} entry made
%    typesetting impossible}
%
%  \section{The Catalan language}
%
%    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-specific macro's for the
%    Catalan language.
%
%    For this language only the double quote character (|"|) is made
%    active by default. In table~\ref{tab:catalan-quote-def} an
%    overview is given of the new macros defined and the new meanings
%    of |"|. Additionally to that, the user can explicitly activate
%    the acute accent or apostrophe (|'|) and/or the grave accent
%    (|`|) characters by using the \Lopt{activeacute} and
%    \Lopt{activegrave} options. In that case, the definitions shown
%    in table~\ref{tab:catalan-quote-opt} also become
%    available\footnote{Please note that if the acute accent character
%    is active, it is necessary to take special care of coding
%    apostrophes in a way which cannot be confounded with
%    accents. Therefore, it is necessary to type \texttt{l'\{\}estri}
%    instead of \texttt{l'estri}.}.
%
%    \begin{table}[htb]
%     \centering
%     \begin{tabular}{lp{8cm}}
%      |\l.l|   & geminated-l digraph (similar to
%               l$\cdot$l). |\L.L| produces the uppercase version.\\
%      |\lgem|  & geminated-l digraph (similar to
%               l$\cdot$l). |\Lgem| produces the uppercase version.\\
%      |\up| & Macro to help typing raised ordinals, like {1\raise
%               1ex\hbox{\small er}}. Takes one argument.\\
%      |\-| & like the old |\-|, but allowing hyphenation
%               in the rest of the word. \\
%      |"i| & i with diaeresis, allowing hyphenation
%             in the rest of the word. Valid for the following vowels:
%               i, u (both lowercase and uppercase).\\
%      |"c| & c-cedilla (\c{c}). Valid for both uppercase and
%               lowercase c.\\
%      |"l| & geminated-l digraph (similar to
%               l$\cdot$l). Valid for both uppercase and lowercase l.\\
%      |"<| & French left double quotes (similar to $<<$).\\
%      |">| & French right double quotes (similar to $>>$).\\
%      |"-| & explicit hyphen sign, allowing hyphenation
%               in the rest of the word.\\
%      \verb="|= & disable ligature at this position.
%     \end{tabular}
%     \caption{Extra definitions made by file \file{catalan.ldf}
%       (activated by default)}
%     \label{tab:catalan-quote-def}
%    \end{table}
%
%    \begin{table}[htb]
%     \centering
%     \begin{tabular}{lp{8cm}}
%      |'e| & acute accented a, allowing hyphenation
%             in the rest of the word. Valid for the following
%             vowels: e, i, o, u (both lowercase and uppercase).\\
%      |`a| & grave accented a, allowing hyphenation
%             in the rest of the word. Valid for the following
%             vowels: a, e, o (both lowercase and uppercase).
%     \end{tabular}
%     \caption{Extra definitions made by file \file{catalan.ldf}
%       (activated only when using the options \Lopt{activeacute} and
%       \Lopt{activegrave})}
%     \label{tab:catalan-quote-opt}
%    \end{table}
%    These active accents characters behave according to their original
%    definitions if not followed by one of the characters indicated in
%    that table.
%
% \StopEventually{}
%
% \changes{catalan-2.0}{1993/07/11}{Removed code to load
%    \file{latexhax.com}}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
% \changes{catalan-2.2g}{1996/11/02}{Now use \cs{LdfInit} to perform
%    initial checks} 
%    \begin{macrocode}
%<*code>
\LdfInit{catalan}\captionscatalan
%    \end{macrocode}
%
%    When this file is read as an option, i.e. by the |\usepackage|
%    command, \texttt{catalan} could be an `unknown' language in which
%    case we have to make it known.  So we check for the existence of
%    |\l@catalan| to see whether we have to do something here.
%
% \changes{catalan-2.1d}{1994/06/26}{Now use \cs{@nopatterns} to
%    produce the warning}
%    \begin{macrocode}
\ifx\l@catalan\@undefined
  \@nopatterns{Catalan}
  \adddialect\l@catalan0
\fi
%    \end{macrocode}
%
%    The next step consists of defining commands to switch to (and
%    from) the Catalan language.
%
%  \begin{macro}{\catalanhyphenmins}
%    This macro is used to store the correct values of the hyphenation
%    parameters |\lefthyphenmin| and |\righthyphenmin|.
% \changes{catalan-2.2n}{2001/02/19}{Set the hyphenation parameters
%    both to two as required by \texttt{cahyph.tex}}
%    \begin{macrocode}
\providehyphenmins{catalan}{\tw@\tw@}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\captionscatalan}
%    The macro |\captionscatalan| defines all strings used
%    in the four standard documentclasses provided with \LaTeX.
% \changes{catalan-1.1}{1993/07/11}{\cs{headpagename} should be
%    \cs{pagename}}
% \changes{catalan-2.0}{1993/07/11}{Added some names}
% \changes{catalan-2.1d}{1994/11/09}{Added a few missing translations}
% \changes{catalan-2.2b}{1995/07/03}{Added \cs{proofname} for
%    AMS-\LaTeX}
% \changes{catalan-2.2d}{1995/07/10}{added translation of Proof}
% \changes{catalan-2.2d}{1995/11/15}{Translations revised}
% \changes{catalan-2.2m}{2000/09/19}{Added \cs{glossaryname}}
% \changes{catalan-2.2p}{2003/11/17}{Inserted translation for
%    Glossary}
%    \begin{macrocode}
\addto\captionscatalan{%
  \def\prefacename{Pr\`oleg}%
  \def\refname{Refer\`encies}%
  \def\abstractname{Resum}%
  \def\bibname{Bibliografia}%
  \def\chaptername{Cap\'{\i}tol}%
  \def\appendixname{Ap\`endix}%
  \def\contentsname{\'Index}%
  \def\listfigurename{\'Index de figures}%
  \def\listtablename{\'Index de taules}%
  \def\indexname{\'Index alfab\`etic}%
  \def\figurename{Figura}%
  \def\tablename{Taula}%
  \def\partname{Part}%
  \def\enclname{Adjunt}%
  \def\ccname{C\`opies a}%
  \def\headtoname{A}%
  \def\pagename{P\`agina}%
  \def\seename{Vegeu}%
  \def\alsoname{Vegeu tamb\'e}%
  \def\proofname{Demostraci\'o}%
  \def\glossaryname{Glossari}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\datecatalan}
%    The macro |\datecatalan| redefines the command |\today| to
%    produce Catalan dates. Months are written in
%    lowercase\footnote{This seems to be the common practice. See for
%    example: E.~Coromina, \emph{El 9 Nou: Manual de redacci\'o i
%    estil}, Ed.~Eumo, Vic, 1993}.
% \changes{catalan-2.2b}{1995/06/18}{Month names in lowercase}
% \changes{catalan-2.2i}{1997/10/01}{Use \cs{edef} to define \cs{today}
%    to save memory}
% \changes{catalan-2.2i}{1998/03/28}{use \cs{def} instead of \cs{edef}}
%    \begin{macrocode}
\def\datecatalan{%
  \def\today{\number\day~\ifcase\month\or
    de gener\or de febrer\or de mar\c{c}\or d'abril\or de maig\or
    de juny\or de juliol\or d'agost\or de setembre\or d'octubre\or
    de novembre\or de desembre\fi
    \space de~\number\year}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\extrascatalan}
% \changes{catalan-2.0}{1993/07/11}{Macro completely rewritten}
% \changes{catalan-2.2a}{1995/03/11}{Handling of active characters
%    completely rewritten}
%
% \begin{macro}{\noextrascatalan}
% \changes{catalan-2.0}{1993/07/11}{Macro completely rewritten}
%
%    The macro |\extrascatalan| will perform all the extra definitions
%    needed for the Catalan language.  The macro |\noextrascatalan| is
%    used to cancel the actions of |\extrascatalan|.
%
% \changes{catalan-2.2e}{1995/11/10}{Now give the apostrophe a
%    lowercase code}
%    To improve hyphenation we give the grave character (\texttt{'}) a
%    non-zero lower case code; when we do that \TeX\ will find more
%    breakpoints in words that contain this character in its r\^ole as
%    apostrophe. 
%    \begin{macrocode}
\addto\extrascatalan{%
  \lccode`'=`'}
\addto\noextrascatalan{%
  \lccode`'=0}
%    \end{macrocode}
%
%    For Catalan, some characters are made active or are redefined. In
%    particular, the \texttt{"} character receives a new meaning; this
%    can also happen for the \texttt{'} character and the \texttt{`}
%    character when the options \Lopt{activegrave} and/or
%    \Lopt{activeacute} are specified.
%
% \changes{catalan-2.2b}{1995/07/07}{Make activating the accent
%    characters optional}
% \changes{catalan-2.2e}{1995/08/17}{Need to split up the
%    \cs{@ifpackagewith} statements}
%    \begin{macrocode}
\addto\extrascatalan{\languageshorthands{catalan}}
\initiate@active@char{"}
\addto\extrascatalan{\bbl@activate{"}}
%    \end{macrocode}
%    Because the grave character is being used in constructs such as
%    |\catcode``=\active| it needs to have it's original category code%''
%    when the auxiliary file is being read. Note that this file is
%    read twice, once at the beginning of the document; then there is
%    no problem; but the second time it is read at the end of the
%    document to check whether any labels changes. It's this second
%    time round that the actived grave character leads to error
%    messages.
% \changes{catalan-2.2l}{1999/11/29}{Make sure that the grave accent
%    has catcode 12 \emph{before} it is made \cs{active}}
%    \begin{macrocode}
\@ifpackagewith{babel}{activegrave}{%
  \AtBeginDocument{%
    \if@filesw\immediate\write\@auxout{\catcode096=12}\fi}
  \initiate@active@char{`}%
  }{}
\@ifpackagewith{babel}{activegrave}{%
  \addto\extrascatalan{\bbl@activate{`}}%
  }{}
\@ifpackagewith{babel}{activeacute}{%
  \initiate@active@char{'}%
  }{}
\@ifpackagewith{babel}{activeacute}{%
  \addto\extrascatalan{\bbl@activate{'}}%
  }{}
%    \end{macrocode}
%    Now make sure that the characters that have been turned into
%    shorthanfd characters expand to `normal' characters outside the
%    catalan environment.
% \changes{catalan-2.2l}{1999/12/16}{Don't forget do deactivate the
%    shorthands}
%    \begin{macrocode}
\addto\noextrascatalan{\bbl@deactivate{"}}
\@ifpackagewith{babel}{activegrave}{%
  \addto\noextrascatalan{\bbl@deactivate{`}}}{}
\@ifpackagewith{babel}{activeacute}{%
  \addto\noextrascatalan{\bbl@deactivate{'}}}{}
%    \end{macrocode}
%
% \changes{catalan-2.2a}{1995/03/11}{All the code for handling active
%    characters is now moved to \file{babel.def}}
%
%    Apart from the active characters some other macros get a new
%    definition. Therefore we store the current ones to be able
%    to restore them later.
%    When their current meanings are saved, we can safely redefine
%    them.
%
%    We provide new definitions for the accent macros when one or
%    both of the options \Lopt{activegrave} or \Lopt{activeacute}
%    were specified.
%
% \changes{catalan-2.2h}{1997/01/08}{Added some comment signs to
%    prevent unwanted spaces in the output} 
%    \begin{macrocode}
\addto\extrascatalan{%
  \babel@save\"%
  \def\"{\protect\@umlaut}}%
\@ifpackagewith{babel}{activegrave}{%
  \babel@save\`%
  \addto\extrascatalan{\def\`{\protect\@grave}}
  }{}
\@ifpackagewith{babel}{activeacute}{%
  \babel@save\'%
  \addto\extrascatalan{\def\'{\protect\@acute}}
  }{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    All the code above is necessary because we need a few extra
%    active characters. These characters are then used as indicated in
%    tables~\ref{tab:catalan-quote-def}
%    and~\ref{tab:catalan-quote-opt}.
%
%  \begin{macro}{\dieresis}
%  \begin{macro}{\textacute}
% \changes{catalan-2.1d}{1994/06/26}{Renamed from \cs{acute} as that
%    is a \cs{mathaccent}}
%  \begin{macro}{\textgrave}
%
%    The original definition of |\"| is stored as |\dieresis|, because
%    the definition of |\"| might not be the default plain \TeX\
%    one. If the user uses \textsc{PostScript} fonts with the Adobe
%    font encoding the \texttt{"} character is not in the same
%    position as in Knuth's font encoding. In this case |\"| will not
%    be defined as |\accent"7F 1|, but as |\accent'310 #1|. Something
%    similar happens when using fonts that follow the Cork
%    encoding. For this reason we save the definition of |\"| and use
%    that in the definition of other macros. We do likewise for |\`|,
%    and |\'|.
%    \begin{macrocode}
\let\dieresis\"
\@ifpackagewith{babel}{activegrave}{\let\textgrave\`}{}
\@ifpackagewith{babel}{activeacute}{\let\textacute\'}{}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\@umlaut}
%  \begin{macro}{\@acute}
%  \begin{macro}{\@grave}
%    We check the encoding and if not using T1, we make the accents
%    expand but enabling hyphenation beyond the accent. If this is the
%    case, not all break positions will be found in words that contain
%    accents, but this is a limitation in \TeX. An unsolved problem
%    here is that the encoding can change at any time. The definitions
%    below are made in such a way that a change between two 256-char
%    encodings are supported, but changes between a 128-char and a
%    256-char encoding are not properly supported. We check if T1 is
%    in use. If not, we will give a warning and proceed redefining the
%    accent macros so that \TeX{} at least finds the breaks that are
%    not too close to the accent. The warning will only be printed to
%    the log file.
%
%    \begin{macrocode}
\ifx\DeclareFontShape\@undefined
  \wlog{Warning: You are using an old LaTeX}
  \wlog{Some word breaks will not be found.}
  \def\@umlaut#1{\allowhyphens\dieresis{#1}\allowhyphens}
  \@ifpackagewith{babel}{activeacute}{%
    \def\@acute#1{\allowhyphens\textacute{#1}\allowhyphens}}{}
  \@ifpackagewith{babel}{activegrave}{%
    \def\@grave#1{\allowhyphens\textgrave{#1}\allowhyphens}}{}
\else
  \ifx\f@encoding\bbl@t@one
    \let\@umlaut\dieresis
    \@ifpackagewith{babel}{activeacute}{%
      \let\@acute\textacute}{}
    \@ifpackagewith{babel}{activegrave}{%
      \let\@grave\textgrave}{}
  \else
    \wlog{Warning: You are using encoding \f@encoding\space
      instead of T1.}
    \wlog{Some word breaks will not be found.}
    \def\@umlaut#1{\allowhyphens\dieresis{#1}\allowhyphens}
    \@ifpackagewith{babel}{activeacute}{%
      \def\@acute#1{\allowhyphens\textacute{#1}\allowhyphens}}{}
    \@ifpackagewith{babel}{activegrave}{%
      \def\@grave#1{\allowhyphens\textgrave{#1}\allowhyphens}}{}
  \fi
\fi
%    \end{macrocode}
%    If the user setup has extended fonts, the Ferguson macros are
%    required to be defined. We check for their existance and, if
%    defined, expand to whatever they are defined to. For instance,
%    |\'a| would check for the existance of a |\@ac@a| macro. It is
%    assumed to expand to the code of the accented letter.  If it is
%    not defined, we assume that no extended codes are available and
%    expand to the original definition but enabling hyphenation beyond
%    the accent. This is as best as we can do. It is better if you
%    have extended fonts or ML-\TeX{} because the hyphenation
%    algorithm can work on the whole word. The following macros are
%    directly derived from ML-\TeX{}.\footnote{A problem is perceived
%    here with these macros when used in a multilingual environment
%    where extended hyphenation patterns are available for some but
%    not all languages. Assume that no extended patterns exist at some
%    site for French and that \file{french.sty} would adopt this
%    scheme too. In that case, \mbox{\texttt{'e}} in French would
%    produce the combined accented letter, but hyphenation around it
%    would be suppressed. Both language options would need an
%    independent method to know whether they have extended patterns
%    available. The precise impact of this problem and the possible
%    solutions are under study.}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \changes{catalan-2.2a}{1995/03/14}{All the code to deal with active
%    characters is now in \file{babel.def}} 
%
%    Now we can define our shorthands: the diaeresis and ``ela
%    geminada'' support,
%    \begin{macrocode}
\declare@shorthand{catalan}{"i}{\textormath{\@umlaut\i}{\ddot\imath}}
\declare@shorthand{catalan}{"l}{\lgem{}}
\declare@shorthand{catalan}{"u}{\textormath{\@umlaut u}{\ddot u}}
\declare@shorthand{catalan}{"I}{\textormath{\@umlaut I}{\ddot I}}
\declare@shorthand{catalan}{"L}{\Lgem{}}
\declare@shorthand{catalan}{"U}{\textormath{\@umlaut U}{\ddot U}}
%    \end{macrocode}
%    cedille,
% \changes{catalan-2.2c}{1995/07/08}{cedile now produced by double
%    quote shorthand}
%    \begin{macrocode}
\declare@shorthand{catalan}{"c}{\textormath{\c c}{^{\prime} c}}
\declare@shorthand{catalan}{"C}{\textormath{\c C}{^{\prime} C}}
%    \end{macrocode}
%    `french' quote characters,
% \changes{catalan-2.2c}{1995/07/08}{Added shorthands for guillemets}
% \changes{catalan-2.2i}{1997/04/03}{Removed empty groups after
%    guillemot characters} 
%    \begin{macrocode}
\declare@shorthand{catalan}{"<}{%
  \textormath{\guillemotleft}{\mbox{\guillemotleft}}}
\declare@shorthand{catalan}{">}{%
  \textormath{\guillemotright}{\mbox{\guillemotright}}}
%    \end{macrocode}
%     grave accents,
% \changes{catalan-2.2e}{1996/03/05}{Added `{}` as an axtra shorthand}
%    \begin{macrocode}
\@ifpackagewith{babel}{activegrave}{%
  \declare@shorthand{catalan}{`a}{\textormath{\@grave a}{\grave a}}
  \declare@shorthand{catalan}{`e}{\textormath{\@grave e}{\grave e}}
  \declare@shorthand{catalan}{`o}{\textormath{\@grave o}{\grave o}}
  \declare@shorthand{catalan}{`A}{\textormath{\@grave A}{\grave A}}
  \declare@shorthand{catalan}{`E}{\textormath{\@grave E}{\grave E}}
  \declare@shorthand{catalan}{`O}{\textormath{\@grave O}{\grave O}}
  \declare@shorthand{catalan}{``}{\textquotedblleft}%''
  }{}
%    \end{macrocode}
%     acute accents,
% \changes{catalan-2.2b}{1995/07/03}{Changed mathmode definition of
%    acute shorthands to expand to a single prime followed by the next
%    character in the input}
% \changes{catalan-2.2e}{1995/09/05}{Added vertical bar as argument to
%    active acute}
%    \begin{macrocode}
\@ifpackagewith{babel}{activeacute}{%
  \declare@shorthand{catalan}{'a}{\textormath{\@acute a}{^{\prime} a}}
  \declare@shorthand{catalan}{'e}{\textormath{\@acute e}{^{\prime} e}}
  \declare@shorthand{catalan}{'i}{\textormath{\@acute\i{}}{^{\prime} i}}
  \declare@shorthand{catalan}{'o}{\textormath{\@acute o}{^{\prime} o}}
  \declare@shorthand{catalan}{'u}{\textormath{\@acute u}{^{\prime} u}}
  \declare@shorthand{catalan}{'A}{\textormath{\@acute A}{^{\prime} A}}
  \declare@shorthand{catalan}{'E}{\textormath{\@acute E}{^{\prime} E}}
  \declare@shorthand{catalan}{'I}{\textormath{\@acute I}{^{\prime} I}}
  \declare@shorthand{catalan}{'O}{\textormath{\@acute O}{^{\prime} O}}
  \declare@shorthand{catalan}{'U}{\textormath{\@acute U}{^{\prime} U}}
  \declare@shorthand{catalan}{'|}{%
    \textormath{\csname normal@char\string'\endcsname}{^{\prime}}}
%    \end{macrocode}
%         the acute accent,
% \changes{catalan-2.2c}{1995/07/08}{Added '{}' as an axtra shorthand,
%    removed 'n as a shorthand}
%    \begin{macrocode}
  \declare@shorthand{catalan}{''}{%
    \textormath{\textquotedblright}{\sp\bgroup\prim@s'}}
  }{}
%    \end{macrocode}
%    and finally, some support definitions
%    \begin{macrocode}
\declare@shorthand{catalan}{"-}{\nobreak-\bbl@allowhyphens}
\declare@shorthand{catalan}{"|}{%
  \textormath{\nobreak\discretionary{-}{}{\kern.03em}%
              \allowhyphens}{}}
%    \end{macrocode}
%
%  \begin{macro}{\-}
%
%    All that is left now is the redefinition of |\-|. The new version
%    of |\-| should indicate an extra hyphenation position, while
%    allowing other hyphenation positions to be generated
%    automatically. The standard behaviour of \TeX\ in this respect is
%    unfortunate for Catalan but not as much as for Dutch or German,
%    where long compound words are quite normal and all one needs is a
%    means to indicate an extra hyphenation position on top of the
%    ones that \TeX\ can generate from the hyphenation
%    patterns. However, the average length of words in Catalan makes
%    this desirable and so it is kept here.
%
%    \begin{macrocode}
\addto\extrascatalan{%
  \babel@save{\-}%
  \def\-{\bbl@allowhyphens\discretionary{-}{}{}\bbl@allowhyphens}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\lgem}
%  \begin{macro}{\Lgem}
% \changes{catalan-2.2b}{1995/06/18}{Added support for typing the
%    catalan ``ela geminada'' with the macros \cs{lgem} and \cs{Lgem}}
% \changes{catalan-2.2f}{1996/09/20}{Added a check for math mode as
%    the use of \cs{lgem} and \cs{Lgem} in math mode is not sensible.}
%
%    Here we define a macro for typing the catalan ``ela geminada''
%    (geminated l). The macros |\lgem| and |\Lgem| have been chosen
%    for its lowercase and uppercase representation,
%    respectively\footnote{The macro names \cs{ll} and \cs{LL} were
%    not taken because of the fact that \cs{ll} is already used in
%    mathematical mode.}.
%
%    The code used in the actual macro used is a combination of the
%    one proposed by Feruglio and Fuster\footnote{G.~Valiente and
%    R.~Fuster, Typesetting Catalan Texts with \TeX, \emph{TUGboat}
%    \textbf{14}(3), 1993.} and the proposal\footnote{G. Valiente,
%    Modern Catalan Typographical Conventions, \emph{TUGboat}
%    \textbf{16}(3), 1995.} from Valiente presented at the \TeX\ Users
%    Group Annual Meeting in 1995. This last proposal has not been
%    fully implemented due to its limitation to CM fonts.
%    \begin{macrocode}
\newdimen\leftllkern \newdimen\rightllkern \newdimen\raiselldim
\def\lgem{%
  \ifmmode
    \csname normal@char\string"\endcsname l%
  \else
    \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
    \setbox0\hbox{l}\setbox1\hbox{l\/}\setbox2\hbox{.}%
    \advance\raiselldim by \the\fontdimen5\the\font
    \advance\raiselldim by -\ht2%
    \leftllkern=-.25\wd0%
    \advance\leftllkern by \wd1%
    \advance\leftllkern by -\wd0%
    \rightllkern=-.25\wd0%
    \advance\rightllkern by -\wd1%
    \advance\rightllkern by \wd0%
    \allowhyphens\discretionary{l-}{l}%
    {\hbox{l}\kern\leftllkern\raise\raiselldim\hbox{.}%
      \kern\rightllkern\hbox{l}}\allowhyphens
  \fi
  }
\def\Lgem{%
  \ifmmode
    \csname normal@char\string"\endcsname L%
  \else
    \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
    \setbox0\hbox{L}\setbox1\hbox{L\/}\setbox2\hbox{.}%
    \advance\raiselldim by .5\ht0%
    \advance\raiselldim by -.5\ht2%
    \leftllkern=-.125\wd0%
    \advance\leftllkern by \wd1%
    \advance\leftllkern by -\wd0%
    \rightllkern=-\wd0%
    \divide\rightllkern by 6%
    \advance\rightllkern by -\wd1%
    \advance\rightllkern by \wd0%
    \allowhyphens\discretionary{L-}{L}%
    {\hbox{L}\kern\leftllkern\raise\raiselldim\hbox{.}%
      \kern\rightllkern\hbox{L}}\allowhyphens
  \fi
  }
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\l.l}
%  \begin{macro}{\L.L}
% \changes{catalan-2.2e}{1996/06/26}{Added redefinition of \cs{l} and
%    \cs{L}}
%    It seems to be the most natural way of entering the ``ela
%    geminda'' to use the sequences |\l.l| and |\L.L|. These are not
%    really macro's by themselves but the macros |\l| and |\L| with
%    delimited arguments. Therefor we define two macros that check if
%    the next character is a period. If not the ``polish l'' will be
%    typeset, otherwise a ``ela geminada'' will be typeset and the
%    next two tokens will be `eaten'.
% \changes{catalan-2.2o}{2003/09/19}{Postpone the redefinition of
%    \cs{l} and \cs{L} until begin document to prevent overwriting by
%    fontenc}
%    \begin{macrocode}
\AtBeginDocument{%
  \let\lslash\l
  \let\Lslash\L
  \DeclareRobustCommand\l{\@ifnextchar.\bbl@l\lslash}
  \DeclareRobustCommand\L{\@ifnextchar.\bbl@L\Lslash}}
\def\bbl@l#1#2{\lgem}
\def\bbl@L#1#2{\Lgem}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\up}
%
%    A macro for typesetting things like 1\raise1ex\hbox{\small er} as
%    proposed by Raymon Seroul\footnote{This macro has been borrowed
%    from francais.dtx}.
% \changes{catalan-2.2b}{1995/06/18}{Added definition of macro
%    \cs{up}, which can be used to type ordinals}
% \changes{catalan-2.2e}{1996/02/29}{Now use \cs{textsuperscript} and
%    make \cs{up} robust}
%    \begin{macrocode}
\DeclareRobustCommand*{\up}[1]{\textsuperscript{#1}}
%    \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.
% \changes{catalan-2.2g}{1996/11/02}{Now use \cs{ldf@finish} to wrap
%    up} 
%    \begin{macrocode}
\ldf@finish{catalan}
%</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