<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% (c) 2001-2005 Javier Bezos

\def\fileversion{0.0004 pre-alpha}

\iffalse % ==========================
To do:

- verbatim
 - scripts
 Some settings (eg. names) should be done in two steps:
  \chaptername = \&lt;french&gt;chaptername or maybe not?
- AtBeginLanguage
- AtEndLanguage
- Hacer que al cargar una escritura rm/sf/ttfamily se ajusten
  para esa escritura? Así si se vuelve se conservan.
- Idea? platform + language =&gt; charset, eg, [unix, czech]
  is the same as [charset=isolat2]
- Most of definitions in .sd files should be moved to
  font encoding files. If a language requires another
  definition (Greek \~) then set it with
  \DeclareLanguageCommand.
- En lugar de mem.cfg, hacer eg spanish.mem which llama
  a spa.ld, ajusta las codificaciones, los patrones, etc. 
  (?)

\fi %========================

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mem}
  [2004/08/22 Multilingual LaTeX support for Lamed/Lambda]

\DeclareOption{loadonly}{\let\mem@sel@opt\relax}

% Now, a buggy setup in TeXLive 2003 is fixed. The
% best solution is to remove the file:
% \texmf\omega\lambda\omegabook\ltpatch.ltx
% Only restored if uctt, perhaps a package has
% customized fonts

\def\mem@a{uctt}
\ifx\ttdefault\mem@a
  \def\ttdefault{cmtt}
\fi                    

%\def\sfdefault{cmss}

\newcount\mem@count

\def\mem@@{mem-}
\def\mem@@trpr{mem-trpr-}
\def\mem@@prop{mem-prop-}
\def\mem@@flag{mem-flag-}
\def\mem@csflag#1{\csname mem-flag-#1\endcsname}

\def\mem@last{{}{}}

\input{mem-comm.sty}

% \mem@cmd{prefix}{&lt;language&gt;}{suffix} searchs the
% following definitions in an expandable way:
%
% \mem-prefix&lt;language&gt;-suffix   -&gt; dialect
% \mem-prefix!&lt;language&gt;-suffix  -&gt; language
% \mem-prefix?-suffix            -&gt; global
%
% and uses the first one found. Must be used
% inside \csname.
%
% Is it possible to extend it to script?
% 2005-12-08 Add \@empty after #3 in case it's {}.

\long\def\mem@cmd#1#2#3{%
  \mem@@#1%
  \expandafter
  \ifx\csname\mem@@#1#2-\string#3\@empty\endcsname\relax % if not language 
    \expandafter\ifx\csname\mem@@?#2\endcsname\relax % if not language
      ?%
    \else%
      \expandafter  % if not !language
      \ifx\csname\mem@@#1\csname\mem@@?#2\endcsname-\string#3\@empty\endcsname\relax
        ?%
      \else % if !language
        \csname\mem@@?#2\endcsname
      \fi
    \fi
  \else % if language
      #2%
  \fi-\string#3\@empty}

% \mem@use is a shorthand. If fact \mem@cmd is used directly
% only once

\long\def\mem@use#1#2{\mem@cmd{#1}\languagename{#2}}

\def\mem@ifno#1#2#3#4{%
  \if#1n\if#2o#3\else\@firstoftwo\fi\else#4\fi}

% \def\mem@ifup#1#2#3#4{%
%   \if#1u\if#2p#3\else\@firstoftwo\fi\else#4\fi}

