% \iffalse meta-comment
%
%%
%% This is file 'copyedit.dtx'
%% ...........................
%%
%% (c) 2014,2015,
%%           CV Radhakrishnan <cvr@cvr.cc>, JWRA 34, Jagathy,
%%              Trivandrum 695014, India
%%           CV Rajagopal <cvr3@cvr.cc>, SRA 34C, Elipode,
%%              Vattiyoorkavu, Trivandrum 695013, India
%%           SK Venkatesan <skvenkat@tnq.co.in>, TNQ Books and Journals
%%              Pvt Ltd, Kottivakkam, Chennai 600041, India
%%           
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%   http://www.latex-project.org/lppl.txt
%%
%% The list of all files belonging to the 'copyedit' is
%% given in the file `manifest.txt'.
%% 
%
%<*driver|package>
% The version of expl3 required is tested as early as possible, as
% some really old versions do not define \ProvidesExplPackage.
\RequirePackage{expl3}[2014/07/20]
%<package>\@ifpackagelater{expl3}{2014/07/20}
%<package>  {}
%<package>  {%
%<package>    \PackageError{copyedit}{Support package l3kernel too old}
%<package>      {%
%<package>        Please install an up to date version of l3kernel\MessageBreak
%<package>        using your TeX package manager or from CTAN.\MessageBreak
%<package>        \MessageBreak
%<package>        Loading copyedit will abort!%
%<package>      }%
%<package>    \endinput
%<package>  }
\RequirePackage{acronym,l3str,l3keys2e,xparse}
%%%% $Id: copyedit.dtx,v 1.6 2015/07/21 07:27:11 cvr Exp cvr $
\GetIdInfo$Id: copyedit.dtx,v 1.6 2015-07-21 07:27:11 cvr Exp cvr $
  {TeX and Copyediting (CVR)}
%</driver|package>
%<*driver>
\documentclass[full]{l3doc}
\usepackage{xcolor}
\colorlet{vcolor}{magenta}
\usepackage{array}
\usepackage[lat=0]{copyedit}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% 
% \title{ \TeX{} and Copyediting }
%
% \author{  CV Radhakrishnan\thanks
%    { \textsc{jwra} 34, Jagathy, Trivandrum 695014, India, E-mail:
%    \href{mailto:cvr@cvr.cc}{\ttfamily<cvr@cvr.cc>} }, 
%    ~CV Rajagopal\thanks{\textsc{sra} 34c, Elipode, Trivandrum 695013,
%    India, E-mail: \href{mailto:cvr3@cvr.cc}
%    {\ttfamily<cvr3@cvr.cc>}}
%     ~and SK Venkatesan\thanks{\textsc{tnq b}ooks and Journals, Kottivakkam,
%     Chennai 600041, India, E-mail: \href{mailto:skvenkat@tnq.co.in}
%    {\ttfamily<skvenkat@tnq.co.in>}}
% }
%
% \date{Released \ExplFileDate}
%
% \maketitle
%
% \begin{documentation}
%
% \pkg{Copyedit} implements copyediting support for \LaTeX{}
% documents. Authors can enjoy the freedom of using, for example,
% using words with \textsc{us} or \textsc{uk} or Canadian or Australian
% spelling in a mixed way, yet, they can choose any one of the usage
% form for their entire document irrespective of kinds of spelling
% they have adopted. In the same fashion, the users can have the
% benefit of following features available in the package:
%
% \begin{enumerate}
% \item Localization --- British-American-Australian-Canadian
% \item Close-up, Hyphenation, and Spaced words
% \item Latin abbreviations
% \item Acronyms and Abbreviations
% \item Itemization, nonlocal lists and labels
% \item Parenthetical and serial commas
% \item Non-local tokenization in language through Abbreviations and
%   pronouns.
% \end{enumerate}
% 
% \section{Package Loading}
% 
% The \pkg{copyedit} package can be loaded with the command:
% \begin{verbatim}
%   \usepackage[<options>]{copyedit}
% \end{verbatim}
%
% \begin{function}{\ceset,\cesetup}
% \begin{syntax}
%   \cs{ceset} \Arg{options}\\
%   \cs{cesetup} \Arg{options}
% \end{syntax}
% There is a user-friendly function, namely, \cs{ceset} or
% \cs{cesetup} available which can be used anywhere in the document
% to change the options or behaviour of the package from that point
% onwards. The usage of the function is:
%
% The \meta{options} shall be provided as a comma separated list.
% \end{function}
%
% \section{Using the Features}
%
% \subsection{Localization --- British, American, Australian and Canadian}
%
%  \begin{function}{\definevariant}
%  The package provides a database of commonly used English language
%  words in all the above four variant spelling. One can add new
%  entries to the list with the command:
%  \begin{syntax}
%    \cs{definevariant}\Arg{uk}\Arg{us}\Arg{au}\Arg{ca}
%  \end{syntax}
%  The variants, \meta{uk}, \meta{us}, \meta{au} and \meta{ca} denote
%  British, American, Australian and Canadian spelling respectively.
% \end{function}
%
% \begin{function}{\vara}
%  \begin{syntax}
%   \cs{vara} \Arg{variant}
%  \end{syntax}
%  In the document, one can use the macro \cs{vara}\marg{variant}.
%  The user is free to use a combination of words of various spelling,
%  but output will totally be dependent on the option of locale chosen
%  for the document.  For the sake of distinction and to prove our
%  point, let us assume that the word \meta{color} has the following
%  four different spelling in four different locale:
% \end{function}
% \begin{enumerate}[itemsep=0pt]
%  \item UK: colour
%  \item US: color
%  \item AU: COLOUR
%  \item CA: COLOR
%  \end{enumerate}
%  By using the four words in the following manner:
%  \begin{verbatim}
%    \vara{colour} \vara{color} \vara{COLOUR} \vara{COLOR}
%  \end{verbatim}
%  and by using various language option with different values for the
%  option \marg{lang}, we can switch across different languages for
%  all four words, no matter, whatever locate spelling one has adopted
%  for the word in the document instance.
%  \begin{enumerate}[itemsep=0pt]
%  \item |lang=uk| $\longrightarrow$ colour colour colour colour
%  \item |lang=us| $\longrightarrow$ color color color color
%  \item \dots 
% \end{enumerate}
%
% \begin{function}{starred \vara}
% If for any reason, the user chooses to retain the word as it is then
% it is possible by using the starred version of the macro:
% \begin{syntax}
%   \cs{vara*}\Arg{word}
% \end{syntax}
% \end{function}
% 
% \subsection{Close-up, Hyphenation, Spaced Words}
%
% \begin{function}{\hyp,\closeup,\sword}
% \begin{syntax}
%   \cs{hyp}\Arg{word}\Arg{word}\\
%   \cs{closeup}\Arg{word}\Arg{word}\\
%   \cs{sword}\Arg{word}\Arg{word}
% \end{syntax}
% \end{function}
% \noindent There are three commands that make the above possible:
%  \begin{enumerate}[itemsep=0pt]
%  \item |\hyp{anti}{body}| $\longrightarrow$ anti-body (hyphenate)
%  \item |\closeup{anti}{body}| $\longrightarrow$ antibody (close up)
%  \item |\sword{Civil}{War}| $\longrightarrow$ Civil War (space our)
%  \end{enumerate}
%  
% \subsection{Latin Abbreviation}
%
% \begin{function}{\definelat,\lat}
%  \begin{syntax}
%    \cs{definelat} \Arg{abbr} \Arg{abbr without dots} \Arg{English form}\\
%    \cs{lat} \Arg{abbr}
%  \end{syntax}
% \end{function}
% \noindent Latin abbreviations can be used in different ways. The
% option |lat=0| will keep the Latin abbreviation as such in form in
% italic shape. |abbr=italic| will make the abbreviation italicized
% (which is also default). |abbr=rm| will make it upshape.  |lat=1|
% will take away the periods in the abbreviated Latin forms while
% |lat=2| will replace the abbreviation with its English language
% equivalents.
%
% The package comes with a default list of abbreviations. Users shall
% use the command \cs{lat}\Arg{abbr} to invoke the desired format of
% abbeviation in the document instance.
%
% 
% \subsection{Acronyms}
%
% \begin{function}{\newacro,\ac}
%  \begin{syntax}
%   \cs{newacro} \Arg{short form} \Arg{long form}\\
%   \cs{ac} \Arg{short form}
% \end{syntax}
% \end{function}
% \noindent The highly aclaimed package, namely, \pkg{acronym} has
% been made use of to achieve the extensive features available
% therein. Kindly refer to its documentation for getting an
% understanding of the usage.
%
% \subsection{Itemization and Non-local Lists}
%
% A list environment, namely, |eitem| has been defined which can be
% used for a variety of purposes as enlisted below by changing its
% options.
% 
% \begin{flushleft}
% \begin{tabular}{@{}ll}
% \bfseries Option & \bfseries Rendering\\[3pt]
% |eitem=0|  & normal list: Firstly, Secondly, Thirdly, \dots\\
% |eitem=1|  & normal list: First, Second, Third, \dots\\
% |eitem=2|  & enumerated list: 1, 2, 3, \dots\\
% |eitem=3|  & itemized bulletted list\\
% |eitem=4|  & para list: Firstly, secondly, thirdly, \dots\\
% |eitem=5|  & para list: First, second, third, \dots\\
% \end{tabular}
% \end{flushleft}
%
% In the para list forms, each item will be separated by semicolon
% (|;|) and the penultimate item will be connected to the last one by
% the `|and|' automatically.
%
% \begin{function}{\elist}
% \begin{syntax}
%  \cs{elist} \Arg{comma separated list}
% \end{syntax}
% \end{function}
% \noindent
% There is also a convenient command, ``|elist|'' that helps to format
% a comma separated list in a proper way with proper spacing.  For
% example,
% \begin{verbatim}
%   \elist{warblers,tits,wrens,hummingbirds}
%   \elist{warblers , tits, wrens ,hummingbirds}
% \end{verbatim}
% will be formatted in the proper way with right spacing and correct
% punctuation:
% \begin{quote}\color{vcolor}
%   warblers, tits, wrens and hummingbirds
% \end{quote}
%
% \subsection{Parenthetical and Serial Comma}
%
% \begin{function}{\pc}
%  \begin{syntax}
%   \cs{pc} \Arg{text to be included}
% \end{syntax}  
% \end{function}
% \noindent This is accomplished with the command \cs{pc} and the text
% to be distiguished shall be its argument. Different values for
% option with the same name, |pc|, provide different functionality as
% detailed below:
% 
% \begin{flushleft}
% \begin{tabular}{@{}ll}
% \bfseries Option & \bfseries Rendering\\[3pt]
% |pc=0|  & argument is separated by parenthetical commas\\
% |pc=1|  & separated by parenthesis\\
% |pc=2|  & separated by emdashes\\
% |pc=3|  & formatted as a footnote \\
% |pc=4|  & formatted as a sidenote (marginpar)
% \end{tabular}
% \end{flushleft}
%
% \subsection{Non-local Tokenization}
%
% \begin{function}{\definetoken,\tkn} 
%  \begin{syntax}
%   \cs{definetoken} \Arg{label} \Arg{full tokens} \Arg{less tokens}
%   \Arg{least tokens} \\
%   \cs{tkn} \Arg{label}
% \end{syntax}  
% \end{function}
% \noindent A sequence of minimization operation can be brought out by
% first defining the tokens to be minimized and then using the same
% consecutively will typeset the tokens in differently and minimized
% manner each time it is called.  We define a token as:
% \begin{verbatim}
%   \definetoken{mango}{His Holyness, the Prince of Mangoistan}
%               {The Prince of Mangoistan}{He}
% \end{verbatim}
% will have different output as given below:
% 
% \begin{flushleft}
% \begin{tabular}{@{}ll}
% \bfseries Command & \bfseries Rendering\\[3pt]
% First instance: \cs{tkn}|{mango}| & His Holyness, the Prince of Mangoistan\\
% Second: \cs{tkn}|{mango}|& The Prince of Mangoistan\\
% Third: \cs{tkn}|{mango}|& He \\
% Fourth: \cs{tkn}|{mango}|& He
% \end{tabular}
% \end{flushleft}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{copyedit} implementation}
%
%    \begin{macrocode}
%<*initex|package>
%    \end{macrocode}
%
%    \begin{macrocode}
%<@@=cedt>
%    \end{macrocode}
%
%    \begin{macrocode}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
%    \end{macrocode}
%
%\begin{macro}{\@@_load_check:n}
% There are also a number of packages that are incompatible with
% \pkg{copyedit}. These are all checked for next.  Some of the
% incompatible packages will not raise an error if loaded after
% \pkg{copyedit}.  So a test is made at the beginning of the
% document as well. The message for this may be needed immediately, so
% it is created here not with the other messages.
%    \begin{macrocode}
\msg_new:nnnn { copyedit } { incompatible-package }
  { Package~'#1'~incompatible. }
  { The~#1~package~and~copyedit~are~incompatible. }
\cs_new_protected:Npn \@@_load_check:n #1
  {
    \group_begin:
    \@ifpackageloaded {#1}
    { \msg_error:nnx { copyedit } { incompatible-package } {#1} }
    { }
    \group_end:
  }
\clist_map_function:nN
  { Array , MyPackage }
  \@@_load_check:n
\AtBeginDocument {
  \clist_map_function:nN { Array , MyPackage }
    \@@_load_check:n
  }
%    \end{macrocode}
%\end{macro}
%
% \begin{macro}{\wrAux}
%    \begin{macrocode}
\NewDocumentCommand \wrAux { m }    
   { \iow_now:Nx \@auxout { #1 } }
%    \end{macrocode}
% A simple scratch macro to write out stuff to the auxiliary file.
% There should be some elegant way or macro for the job.
%
% \end{macro}
%
% \begin{macro}{\l@@_lat_int,\l@@_pc_int,\l@@_lang_int,\l@@_eitem_int}
% Needed counters and functions to use the counters are defined in advance.
%    \begin{macrocode}
\int_new:N \l@@_lat_int 
\NewDocumentCommand \setlat { m }
  { \int_set:Nn \l@@_lat_int { #1 } }

\int_new:N \l@@_pc_int 
\NewDocumentCommand \setpc { m }
  { \int_set:Nn \l@@_pc_int { #1 } }

\int_new:N \l@@_lang_int          
\NewDocumentCommand \setlang { m }
  { \int_set:Nn \l@@_lang_int { #1 } }

\int_new:N \l@@_eitem_int          
\NewDocumentCommand \seteitem { m }
  { \int_set:Nn \l@@_eitem_int { #1 } }
\int_new:N \l@@_abbr_int

\NewDocumentCommand \setabbr { m }
  {
    \str_if_eq:nnTF { #1 } { italic }
      { \int_set:Nn \l@@_abbr_int { 0 } }
      { \int_set:Nn \l@@_abbr_int { 1 } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_lang_check:n}
%
% Define a function to check language code
% and set the language numeric counter.
% 
%    \begin{macrocode}    
\cs_new_protected:Npn \@@_lang_check:n #1
  {
    \str_if_eq:nnT { #1 } { uk } { \setlang { 0 } }
    \str_if_eq:nnT { #1 } { us } { \setlang { 1 } }
    \str_if_eq:nnT { #1 } { ca } { \setlang { 2 } }
    \str_if_eq:nnT { #1 } { au } { \setlang { 3 } }
  }
%    \end{macrocode}
%
% \end{macro}
% 
% \begin{macro}{}
%
% Define key-values as per expl3 syntax:
%    \begin{macrocode}
\keys_define:nn { copyedit }
  {
    lang        .code:n     = \@@_lang_check:n { #1 } ,
    lat         .code:n     = \setlat { #1 }              ,
    abbr        .code:n     = \setabbr{ #1 }              ,
    pc          .code:n     = \setpc { #1 }               ,
    draft       .bool_set:N = \l@@_draft_bool          ,
    last        .bool_set:N = \l@@_last_bool           ,
    eitem       .code:n     = \seteitem { #1 }            ,
    key-unknown .code:n     =
    {
      \msg_error:nnx { copyedit } { unknown-option }
       { \exp_not:V \l_keys_key_tl }
    }
  }
%    \end{macrocode}
%
% Set key-values and process key-value options.
%
%    \begin{macrocode}
\keys_set:nn { copyedit }
  {
    lang      = { uk }     ,
    lat       = { 0 }      ,
    abbr      = { italic } ,
    pc        = { 0 }      ,
    draft     = { false }  ,
    last      = { false }  ,
    eitem     = { 0 }      ,
  }

\ProcessKeysOptions { copyedit }
%    \end{macrocode}
% 
% \end{macro}
%
% \begin{macro}{\ceset,\cesetup}
%
%  A macro, \cs{ceset} has been  defined to invoke any option at any
%  point in the document instance. A variant, \cs{cesetup}, has also
%  been defined.
%
%    \begin{macrocode}
\NewDocumentCommand \ceset { m }
  {
    \keys_set:nn { copyedit } { #1 }
    \@@_lang_check:n { \l@@_lang_tl }
  }
\cs_set_eq:NN \cesetup \ceset
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\switchvariant,\definevariant,\vara}
%  \cs{swtchvariant} is an internal function that will help to switch
%  between different locale as per the language option chosen.
%  \cs{definevariant} is the one for defining different locale and
%  \cs{vara} is the user level command for using in document
%  instance. 
%
%    \begin{macrocode}
\NewDocumentCommand \switchvariant { m m m m }
   {
     \int_case:nn { \l@@_lang_int }
     {
       { 0 } { #1 }
       { 1 } { #2 }
       { 2 } { #3 }
       { 3 } { #4 }
     }
   }
 
\NewDocumentCommand \definevariant { m m m m }
   {
     \tl_set:cn { g_vara_#1_tl }
         { \switchvariant { #1 } { #2 } { #3 } { #4 } }
     \tl_set:cn { g_vara_#2_tl }
         { \switchvariant { #1 } { #2 } { #3 } { #4 } }
     \tl_set:cn { g_vara_#3_tl }
         { \switchvariant { #1 } { #2 } { #3 } { #4 } }
     \tl_set:cn { g_vara_#4_tl }
         { \switchvariant { #1 } { #2 } { #3 } { #4 } }
    }

\DeclareDocumentCommand \vara { s m } 
   {
     \IfBooleanTF {#1}
     { #2 }
     { \normalvara {#2} }
   }

\NewDocumentCommand \normalvara { m }
   {
     \use:c { g_vara_#1_tl }
   }
%    \end{macrocode}
% 
% \end{macro}
%
% \begin{macro}{\hyp,\closeup,sword}
% 
% \cs{hyp}, \cs{closeup} and \cs{sword} are three simple macros to
% hyphenate, close up and separate two words respectively.
%     \begin{macrocode}
\NewDocumentCommand \hyp { m m } { #1-#2 }
\NewDocumentCommand \closeup { m m } { #1#2 }  
\NewDocumentCommand \sword { m m } { #1~#2 }
%    \end{macrocode}
% \end{macro} 
% 
%
%\begin{macro}{\definelat,\lat}
% 
% Latin abbreviation and its variant forms can be brought in by these
% macros. 
%    \begin{macrocode}
\NewDocumentCommand \definelat { m m m }
  {
    \tl_set:cn { g_@@_lat_#1_tl }
    {
      \group_begin:
      \int_case:nn { \l@@_abbr_int}
      {
        { 0 } { \itshape }
        { 1 } { \upshape }
      }
      \int_case:nn { \l@@_lat_int }
      {
        { 0 } { #1 }
        { 1 } { #2 }
        { 2 } { #3 }
      }
      \group_end:  
    } 
  }

\NewDocumentCommand \lat { m } { \use:c { g_@@_lat_#1_tl } }
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\pc,\elist}
%
% Parenthetical comma (pc) and its variants are chosen with this macro
% in combination with different options.
%    \begin{macrocode}
\NewDocumentCommand \pc { m }
  {
    \int_case:nn { \l@@_pc_int }
    {
      { 0 } { \unskip,~#1,~ }
      { 1 } { (#1) }
      { 2 } { ---~#1~--- }
      { 3 } { \unskip\footnote{#1} }
      { 4 } { \marginpar{ \footnotesize\raggedright#1} }
    }
  }
\clist_new:N \l@@_clist
\NewDocumentCommand \elist { m }
  {
    \clist_set:Nn \l@@_clist { #1 }
    \clist_use:Nnnn \l@@_clist { ~and~ } { ,~ } { ~and~ }
  }
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\definetoken,\tkn,\Token}
%
% Non-local tokenization
%
%    \begin{macrocode}
\NewDocumentCommand \definetoken { m m m m }
  {
    \tl_gset:cn { #1num } { 0 }
    \tl_gset:cn { g_toks_#1_0_tl } { #2 \tl_gset:cn { #1num } { 1 } }
    \tl_gset:cn { g_toks_#1_1_tl } { #3 \tl_gset:cn { #1num } { 2 } }
    \tl_gset:cn { g_toks_#1_2_tl } { #4 \tl_gset:cn { #1num } { 2 } }
  }
\NewDocumentCommand \tkn { m }
  { \use:c { g_toks_#1_\use:c{#1num}_tl } }  
\cs_set_eq:NN \Token \tkn 
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{eitem}
%   \env{eitem} is defined to switch between non-local list of
%   different types. We make use of the package \pkg{enumitem} for
%   this purpose.
%
%    \begin{macrocode}
\RequirePackage{enumitem}
\chardef\thre@=3
\newenvironment{enumerate*}[1][]%
     {\@nameuse{enit@enumerate*}\enitdp@enumerate{enum}\thre@{#1}}
     {\@nameuse{enit@endenumerate*}}
%    \end{macrocode}
%
% A few macros like, \cs{lastlabel}, \cs{mysep}, \cs{myseplast},
% \cs{elistcnt}, \cs{LastItem} are defined to make the job easier. 
%
%    \begin{macrocode}
\int_new:N \l@@_elistcnt_int
\NewDocumentCommand \lastlabel { } { \tex_xdef:D\@itemlabel{Lastly}}
\NewDocumentCommand \mysep { } { ;\hskip .5em plus .1em minus .1em  }
\NewDocumentCommand \myseplast { } {\space and \space  }
\NewDocumentCommand \elistcnt { } { \int_use:N \l@@_elistcnt_int }
\NewDocumentCommand \LastItem { m m }
   { \tl_gset:cn { l@@_tmpa_#1_tl } { #2 } }
%    \end{macrocode}
%
% \begin{macro}{\checklast}
% \cs{checklast} is the macro that finds the last item number and
% substitutes with |Last| or |Lastly| depending upon the option
% chosen. 
% 
%    \begin{macrocode}
\NewDocumentCommand \checklast { m }
  {
    \tl_if_exist:cTF { l@@_tmpa_ \elistcnt _tl }
      { \int_set:Nn \l_tmpa_int { \use:c{ l@@_tmpa_\elistcnt _tl }} }
      { \int_set:Nn \l_tmpa_int { 0 } }
    \int_set:Nn \l_tmpb_int { \the\c@enumi }                               
    \int_compare:nNnTF { \l_tmpa_int } = { \l_tmpb_int }
         {
           \bool_if:NTF \l@@_last_bool
           {
             \int_case:nn { \l@@_eitem_int }
             {
               { 0 } { Lastly, }
               { 1 } { Last, }
               { 4 } { lastly, }
               { 5 } { last, }
             }
           }
           { #1 }
         }
         { #1 }
  }
%    \end{macrocode}
% \end{macro}
%
% Smallish set up changes are made to the \pkg{enumitem} to suit the
% requirements.
%
% \begin{macro}{\ctext,\@ctext,\ltext,\@ltext,\paratext,\@paractext,\paraltext,\@paraltext}
%
% These macros act as variables to hold textual values for each item number.
%
%    \begin{macrocode}
\makeatletter
\def\ctext#1{\expandafter\@ctext\csname c@#1\endcsname}
\def\@ctext#1{\ifcase#1\or \checklast{First,}\or
  \checklast{Second,}\or \checklast{Third,}\or
  \checklast{Fourth,}\or \checklast{Fifth,}\or 
  \checklast{Sixth,}\or \checklast{Seventh,}\or
  \checklast{Eigth,}\or \checklast{Nineth,}\or
  \checklast{Tenth,}\fi}
\AddEnumerateCounter{\ctext}{\@ctext}{Second,}

\def\ltext#1{\expandafter\@ltext\csname c@#1\endcsname}
\def\@ltext#1{\ifcase#1\or \checklast{Firstly,}\or
  \checklast{Secondly,}\or \checklast{Thirdly,}\or
  \checklast{Fourthly,}\or \checklast{Fifthly,}\or 
  \checklast{Sixthly,}\or \checklast{Seventhly,}\or
  \checklast{Eigthly,}\or \checklast{Ninethly,}\or
  \checklast{Tenthly,}\fi}
\AddEnumerateCounter{\ltext}{\@ltext}{Secondly,}

\def\paractext#1{\expandafter\@paractext\csname c@#1\endcsname}
\def\@paractext#1{\ifcase#1\or \checklast{First,}\or
  \checklast{second,}\or \checklast{third,}\or
  \checklast{fourth,}\or \checklast{fifth,}\or 
  \checklast{sixth,}\or \checklast{seventh,}\or
  \checklast{eigth,}\or \checklast{nineth,}\or
  \checklast{tenth,}\fi}
\AddEnumerateCounter{\paractext}{\@paractext}{second,}

\def\paraltext#1{\expandafter\@paraltext\csname c@#1\endcsname}
\def\@paraltext#1{\ifcase#1\or \checklast{Firstly,}\or
  \checklast{secondly,}\or \checklast{thirdly,}\or
  \checklast{fourthly,}\or \checklast{fifthly,}\or 
  \checklast{sixthly,}\or \checklast{seventhly,}\or
  \checklast{eigthly,}\or \checklast{ninethly,}\or
  \checklast{tenthly,}\fi}
\AddEnumerateCounter{\paraltext}{\@paraltext}{secondly,}
%    \end{macrocode}
% \end{macro}
%
% At last \env{eitem} has been defined.
%
%    \begin{macrocode}
\NewDocumentEnvironment { eitem } { }
   {
     \int_gincr:N \l@@_elistcnt_int
     \int_case:nn { \l@@_eitem_int }
     {
       { 0 } { \begin{enumerate}
               [label=\ltext*,align=left,itemjoin=\mysep,itemjoin*=\myseplast] }
       { 1 } { \begin{enumerate}
               [label=\ctext*,align=left,itemjoin=\mysep,itemjoin*=\myseplast] }
       { 2 } { \begin{enumerate}[label=\arabic*.] }
       { 3 } { \begin{enumerate}[label=\textbullet] }
       { 4 } { \begin{enumerate*}
               [label=\paraltext*,itemjoin=\mysep,itemjoin*=\myseplast] }
       { 5 } { \begin{enumerate*}
               [label=\paractext*,itemjoin=\mysep,itemjoin*=\myseplast] }
      }
    }
    {
      \wrAux { \token_to_str:N \LastItem
        { \int_use:N \l@@_elistcnt_int } {\the\c@enumi} }
      \int_case:nn { \l@@_eitem_int }
     {
       { 0 } { \end{enumerate} }
       { 1 } { \end{enumerate} }
       { 2 } { \end{enumerate} } 
       { 3 } { \end{enumerate} }
       { 4 } { \end{enumerate*} } 
       { 5 } { \end{enumerate*} }
     }
   }
%
%    \end{macrocode}
% \end{environment}
%
%
%
%
%    \begin{macrocode}
%</initex|package>
%    \end{macrocode}
%%
% \end{implementation}
% 
% \PrintIndex
%
% \endinput