1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757
|
% \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
|