\def\AtEndComponent#1{%
  \@ifundefined{\mem@@flag#1}%
    {\mem@error{Unknown component}}
    {\@ifundefined{mem@no#1}%
      {\@ifundefined{\mem@@\languagename-#1}%
        {\expandafter\let\csname\mem@@\languagename-#1\endcsname\@empty}%
        \@empty
      \expandafter\mem@after
         \csname\mem@@\languagename-#1\expandafter\endcsname}\@gobble}}

\def\mem@eadd#1{%
  \@ifundefined{\mem@@flag#1}%
    {\mem@error{Unknown module}}
    {\@ifundefined{mem@no#1}%
      {\@ifundefined{\mem@@\languagename-#1}%
        {\expandafter\let\csname\mem@@\languagename-#1\endcsname\@empty}%
        \@empty
      \expandafter\mem@eafter
         \csname\mem@@\languagename-#1\expandafter\endcsname}\@gobble}}

\def\DeclareLanguage#1{%
  \def\languagename{!#1}%
  \def\mem@main{!#1}%
  \DeclareDialect{#1}}

\def\DeclareDialect#1{%
  \expandafter\let\csname\mem@@?#1\endcsname\mem@main
  \expandafter
  \@namedef{#1text}{\languagetext{#1}}%
  \@ifundefined{#1}%
    {\newenvironment{#1}{\languageset{#1}}{}}%
    {\PackageWarning{mem}{Skipping declaration of #1
    environment.\MessageBreak This name already exists.}}}

\@onlypreamble\DeclareLanguage
\@onlypreamble\DeclareDialect

\def\SetLanguage#1{%
  \@ifundefined{\mem@@?#1}%
     {\mem@bug@err4}%
     {\edef\languagename{!#1}}}

\def\SetDialect#1{
  \@ifundefined{\mem@@?#1}%
     {\mem@bug@err4}%
     {\edef\languagename{#1}}}

\@onlypreamble\SetLanguage
\@onlypreamble\SetDialect

\def\mem@ifcomponent#1{\@ifundefined{\mem@@flag#1}%
  {\mem@bug@err1\@gobble}}

% Components
% ~~~~~~~~~~

\def\DeclareLanguageComponent{%
  \@ifstar{\mem@newcomponent\mem@c}%
          {\mem@newcomponent\mem@text@components}}

\def\mem@newcomponent#1#2{%
  \def\mem@a##1##2##3\mem@a{%
    \mem@ifno##1##2}%
  \mem@a#2\mem@a
    {\mem@bug@err2}%
    {\@ifundefined{\mem@@flag#2}%
       {\mem@eafter\mem@components{%  Note the flag expands to \relax
          \noexpand\mem@elt\mem@csflag{#2}{#2}}%
        \mem@eafter#1{%
          \noexpand\mem@elt\mem@csflag{#2}{#2}}%
        \expandafter\edef
        \csname\mem@@prop?-#2\endcsname{%
          \noexpand\mem@flagon{\mem@csflag{#2}}%
          \noexpand\@tempswafalse}%
        \expandafter\edef
        \csname\mem@@prop?-no#2\endcsname{%
          \noexpand\mem@flagoff{\mem@csflag{#2}}%
          \noexpand\@tempswafalse}%
        \expandafter\newcount\csname\mem@@flag#2\endcsname}%
       {\PackageInfo{mem}%
         {Ignoring component declaration: #2.^^J%
          Already declared\@gobble}}}}

\@onlypreamble\DeclareLanguageComponent
\@onlypreamble\mem@newcomponent

\let\mem@components\@empty
\let\mem@text@components\@empty
\let\mem@c\@empty

\DeclareLanguageComponent*{names}
\DeclareLanguageComponent*{layout}

\DeclareLanguageComponent{date}
\DeclareLanguageComponent{processes}
\DeclareLanguageComponent{tools}

\expandafter\let\csname\mem@@prop?-text\endcsname\relax
\expandafter\let\csname\mem@@prop?-notext\endcsname\relax

\def\mem@enable{% Implicit #1
  \let\mem@ifenabling\@firstoftwo
  \mem@switch}

\def\mem@disable{% Implicit #1
  \let\mem@ifenabling\@secondoftwo
  \mem@switch}

\def\mem@switch#1{% !language
  \@nameuse{\mem@@\@nameuse{\mem@@?\languagename}-#1}% -!language-
  \@nameuse{\mem@@\languagename-#1}}  % -dialect-

\def\mem@switch@cmd#1#2{%
  \let\mem@c=#1%
  \let#1=#2%
  \let#2=\mem@c}

\def\mem@disablesub#1#2{%
  \ifcase#1\or\or
    \@gobble\or\mem@disable{#2}%
  \else
    \advance#1-\tw@
  \fi}

\def\mem@enablesub#1#2{%
  \ifcase#1\or\or
    \@gobble\or\mem@enable{#2}%
  \fi}

\def\mem@submain#1#2{%
  #1=\ifcase#1\z@\or
    \@ne\or
    \z@\or
    \@ne\mem@enable{#2}\or
    \tw@\or
    \thr@@\mem@disable{#2}\or
    \tw@\or
    \thr@@\or
    4 \or
    5 \mem@disable{#2}\or
    4 \or
    5 \fi\relax}

\def\mem@disablemain#1#2{%
  \ifcase#1\or\mem@disable{#2}\fi}

\def\mem@enablemain#1#2{%  Considerar la marca -\@m
  #1=\ifnum#1&lt;\z@\z@\else\@ne\mem@enable{#2}\fi}

\def\mem@step#1{\let\mem@elt#1\mem@components}

%%% 2005-12-08 Added grouping for languageset

\def\languageset{%
  \@ifstar{\mem@sel@i\@ne}{\mem@sel@i\z@}}

% Task: Replacing the text for empty
\def\mem@sel@i#1{%
%  To be used later. If \...text, then \mem@pardir = \@empty
  \def\mem@pardir{\pardir\csname\mem@@\mem@script-dir\endcsname}%
  \@ifnextchar[{\mem@sel@ii#1}{\mem@sel@ii#1[]}}

\def\mem@sel@ii#1[#2]#3{%
  \edef\mem@b{\zap@space#2 \@empty}%
  \ifcase#1%
    \edef\mem@a{{\expandafter\@firstoftwo\mem@last}{[\mem@b]{#3}}}%
  \else
    \def\mem@a{{[#2]{#3}}{}}%
  \fi
  \ifx\mem@a\mem@last\else
    \let\mem@last\mem@a
    \aftergroup\mem@fileends
    \mem@filesetup#1{#2}{#3}%
    \expandafter\mem@sel@iii\expandafter[\mem@b]{#3}#1%
  \fi}

\def\mem@sel@iii[#1]#2#3{%
  \@ifundefined{l@#2}%
     {\@ifundefined{memh@#2}%
        {\mem@error{Unknown language}\language\z@}%
        {\language\csname memh@#2\endcsname}}%
     {\language\csname l@#2\endcsname}%
  \let\mem@b\mem@script
  \mem@step\mem@disablesub
  \edef\languagename{#2}%
  \ifcase#3%  if local
    \def\mem@flagon##1{\advance##14\relax}%
    \def\mem@flagoff##1{\advance##18\relax}%
    \@tempswatrue
    \ExecuteLanguageProperties{#1}%
    \if@tempswa % if there was not &lt;component&gt; or &lt;nocomponent&gt;
      \def\mem@elt##1##2{\mem@flagon{##1}}%
      \mem@text@components
    \fi
    \mem@csflag{processes}=5
    \let\languagename\mem@main
    \mem@step\mem@submain
    \edef\languagename{#2}%
    \mem@step\mem@enablesub
  \else % if global
    \mem@step\mem@disablemain
    \def\mem@flagon##1{\Error}%
    \def\mem@flagoff##1{##1-\@m}% Just a mark
    \@tempswatrue
    \ExecuteLanguageProperties{#1}%
    %\if@tempswa
    %   % to be used if syntax changes
    %\fi
    %\mem@csflag{processes}=\@ne
    \edef\mem@main{#2}%
    \edef\languagename{#2}%
    \mem@step\mem@enablemain
  \fi
  \ifx\mem@b\mem@script\else\mem@switchfont\fi % mem@b saved above
  \edef\mem@charset{\csname\mem@use{}{cset}\endcsname}%
  \textdir\csname\mem@@\mem@script-dir\endcsname
    %\ifvmode
  \mem@pardir
    %\bodydir\csname\mem@@\mem@script-dir\endcsname
    %\fi
  \let\mem@pardir\@empty
  \SetLanguageProcess{charenc}{\mem@charset}%
  \SelectProcesses}

\def\mem@switchfont{%
  \mem@eforeach{\mem@fontfamilies}{%
    \@ifundefined{\mem@@ font-\languagename-##1}%
      {\@ifundefined{\mem@@ font-\mem@script-##1}{}%
         {\edef\rmdefault{%
            \csname\mem@@ font-\mem@script-##1\endcsname}}}%
      {\edef\rmdefault{%
         \csname\mem@@ font-\languagename-##1\endcsname}}}%
  \mem@family}  % To be expanded and fine-tuned

\def\mem@fontfamilies{rmfamily}%,sffamily,ttfamily}

\DeclareRobustCommand\languagetext{\@ifnextchar[{\mem@text}{\mem@text[]}}

% The following contains a trick to avoid passing the text as
% argument. The text is actually inside a group.

\def\mem@text[#1]#2{%
  \bgroup
    \mem@sel@ii\z@[#1]{#2}%
    \@ifnextchar\bgroup
      {\let\mem@a}% Gobbles the opening {
      {\mem@text@x}}% No braces--only a token

\def\mem@text@x#1{#1\egroup}

\def\languageunset{%
  \@ifstar
    {\languageset[]{\mem@main}}%
    {\mem@unsel@i\mem@unsel@ii}}

\def\mem@unsel@i{%
  \c@mem@depth\z@
  \mem@fileends
  \def\mem@elt##1{%
     \expandafter\let\csname\mem@@slot##1\endcsname\@empty}%
  \mem@elt{}%   or \@empty??
  \mem@streams}

\def\mem@unsel@ii{%
  \edef\languagereset{%
    \let\noexpand\languagereset\relax
    \noexpand\mem@ensure\mem@last}%
  \language\z@
  \mem@step\mem@disablesub
  \mem@step\mem@disablemain
  \def\mem@elt##1##2{\mem@csflag{##2}\z@}%
  \mem@components
  \let\languagename\@empty
  %\SelectProcesses
  %\let\mem@main\@empty %% 2004/08/04 Commented out
  %\let\mem@trprlist\nullocplist
  \def\mem@last{{}{}}}

% Automatic switching of languages

\def\UpdateScript#1{}

% Synchonization with auxiliary files
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\AtBeginDocument{%
  \if@filesw\else
    \def\mem@filesetup#1#2#3{}%
    \let\mem@filewrite\@gobble
    \let\mem@fileends\relax
  \fi}

\AtEndDocument{%
    \let\mem@newpage\newpage
    \def\newpage{%
      \let\newpage\mem@newpage
      \newpage
      \let\mem@immediate\immediate
      \languageunset}}

\let\mem@immediate\relax

\def\mem@@slot{mem@slot@}

\def\mem@filesetup#1#2#3{%
  \advance\c@mem@depth\@ne
  \def\mem@elt##1{%
     \expandafter\mem@after\csname\mem@@slot##1\endcsname
       {\addtocounter{\mem@@slot\the\mem@count}\@ne
        \mem@immediate\write\mem@count
          {\mem@begin
           \noexpand\languageset\ifcase#1\or*\fi[#2]{#3}}}}%
  \mem@elt\@empty
  \mem@streams}

\def\mem@filewrite#1{%
   \mem@count=#1\relax
   \@ifundefined{c@\mem@@slot\the\mem@count}%
     {\newcounter{\mem@@slot\the\mem@count}%
      \mem@slot@
      \let\mem@elt\relax
      \xdef\mem@streams{\mem@streams\mem@elt{\the\mem@count}}}{}%
     {\@nameuse{\mem@@slot\the\mem@count}}%
   \expandafter\gdef\csname\mem@@slot\the\mem@count\endcsname{}}

\def\mem@fileends{%
  \def\mem@elt##1%
    {\ifnum\value{\mem@@slot##1}&gt;\c@mem@depth
       \mem@immediate\write##1{\mem@end}%
       \addtocounter{\mem@@slot##1}\m@ne
       \expandafter\mem@elt
     \else
       \expandafter\@gobble
     \fi{##1}}%
  \mem@streams
  \let\mem@elt\relax}%

\let\mem@streams\@empty
\let\mem@slot@\@empty % &lt;&lt;?????

\let\mem@begin\begingroup
\let\mem@end\endgroup

\newcounter{mem@depth}

\long\def\protected@write#1#2#3{%
  \mem@filewrite{#1}%
  \begingroup
    \let\thepage\relax
    #2%
    \let\protect\@unexpandable@protect
    \edef\reserved@a{\write#1{#3}}%
    \reserved@a
    \endgroup
  \if@nobreak\ifvmode\nobreak\fi\fi}

\long\def\@writefile#1#2{%
  \@ifundefined{tf@#1}\relax
    {\mem@filewrite{\csname tf@#1\endcsname}%
     \@temptokena{#2}%
     \mem@immediate\write\csname tf@#1\endcsname{\the\@temptokena}}}

% Dangerous. We should consider packages modifying that:
% Actually, is it necessary at all?

\def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]%
  \if@filesw
    \protected@write\@auxout{}%
      {\string\bibcite{#2}{\protect\mem@ensure\mem@last#1}}%
  \fi\ignorespaces}

% Declaring language stuff
% ~~~~~~~~~~~~~~~~~~~~~~~~

\def\DeclareLanguageCommand{%
  \@ifstar{\mem@command@s}% Full \newcommand syntax not allowed
          {\mem@command@x}}% with star. To be fixed.

\def\mem@command@s#1#2#3{%
  \@ifundefined{\mem@use{}{#1}}%
   {\mem@eadd{#2}{%
      \noexpand\mem@switch@cmd
      \expandafter\noexpand\csname\mem@@\languagename-\string#1\endcsname
      \noexpand#1}%
    \expandafter\newcommand
    \csname\mem@@\languagename-\string#1\endcsname
        {\utftext{#3}}}%
   {\mem@bug@err3}}

\def\mem@command@x#1#2{%
  \@ifundefined{\mem@use{}{#1}}%
   {\mem@eadd{#2}{%
      \noexpand\mem@switch@cmd
      \expandafter\noexpand\csname\mem@@\languagename-\string#1\endcsname
      \noexpand#1}%
    \expandafter\newcommand
    \csname\mem@@\languagename-\string#1\endcsname}%
   {\mem@bug@err3}}

\def\DeclareLanguageRobustCommand#1#2{%
  \@ifundefined{\mem@use{}{#1}}%
   {\mem@eadd{#2}{%
      \noexpand\mem@switch@robustcmd
      \expandafter\noexpand\csname\mem@@\languagename-\string#1\endcsname
      \noexpand#1%
      \expandafter\noexpand\csname\mem@@\languagename--\string#1\endcsname}%
    \expandafter\newcommand
    \csname\mem@@\languagename-\string#1\endcsname}%
   {\mem@bug@err3}}

\def\SetLanguageVariable#1#2{%
  \@ifundefined{\mem@use{}{#1}}%
   {\mem@eadd{#2}{
      \noexpand\mem@switch@var
      \expandafter\noexpand\csname\mem@@\languagename-\string#1\endcsname
      \noexpand#1}%
    \@namedef{\mem@@\languagename-\string#1}}%
   {\mem@bug3}}

\@onlypreamble\SetLanguageVariable
\@onlypreamble\DeclareLanguageCommand

\def\mem@enable{% Implicit #1
  \let\mem@ifenabling\@firstoftwo
  \mem@switch}

\def\mem@disable{% Implicit #1
  \let\mem@ifenabling\@secondoftwo
  \mem@switch}

\def\mem@switch#1{% !language
  \@nameuse{\mem@@\@nameuse{\mem@@?\languagename}-#1}% -!language-
  \@nameuse{\mem@@\languagename-#1}}  % -dialect-

\def\mem@switch@cmd#1#2{%
  \let\mem@c=#1%
  \let#1=#2%
  \let#2=\mem@c}

\def\mem@switch@robustcmd#1#2#3{%
  \mem@ifenabling
    {\expandafter\let\expandafter#3%
        \csname\expandafter\@gobble\string#2 \endcsname
     \expandafter\let\csname\expandafter\@gobble\string#2 \endcsname=#1%
     \let#1=#2%
     \edef\reserved@a{\string#2}%
     \def\reserved@b{#2}%
     \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
     \edef#2{%
        \ifx\reserved@a\reserved@b
           \noexpand\x@protect
           \noexpand#1%
        \fi
        \noexpand\protect
        \expandafter\noexpand\csname
           \expandafter\@gobble\string#2 \endcsname}}%
    {\let#2=#1%
     \expandafter\let\expandafter#1%
        \csname\expandafter\@gobble\string#2 \endcsname
     \expandafter\let\csname\expandafter\@gobble\string#2 \endcsname=#3}}

\def\mem@switch@var#1#2{%
  \edef\mem@c{\the#1}%
  #1=#2\relax
  \edef#2{\mem@c}}

\def\SetLanguageCode#1#2#3#4{%
  \mem@count=#3\relax
  \edef\mem@a{%
    \noexpand\SetLanguageVariable{\noexpand#1\the\mem@count}}%
  \mem@a{#2}{#4}%
  \def\mem@a{#2}% We must be sure that the language name
  \begingroup    % remains untouched with \lowercase
    \lccode`~=`#1
    \lccode`#1=`#1
    \lowercase{%
  \endgroup
  \AtEndComponent\mem@a{\UpdateSpecial{#1}}}}

\@onlypreamble\SetLanguageCode

% Dates
% ~~~~~

\def\DeclareDateFunctionDefault#1{%
  \expandafter\providecommand\csname\mem@@ DF-#1\endcsname}

\def\DeclareDateFunction#1{%
  \expandafter\DeclareLanguageCommand
    \csname\mem@@ DF-#1\endcsname{date}}

\@onlypreamble\DeclareDateFunctionDefault
\@onlypreamble\DeclareDateFunction

\begingroup
\catcode`&lt;=\active
\gdef\DeclareDateCommand#1{%
  \begingroup
  \let\protect\@unexpandable@protect
  \catcode`&lt;=\active
  \def&lt;##1&gt;{\expandafter\noexpand\csname\mem@@ DF-##1\endcsname}%
  \def\mem@a{%
   \edef\mem@b{\endgroup%
    \noexpand\DeclareLanguageCommand*{\noexpand#1}{date}{\mem@c}}
    \mem@b}%
  \afterassignment\mem@a\def\mem@c}
\endgroup

\@onlypreamble\DeclareDateCommand

\newcount\weekday

\let\c@day\day
\let\c@weekday\weekday
\let\c@month\month
\let\c@year\year

\def\SetWeekDay{\mem@count=\year\divide\mem@count4
  \weekday=\mem@count
  \multiply\mem@count4
  \advance\mem@count-\year
  \ifnum\mem@count=\z@
        \ifnum\month&lt;\thr@@\advance\weekday -1\fi\fi
  \advance\weekday\year
  \advance\weekday-1899
  \advance\weekday\ifcase\month\or0 \or31 \or59 \or90 \or120
        \or151 \or181 \or212 \or243 \or293 \or304 \or334 \fi
  \advance\weekday\day
  \mem@count=\weekday
  \divide\mem@count7
  \multiply\mem@count7
  \advance\weekday-\mem@count
  \advance\weekday\@ne}

\SetWeekDay

\DeclareDateFunctionDefault{d}{\the\day}
\DeclareDateFunctionDefault{dd}{\ifnum\day&lt;10 0\fi\the\day}

\DeclareDateFunctionDefault{m}{\the\month}
\DeclareDateFunctionDefault{mm}{\ifnum\month&lt;10 0\fi\the\month}

\DeclareDateFunctionDefault{yy}{\expandafter\@gobbletwo\the\year}
\DeclareDateFunctionDefault{yyyy}{\the\year}

\def\UpdateSpecial#1{%
  \expandafter\mem@updatespecial\csname\string#1\endcsname}

\def\mem@updatespecial#1{%
  \def\mem@b##1##2{%
    \ifnum`#1=`##2 \else
      \noexpand##1\noexpand##2%
    \fi}%
  \def\mem@c##1##2{%
    \ifnum\catcode`##2&lt;\active
      \ifnum\catcode`##2&gt;10 \else\@firstoftwo\fi
    \else
      \noexpand##1\noexpand##2%
    \fi}%
  \def\do{\mem@b\do}%
  \def\@makeother{\mem@b\@makeother}%
  \edef\dospecials{\dospecials\mem@c\do#1}%
  \edef\@sanitize{\@sanitize\mem@c\@makeother#1}%
  \let\do\relax
  \def\@makeother##1{\catcode`##1=12\relax}}

\def\languageensure{%
  \ifx\glossary\relax
    \protect\mem@ensure\mem@last
  \fi}

\def\mem@ensure#1#2{%
  \def\mem@a{{#1}{#2}}%
  \ifx\mem@a\mem@last\else
    \def\mem@a{#1}%
    \ifx\mem@a\@empty
      \def\mem@c{\mem@unsel@ii}%
    \else
      \def\mem@c{\mem@sel@iii#1\@ne}%
    \fi
    \def\mem@a{#2}%
    \ifx\mem@a\@empty\else
      \def\mem@a{#1}\edef\mem@b{\expandafter\@firstoftwo\mem@last}%
      \ifx\mem@b\mem@a
        \expandafter\def\else\expandafter\mem@after
      \fi
      \mem@c{\mem@sel@iii#2\z@}%
    \fi
    \expandafter\mem@c
  \fi}

% A recent change in LaTeX: now marks *are not* expanded 2004/08/05

\def\markboth#1#2{%
  \begingroup
    \let\label\relax \let\index\relax \let\glossary\relax
    \protected@edef\mem@a##1##2{%
       \noexpand\unrestored@protected@xdef
       \noexpand\@themark
       {{\languageensure##1}{\languageensure##2}}}%
    \mem@a{#1}{#2}%
    \@temptokena \expandafter{\@themark}%
    \mark{\the\@temptokena}%
  \endgroup
  \if@nobreak\ifvmode\nobreak\fi\fi}

\def\@markright#1#2#3{%
  \@temptokena{#1}%
  \protected@edef\mem@a##1##2{%
      \noexpand\unrestored@protected@xdef
      \noexpand\@themark{{##1}{\languageensure##2}}}%
  \mem@a{\the\@temptokena}{#3}}

%======

%\DeclareProcess{T1}{t1-a, t2-a}

%\DeclareLanguageProcessGroup
%\DeclareMemProcessGroup

% Puesto quien decide si un grupo es language o mem es
% lo primero, se puede reducir a una forma:

%\AddMemProcess{font}{fontenc}
%\AddLanguageProcess{text}{sigma,otro,otro} % Logical

%\SetMemProcess{fontenc}{T1}
%\SetLanguageProcess{fontenc}{T1}

%\SelectProcesses % Ambos

\def\DeclareLanguageProcessGroup{\mem@declproc\languagename}
\def\DeclareMemProcessGroup{\mem@declproc?}

\let\mem@procgroups\@empty

% Añadir debug: Que muestre las definiciones, activaciones y
% estados actuales.

% The first version sorted the groups by numerical order, but
% as the ocp mechanism already uses the number to sort them
% (this is one of its features), I don't think this is
% is necessary. The previous version is:
% 
% \def\mem@declproc#1#2#3{%
%   \let\mem@a\@empty
%   \@tempswatrue
%   \def\mem@pg##1##2##3{%
%     \if@tempswa
%       \ifnum##2=#2\relax
%         \Error
%       \else\ifnum##2&gt;#2
%         \mem@after\mem@a{%
%           \mem@pg{#1}{#2}{#3}\mem@pg{##1}{##2}{##3}}%
%         \@tempswafalse
%       \else
%         \mem@after\mem@a{\mem@pg{##1}{##2}{##3}}%
%       \fi\fi
%     \else
%       \mem@after\mem@a{\mem@pg{##1}{##2}{##3}}%
%     \fi}%
%     \mem@procgroups
%     \if@tempswa
%       \mem@after\mem@a{\mem@pg{#1}{#2}{#3}}
%     \fi
%     \let\mem@procgroups\mem@a}
%
% This version would have to be expanded in order to check
% multiple declarations.
%  
% The new one is:

\def\mem@declproc#1#2#3{%
  % Multiple declarations are allowed provided they are
  % consistent:
  \@tempswatrue % true if to be added
  \def\mem@pg##1##2##3{%
    \ifnum#2=##2
      \def\mem@a{#1{}#3}\def\mem@b{##1{}##3}%
      \ifx\mem@a\mem@b
        \@tempswafalse
      \else
        \Error
      \fi
    \fi
    \def\mem@a{#3}\def\mem@b{##3}%
    \ifx\mem@a\mem@b
      \def\mem@a{\number#2{}#1}\def\mem@b{\number##2{}##1}%
      \ifx\mem@a\mem@b
        \@tempswafalse
      \else
        \Error
      \fi
    \fi}%
  \mem@procgroups
  \if@tempswa
    \mem@after\mem@procgroups{\mem@pg{#1}{#2}{#3}}%
  \fi}


\DeclareLanguageProcessGroup{200}{charset}
\DeclareLanguageProcessGroup{400}{unicode}
\DeclareLanguageProcessGroup{600}{transcript}
\DeclareLanguageProcessGroup{800}{input}
% 1000: case
\DeclareLanguageProcessGroup{1200}{text}
\DeclareMemProcessGroup{1400}{font}

\def\DeclareProcess#1#2{%
  \mem@ecs\let{mem-tp-?-#1}\@empty
  \mem@ecs\mem@lafter{mem-tp-?-#1}\mem@elt{#2}%
  \global\mem@ecs\let{mem-tp-?-#1\expandafter}\csname mem-tp-?-#1\endcsname}

% The following is variant to assign a different ocp for
% a certain language - for example, a different uppercase
% ocp for Turkish. To investigate if this is the right way,
% which explain why the syntax is different

\def\DeclareLanguageProcess#1#2{%
  \mem@ecs\let{mem-tp-\languagename-#1}\@empty
  \mem@ecs\mem@lafter{mem-tp-\languagename-#1}\mem@elt{#2}%
  \global\mem@ecs
    \let{mem-tp-\languagename-#1\expandafter}%
    \csname mem-tp-\languagename-#1\endcsname}

\def\mem@setproc#1#2#3{%
  \mem@ecs\let{mem-pp-#1-#2}\@empty
  \mem@ecs\mem@lafter{mem-pp-#1-#2}\mem@elttp{#3}%
  \def\mem@elttp##1{%
    %\expandafter\show\csname mem-tp-##1\endcsname
    \@ifundefined{mem-tp-?-##1}%
% Añadir aquí la posibilidad de un .mpd
      {\DeclareProcess{##1}{##1}}%
      {}}%
  \@nameuse{mem-pp-#1-#2}}

\def\SetMemProcess{\mem@setproc?}
\def\SetLanguageProcess{\mem@setproc\languagename}

% We must avoid duplicated entries, so that we can
% add processes redundantly (for example, in 'case'):

\def\mem@addproc#1#2#3{%
  \mem@setcsvar{mem-lp-#1-#2}%
  \def\mem@eltpp##1{,##1,}%
  \mem@eforeach{#3}{%
    \@expandtwoargs\in@{,##1,}{,\@nameuse{mem-lp-#1-#2},}%
    \ifin@\else
      \mem@ecs\mem@after{mem-lp-#1-#2}{\mem@eltpp{##1}}%
      \@ifundefined{mem-pp-#1-##1}%
        {\mem@setproc#1{##1}{##1}}%
        {}%
    \fi}}

\def\AddMemProcess{\mem@addproc?}
\def\AddLanguageProcess{\mem@addproc\languagename}

\def\mem@selectprocs#1#2#3{%
  % Make sure mem-lp-?-#3 is not undefined/relax
  \mem@setcsvar{mem-lp-?-#3}%
  \def\mem@eltpp##1{%
    \@ifundefined{\mem@use{pp-}{##1}}%
      {}%
      {\csname\mem@use{pp-}{##1}\endcsname}}%
  \def\mem@elttp##1{\csname\mem@use{tp-}{##1}\endcsname}%
  % Build the ocplist name
  \edef\mem@elt##1{\string/##1}%
  \edef\mem@c{\csname\mem@use{lp-}{#3}\endcsname}%
  \ifx\mem@c\@empty\else
    \edef\mem@a{cpl-\csname\mem@use{lp-}{#3}\endcsname}%
    \mem@debug\@ne{Processing OCP list \mem@c\space for group #3 (#2)}%
    \@ifundefined{\mem@a}%
      {\mem@debug\@ne{- Defining OCP list \mem@c}%
       % Define ocps, if necessary
       \def\mem@elt##1{%
         \@ifundefined{ocp-##1}% &lt;- Seleccionar el ocp correcto
           {\mem@debug\@ne{-- Loading OCP ##1}%
            \global\mem@ecs\ocp{ocp-##1}=##1\relax}%
           {}}%
       \csname\mem@use{lp-}{#3}\endcsname
       % Build the ocplist body and define ocplist
       \def\mem@elt##1{%
         \addbeforeocplist #2 %
         \@nameuse{ocp-##1}}%
       \edef\mem@c{%
         \global\mem@ecs\ocplist{\mem@a}%
         \csname\mem@use{lp-}{#3}\endcsname
         \nullocplist}%
       \mem@c}%
      {}%  
    % Build \ShowProcesses data
    \def\mem@eltpp##1{^^J(Mem) - ##1 = \csname\mem@use{pp-}{##1}\endcsname}%
    \def\mem@elttp##1{##1 : \csname\mem@use{tp-}{##1}\endcsname}%
    \def\mem@elt##1{##1 }%
    \mem@eafter\mem@toshow{^^J(Mem) #2 (#3): \csname\mem@use{lp-}{#3}\endcsname}%
    % Push the list
    \mem@eafter\mem@topush{\mem@ecs\pushocplist{\mem@a}}%
  \fi}

\def\SelectProcesses{%
  \mem@debug\@ne{====================}% 
%   \ifx\languagename\@empty
%     \mem@debug\@ne{Rebuilding processes for (no language)
%                    on input line \the\inputlineno}% 
%   \else
  \mem@debug\@ne{Rebuilding processes for \languagename\space
                 on input line \the\inputlineno}% 
%   \fi
  \edef\mem@toshow{%
   (Mem) ==========================================^^J%
   (Mem) \string\ShowProcesses\space(logical = physical : ocps)}%
  \let\mem@frompush\mem@topush
  \let\mem@topush\@empty
  \let\mem@pg\mem@selectprocs
  \mem@procgroups
  \ifx\mem@frompush\mem@topush
    \mem@debug\@ne{Skipping - currently active}%
  \else
    \clearocplists
    \mem@debug\@ne{Activating}%
    \mem@topush
  \fi}
%\ShowProcesses}
   % Ambos
\def\ShowProcesses{\typeout{\mem@toshow}}




% Font processing
% ~~~~~~~~~~~~~~~

% Let's modify \selectfont. Essentialy it selects a language using
% the current font enconding and then redefines what an encoding means.
%
% Automatic selection of font encoding based on fd files--if there
% is an fd file for some combination then select it (with certain
% preferences).  Hovever, it turns out that t1cmr exists but pointing to
% _another_ font, and that ot1omlgc points to an ut1 encoded font.

\expandafter\let\expandafter
  \mem@selectfont\csname selectfont \endcsname

\DeclareRobustCommand\selectfont{%
  \let\mem@fencoding\f@encoding
  \@ifundefined{\mem@@\languagename-\f@family-enc}%
    {\mem@eforeach{\csname\mem@@\languagename-encs\endcsname}{%
       \lowercase{\edef\mem@a{##1}}%
       \IfFileExists{\mem@a\f@family.fd}%
         {\@namedef{\mem@@\languagename-\f@family-enc}{##1}%
          \@ifundefined{\mem@@ T@##1}%
             {\global\@namedef{\mem@@ T@##1}{}%
              \@ifundefined{T@##1}{\global\@namedef{T@##1}{}}{}%
              \def\f@encoding{##1}%
              \setbox\z@\vbox\bgroup % dummy box
                \catcode`\\=0
                \catcode`\{=1
                \catcode`\}=2
                \catcode`\^^M=5
                \catcode`\ =10
                \catcode`\^^I=10
                \catcode`\%=14
                \input{\mem@a.ed}%
              \egroup}%
             {}%
	  \fontencoding{##1}%
	  \SetMemProcess{fontenc}{\csname\mem@@##1-process\endcsname}%
          \mem@lastfor}%
         {}}%
     \ifx\mem@forcmd\@gobble\else
%  	\PackageError{mem}%
%  	     {Unable to find a proper encoding for a font
% 	     family \f@family}%
%  	     {The list of encodings for that language [...]}%
      \fi}%
    {\fontencoding{\csname\mem@@\languagename-\f@family-enc\endcsname}%
     \edef\f@encoding{\csname\mem@@\languagename-\f@family-enc\endcsname}%
     \SetMemProcess{fontenc}{\csname\mem@@\f@encoding-process\endcsname}}%
  % Select new process only if the encoding has changed
  \ifx\mem@fencoding\f@encoding\else
    \SelectProcesses
  \fi  
  \mem@selectfont
  \begingroup  % ***** An input in an ocp is ignored? &lt;&lt;&lt;&lt;&lt; 
               % Sadly, there is a bug and it is.
    \nfss@catcodes
    \let\nfss@catcodes\relax
    \@ifundefined{TS1/\f@family/m/n}%
      {\InputIfFileExists{ts1\f@family.fd}{}{}}%
      {}%
  \endgroup}

% \..family are modified too keep track of the
% current family, so that if the script changes
% the family is still the same. To be fine tuned.

\DeclareRobustCommand\rmfamily
        {\not@math@alphabet\rmfamily\mathrm
         \let\mem@family\rmfamily
         \fontfamily\rmdefault\selectfont}
\DeclareRobustCommand\sffamily
        {\not@math@alphabet\sffamily\mathsf
         \let\mem@family\sffamily
         \fontfamily\sfdefault\selectfont}
\DeclareRobustCommand\ttfamily
        {\not@math@alphabet\ttfamily\mathtt
         \let\mem@family\ttfamily
         \fontfamily\ttdefault\selectfont}

\let\mem@family\rmfamily


% Properties
% ~~~~~~~~~~

\def\DeclareLanguageProperty{%
  \@ifstar{\mem@prop@s}{\mem@prop@x}}

\def\mem@prop@s#1{% Implicit #2
  \edef\mem@b{\zap@space#1 \@empty}%
  \expandafter\def\csname\mem@@prop\languagename-\mem@b\endcsname##1}

\def\mem@prop@x#1#2{%
  \edef\mem@b{\zap@space#1 \@empty}%
  \expandafter\def\csname\mem@@prop\languagename-\mem@b\endcsname{#2}}

% There are parameters depending on both the language and the font
% encoding.  However, they may not be known when the package is
% loaded.  They are set with \languageproperties, but I think that's
% not very rubust.
%
% Currently works as if it was in fact named \dialectproperties

\def\languageproperties#1#2{%
  \let\mem@savelang\languagename
  \def\languagename{#1}%
  \expandafter\edef\csname\mem@@#1-prlt\endcsname{\zap@space#2 \@empty}%
  \mem@eforeach{\zap@space#2 \@empty}{%
    \csname\mem@cmd{prop-}{#1}{##1}\endcsname}% %&lt;&lt;---remove???
  \edef\mem@b{#1}%
  \ifx\mem@savelang\languagename
    \ExecuteLanguageProperties{\zap@space#2 \@empty}%
    \mem@switchfont
  \fi
  \let\languagename\mem@savelang}

\def\ExecuteLanguageProperties#1{%
  \@ifundefined{\mem@@\languagename-prlt}%
    {\let\mem@a\@empty}%
    {\edef\mem@a{\csname\mem@@\languagename-prlt\endcsname,}}%
  \mem@eforeach{\mem@a#1}{%
    \def\mem@b{##1}%
    \ifx\mem@b\@empty\else
      \@ifundefined{\mem@use{prop-}{##1}}%
        {% Raise error if there is no =
         \expandafter\mem@executegen##1\\}%   ??Lo siguiente con \edef?
        {\csname\mem@use{prop-}{##1}\endcsname}%
    \fi}}

\def\mem@executegen#1=#2\\{%
  \csname\mem@use{prop-}{#1}\endcsname{#2}}

% Properties shared by all languages as generic tools.
% They are assigned to the ? language in the top of the
% tree. When executed, \languagename contains the actual
% name of the active language.

\def\languagename{?}

\DeclareLanguageProperty*{charset}{%
  \@namedef{\mem@@\languagename-cset}{#1}%
  \SetLanguageProcess{charenc}{#1}}

\DeclareLanguageProperty*{hyphenation}{%
  \def\mem@hyphenation{#1}}

\DeclareLanguageProperty*{fontencs}{%
  \mem@setencs\languagename{#1}}

\DeclareLanguageProperty*{rmfamily}{%
  \@namedef{\mem@@ font-\languagename-rmfamily}{#1}}

\DeclareLanguageProperty*{sffamily}{%
  \@namedef{\mem@@ font-\languagename-sffamily}{#1}}

\DeclareLanguageProperty*{ttfamily}{%
  \@namedef{\mem@@ font-\languagename-ttfamily}{#1}}

\AddMemProcess{font}{fontenc}

\AddLanguageProcess{charset}{charenc}
%\SetLanguageProcess{charenc}{\expandafter\noexpand\@nameuse{\mem@use{}{cset}}}
%\SetLanguageProcess{charenc}{isolat1}

% Scripts
% ~~~~~~~

\def\SetLanguageScript#1{%
  \mem@foreach{#1}{%
    \lowercase{\edef\mem@b{##1}}%
    \@ifundefined{\mem@@ script-##1}{\input{\mem@b.sd}}{}%
    \def\mem@a{##1}}%  script description
  \edef\mem@b{%
    \noexpand\DeclareLanguageCommand{\noexpand\mem@script}{processes}{\mem@a}}%
  \mem@b}

\def\DeclareScript#1{%
  \@namedef{\mem@@ script-#1}{}%
  \def\mem@script{#1}%
  \lowercase{\def\mem@b{#1}}%
  \expandafter\let\csname\mem@@ lang-#1\endcsname\mem@b}

\def\SetScriptDirection#1{%
  \expandafter\def\csname\mem@@\mem@script-dir\endcsname{#1}}

\def\mem@setencs#1#2{\@namedef{\mem@@#1-encs}{#2}}  

\def\DeclareScriptSymbol#1#2{%
  \let#1\relax
  \newcommand{#1}{\unichar{#2}}}

\def\DeclareScriptCommand#1{%
  \let#1\relax % Implicit #1#2 etc
  \newcommand{#1}}


\def\scriptproperties#1#2{%
  \mem@eforeach{\zap@space#2 \@empty}{%
    \mem@setfamily#1\\##1\\}%
  \long\def\mem@b{#1}% \long because \mem@script is \long!!
  \ifx\mem@b\mem@script\mem@switchfont\fi}

\def\mem@setfamily#1\\#2=#3\\{%
   \@namedef{\mem@@ font-#1-#2}{#3}}


% ==========================

\def\SetEncodingScript#1{}%

% \def\SetEncodingDirection#1{%
%   \global\@namedef{\mem@@\f@encoding-dir}{#1}}

\newcommand\SetEncodingProcess[2]{%
  \DeclareProcess{#1}{#2}%
  \SetMemProcess{fontenc}{#1}%
  \global\@namedef{\mem@@\f@encoding-process}{#1}}

\SetEncodingProcess{t1}{t1-dec,t1-rec,t1-com}
%\SelectProcesses

% Note the following does not switch the encoding name.
% In other words, symbols are incorporated as part of
% the main encoding and not as a separate encoding.
% The final decision about what font to use is left
% to the font encoding OCP. 
% To be fixed.

\def\SetSymbolEncodings#1{%
  \@ifundefined{\mem@@ T@##1}%
    {\global\@namedef{\mem@@ T@##1}{}%
     \@ifundefined{T@##1}{\global\@namedef{T@##1}{}}{}}
    {}}

% \let\mem@textcmd\DeclareTextCommand
% 
% \def\DeclareEncodingSymbol#1#2{%
%   \mem@textcmd{#1}{\f@encoding}{\unichar{#2}}}
% 
% \def\DeclareEncodingCommand#1{% Implicit #1#2 etc
%   \mem@textcmd{#1}{\f@encoding}}

% =============================

% Charsets
% ~~~~~~~~
%
% The escape char in the ASCII/Unicode charsets is used as
% a escape with several meanings (given by the second char).
% It is used by charset to unicode ocp's to enter a Unicode
% value directly without conversion.

{\catcode`\^^1b=11
\catcode`\^^00=11
\catcode`\^^01=11
\catcode`\^^02=11
\gdef\unichar#1{\mem@protected{^^1b^^00#1^^1b}\unichar{#1}}
\gdef\unitext#1{\mem@protected{^^1b^^01#1^^1b}\unitext{#1}}
\gdef\utftext#1{\mem@protected{^^1b^^02#1^^1b}\utftext{#1}}
\gdef\utfstring#1{\mem@protected{^^1b^^02#1^^1b}\utfstring{#1}}
}

\DeclareRobustCommand\utftext[1]{{%
  \ExecuteLanguageProperties{charset=utf8}%
  \SelectProcesses
  #1}}

% ====================

% onfss

\def\onfss@symenc{TS1}
\DeclareFontEncoding{\onfss@symenc}{}{}

\DeclareRobustCommand\UseMemTextSymbol[1]{%
  {[[#1]]\fontencoding{\onfss@symenc}\mem@selectfont\char#1 }}

\DeclareRobustCommand\UseMemTextSymbol[2]{%
  {\fontencoding{#1}\mem@selectfont\char#2 }}

% \setbox\z@\hbox{\rmfamily\UseMemTextSymbol{TS1}{167}%
%                 \sffamily\UseMemTextSymbol{TS1}{167}%
%                 \ttfamily\UseMemTextSymbol{TS1}{167}}

%================

% Package options

\let\PreLoadPatterns\@gobbletwo

\def\SetPatterns#1#2{%
  \expandafter\chardef
  \csname memh@#1\endcsname=#2\relax}

\def\LoadLanguage#1#2#3#4{%
   \DeclareOption{#1}{\mem@input{#1}{#2}{#3}{#4}}}

\def\mem@input#1#2#3#4{%
  \@ifundefined{languagelist}%
    {\edef\languagelist{#1}}%
    {\edef\languagelist{\languagelist,#1}}%
  \@ifundefined{memh@#1}%
    {\expandafter\let\csname memh@#1\expandafter\endcsname
       \csname memh@#3\endcsname%
     \PackageInfo{mem}%
       {#1 with #3 patterns\@gobble}}\@empty
  \@ifundefined{\mem@@?#1}%
    {\lowercase{\edef\mem@b{#2}}%
     \InputIfFileExists{#2.ld}%
       {}%
       {\mem@error{Missing language file}}}
    {}%   And make sure the right dialect is selected:
  \mem@setencs{#1}{#4}%
  \edef\languagename{#1}%
  \mem@ecs\def{\mem@@\languagename-isocode}{#2}}

\everyjob\expandafter{\the\everyjob\SetWeekDay}

\def\mem@process#1=#2\mem@process{%
  \@ifundefined{\mem@@ gopt-#1}%
    {\mem@error{Error}}
    {\@nameuse{\mem@@ gopt-#1}{#2}}}

\@namedef{\mem@@ gopt-charset}#1{%
  \SetMemProcess{charenc}{#1}%
  \@namedef{\mem@@?-cset}{#1}}

\SetMemProcess{charenc}{utf8}
\@namedef{\mem@@?-cset}{utf8}

\DeclareOption*{%
  \@expandtwoargs\in@{=}{\CurrentOption}%
  \ifin@
    \expandafter\mem@process\CurrentOption\mem@process
  \else
    \mem@error{Error}%\expandafter\mem@input\CurrentOption\mem@input%
  \fi}

\input{mem.cfg}

\def\mem@sel@opt{%
  \PackageInfo{mem}%
   {Selecting document language:\MessageBreak
      \languagename\@gobble}%
   \expandafter\languageset\expandafter*\expandafter
     {\languagename}%
   \bodydir\csname\mem@@\mem@script-dir\endcsname}

\ProcessOptions*

\mem@sel@opt

% Select the interface

\InputIfFileExists{\csname\mem@@\languagename-isocode\endcsname
                   \csname\mem@@?-cset\endcsname.id}{}{}

  % Implicit #2#3  
\def\UseMemAccent#1{\csname mem@accent@#1\endcsname}

% There are four kind of accents.
%
% t: Top accent is the usual accent, which
% can be combined with the well known diatop macro
% #2 is either c or l, if continues or it's the
% last accent; used only in t-

\def\mem@accent@t#1#2#3{% This is the well known diatop macro.
  \if#2c%
    \leavevmode
      \begingroup
      \setbox1=\hbox{{\accent#1{}}}%
      \setbox2=\hbox{{#3{}}}%
      \dimen0=\ifdim\wd1&gt;\wd2\wd1\else\wd2\fi
      \dimen1=\ht2\advance\dimen1by-1ex
      \setbox1=\hbox to1\dimen0{\hss\accent#1\hss}%
      \rlap{\raise1\dimen1\box1}%
      \hbox to1\dimen0{\hss#3\hss}%
    \endgroup
  \else
    \accent#1 #3%
  \fi}

% u: bot accent based on an accent, like \b

\def\mem@accent@u#1#2#3{% 9
   \hmode@bgroup
     \o@lign{\relax#3\crcr\hidewidth\sh@ft{29}%
     \vbox to.2ex{\hbox{\char#1}\vss}\hidewidth}%
   \egroup}

\let\mem@accent@a\mem@accent@u % to remove

% b: bot accent with an "underaccent" like \c

\def\mem@accent@b#1#2#3{% 11
   \leavevmode
   \setbox\z@\hbox{#3}%
   \ifdim\ht\z@=1ex
     \accent#1 #3%
   \else
     {\ooalign{\hidewidth\char#1\hidewidth
        \crcr\unhbox\z@}}%
   \fi}

% c: bot accent with an "underaccent" like \c

\let\mem@accent@c\mem@accent@b

% p: bot accent with a puntuaction point, like \d
	
\def\mem@accent@p#1#2#3{%
   \hmode@bgroup
     \o@lign{\relax#3\crcr\hidewidth\sh@ft{10}#1\hidewidth}%
   \egroup}

% k: an special case (task: to investigate) for \k

\def\mem@accent@k#1#2#3{%
   \oalign{\null#3\crcr\hidewidth\char#1}}

\def\UseMemUnichar#1{\char#1 }

% ====== Verbatim
% The following characters are used in ocp files to ensure their
% catcode is always the same even if in verbatim mode. See mtp2ocp
% for further details (it replaces \, {, }, etc. by the chars below).

\catcode"E000=0 % \
\catcode"E001=1 % {
\catcode"E002=2 % }
\catcode"E003=3 % $
\catcode"E004=4 % &amp;
\catcode"E005=5 % &lt;ret&gt;
\catcode"E006=6 % #
\catcode"E007=7 % ^
\catcode"E008=8 % _

% Special chars to the PUA. This is necessary because ocp's
% recatcode the chars.

\def\#{\unichar{"E123}}
\def\${\unichar{"E124}}
\def\%{\unichar{"E125}}
\def\&amp;{\unichar{"E126}}
\def\_{\unichar{"E15F}}

% =============== Math

\def\DeclareMathSymbol#1#2#3#4{%
  \expandafter\in@\csname sym#3\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
    \begingroup
      \if\relax\noexpand#1% is command?
        \edef\reserved@a{\noexpand\in@{\string\mathchar}{\meaning#1}}%
        \reserved@a
        \ifin@
          \expandafter\set@mathsymbol\csname sym#3\endcsname#1#2{#4}%
          \@font@info{Redeclaring math symbol \string#1}%
        \else
            \expandafter\ifx
            \csname\expandafter\@gobble\string#1\endcsname
            \relax
            \expandafter\set@mathsymbol\csname sym#3\endcsname#1#2{#4}%
          \else
            \@latex@error{Command `\string#1' already defined}\@eha
          \fi
        \fi
      \else
        \expandafter\set@mathchar\csname sym#3\endcsname#1#2{#4}%
      \fi
    \endgroup
  \else
    \@latex@error{Symbol font `#3' is not defined}\@eha
  \fi
}

\def\mem@setmath#1#2#3#4{%
  \count@\mathchar@type#3
  \multiply\count@256
  \advance\count@#1
  \multiply\count@65536
  \advance\count@#4
  \global#2\count@}

\def\set@mathchar#1#2{\mem@setmath{#1}{\omathcode`#2=}}
\def\set@mathsymbol#1#2{\mem@setmath{#1}{\omathchardef#2}}

\def\MemUnknownCharacter#1{%
  \vrule width .6em
  \PackageWarning{Mem}{Unknown character \number`#1\space}}

% The original definition of \do@noligs includes a \char and
% \char's has been always problematic in omega. Here is a
% redefinition which uses the actual char. 2005-12-08

\def\do@noligs#1{%
  \catcode`#1\active
  \begingroup
    \lccode`\~`#1\relax
    \lowercase{\endgroup
  \def~{\leavevmode\kern\z@\expandafter\@gobble\string#1}}}

\def\MemMoveOtherChar#1{\relax\expandafter\@gobble\string#1}

\endinput
%%
%% End of file `mem.sty'.
</pre></body></html>