| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% |
| 4 |
%% This is file 'copyedit.dtx' |
| 5 |
%% ........................... |
| 6 |
%% |
| 7 |
%% (c) 2014,2015, |
| 8 |
%% CV Radhakrishnan <[email protected]>, JWRA 34, Jagathy, |
| 9 |
%% Trivandrum 695014, India |
| 10 |
%% CV Rajagopal <[email protected]>, SRA 34C, Elipode, |
| 11 |
%% Vattiyoorkavu, Trivandrum 695013, India |
| 12 |
%% SK Venkatesan <[email protected]>, TNQ Books and Journals |
| 13 |
%% Pvt Ltd, Kottivakkam, Chennai 600041, India |
| 14 |
%% |
| 15 |
%% It may be distributed and/or modified under the conditions of the |
| 16 |
%% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 17 |
%% license or (at your option) any later version. The latest version |
| 18 |
%% of this license is in the file |
| 19 |
%% |
| 20 |
%% http://www.latex-project.org/lppl.txt |
| 21 |
%% |
| 22 |
%% The list of all files belonging to the 'copyedit' is |
| 23 |
%% given in the file `manifest.txt'. |
| 24 |
%% |
| 25 |
% |
| 26 |
%<*driver|package> |
| 27 |
% The version of expl3 required is tested as early as possible, as |
| 28 |
% some really old versions do not define \ProvidesExplPackage. |
| 29 |
\RequirePackage{expl3}[2014/07/20] |
| 30 |
%<package>\@ifpackagelater{expl3}{2014/07/20} |
| 31 |
%<package> {} |
| 32 |
%<package> {% |
| 33 |
%<package> \PackageError{copyedit}{Support package l3kernel too old} |
| 34 |
%<package> {% |
| 35 |
%<package> Please install an up to date version of l3kernel\MessageBreak |
| 36 |
%<package> using your TeX package manager or from CTAN.\MessageBreak |
| 37 |
%<package> \MessageBreak |
| 38 |
%<package> Loading copyedit will abort!% |
| 39 |
%<package> }% |
| 40 |
%<package> \endinput |
| 41 |
%<package> } |
| 42 |
\RequirePackage{acronym,l3str,l3keys2e,xparse} |
| 43 |
%%%% $Id: copyedit.dtx,v 1.6 2015/07/21 07:27:11 cvr Exp cvr $ |
| 44 |
\GetIdInfo$Id: copyedit.dtx,v 1.6 2015-07-21 07:27:11 cvr Exp cvr $ |
| 45 |
{TeX and Copyediting (CVR)} |
| 46 |
%</driver|package> |
| 47 |
%<*driver> |
| 48 |
\documentclass[full]{l3doc} |
| 49 |
\usepackage{xcolor} |
| 50 |
\colorlet{vcolor}{magenta} |
| 51 |
\usepackage{array} |
| 52 |
\usepackage[lat=0]{copyedit} |
| 53 |
\begin{document} |
| 54 |
\DocInput{\jobname.dtx} |
| 55 |
\end{document} |
| 56 |
%</driver> |
| 57 |
% \fi |
| 58 |
% |
| 59 |
% \title{ \TeX{} and Copyediting } |
| 60 |
% |
| 61 |
% \author{ CV Radhakrishnan\thanks |
| 62 |
% { \textsc{jwra} 34, Jagathy, Trivandrum 695014, India, E-mail: |
| 63 |
% \href{mailto:[email protected]}{\ttfamily<[email protected]>} }, |
| 64 |
% ~CV Rajagopal\thanks{\textsc{sra} 34c, Elipode, Trivandrum 695013, |
| 65 |
% India, E-mail: \href{mailto:[email protected]} |
| 66 |
% {\ttfamily<[email protected]>}} |
| 67 |
% ~and SK Venkatesan\thanks{\textsc{tnq b}ooks and Journals, Kottivakkam, |
| 68 |
% Chennai 600041, India, E-mail: \href{mailto:[email protected]} |
| 69 |
% {\ttfamily<[email protected]>}} |
| 70 |
% } |
| 71 |
% |
| 72 |
% \date{Released \ExplFileDate} |
| 73 |
% |
| 74 |
% \maketitle |
| 75 |
% |
| 76 |
% \begin{documentation} |
| 77 |
% |
| 78 |
% \pkg{Copyedit} implements copyediting support for \LaTeX{} |
| 79 |
% documents. Authors can enjoy the freedom of using, for example, |
| 80 |
% using words with \textsc{us} or \textsc{uk} or Canadian or Australian |
| 81 |
% spelling in a mixed way, yet, they can choose any one of the usage |
| 82 |
% form for their entire document irrespective of kinds of spelling |
| 83 |
% they have adopted. In the same fashion, the users can have the |
| 84 |
% benefit of following features available in the package: |
| 85 |
% |
| 86 |
% \begin{enumerate} |
| 87 |
% \item Localization --- British-American-Australian-Canadian |
| 88 |
% \item Close-up, Hyphenation, and Spaced words |
| 89 |
% \item Latin abbreviations |
| 90 |
% \item Acronyms and Abbreviations |
| 91 |
% \item Itemization, nonlocal lists and labels |
| 92 |
% \item Parenthetical and serial commas |
| 93 |
% \item Non-local tokenization in language through Abbreviations and |
| 94 |
% pronouns. |
| 95 |
% \end{enumerate} |
| 96 |
% |
| 97 |
% \section{Package Loading} |
| 98 |
% |
| 99 |
% The \pkg{copyedit} package can be loaded with the command: |
| 100 |
% \begin{verbatim} |
| 101 |
% \usepackage[<options>]{copyedit} |
| 102 |
% \end{verbatim} |
| 103 |
% |
| 104 |
% \begin{function}{\ceset,\cesetup} |
| 105 |
% \begin{syntax} |
| 106 |
% \cs{ceset} \Arg{options}\\ |
| 107 |
% \cs{cesetup} \Arg{options} |
| 108 |
% \end{syntax} |
| 109 |
% There is a user-friendly function, namely, \cs{ceset} or |
| 110 |
% \cs{cesetup} available which can be used anywhere in the document |
| 111 |
% to change the options or behaviour of the package from that point |
| 112 |
% onwards. The usage of the function is: |
| 113 |
% |
| 114 |
% The \meta{options} shall be provided as a comma separated list. |
| 115 |
% \end{function} |
| 116 |
% |
| 117 |
% \section{Using the Features} |
| 118 |
% |
| 119 |
% \subsection{Localization --- British, American, Australian and Canadian} |
| 120 |
% |
| 121 |
% \begin{function}{\definevariant} |
| 122 |
% The package provides a database of commonly used English language |
| 123 |
% words in all the above four variant spelling. One can add new |
| 124 |
% entries to the list with the command: |
| 125 |
% \begin{syntax} |
| 126 |
% \cs{definevariant}\Arg{uk}\Arg{us}\Arg{au}\Arg{ca} |
| 127 |
% \end{syntax} |
| 128 |
% The variants, \meta{uk}, \meta{us}, \meta{au} and \meta{ca} denote |
| 129 |
% British, American, Australian and Canadian spelling respectively. |
| 130 |
% \end{function} |
| 131 |
% |
| 132 |
% \begin{function}{\vara} |
| 133 |
% \begin{syntax} |
| 134 |
% \cs{vara} \Arg{variant} |
| 135 |
% \end{syntax} |
| 136 |
% In the document, one can use the macro \cs{vara}\marg{variant}. |
| 137 |
% The user is free to use a combination of words of various spelling, |
| 138 |
% but output will totally be dependent on the option of locale chosen |
| 139 |
% for the document. For the sake of distinction and to prove our |
| 140 |
% point, let us assume that the word \meta{color} has the following |
| 141 |
% four different spelling in four different locale: |
| 142 |
% \end{function} |
| 143 |
% \begin{enumerate}[itemsep=0pt] |
| 144 |
% \item UK: colour |
| 145 |
% \item US: color |
| 146 |
% \item AU: COLOUR |
| 147 |
% \item CA: COLOR |
| 148 |
% \end{enumerate} |
| 149 |
% By using the four words in the following manner: |
| 150 |
% \begin{verbatim} |
| 151 |
% \vara{colour} \vara{color} \vara{COLOUR} \vara{COLOR} |
| 152 |
% \end{verbatim} |
| 153 |
% and by using various language option with different values for the |
| 154 |
% option \marg{lang}, we can switch across different languages for |
| 155 |
% all four words, no matter, whatever locate spelling one has adopted |
| 156 |
% for the word in the document instance. |
| 157 |
% \begin{enumerate}[itemsep=0pt] |
| 158 |
% \item |lang=uk| $\longrightarrow$ colour colour colour colour |
| 159 |
% \item |lang=us| $\longrightarrow$ color color color color |
| 160 |
% \item \dots |
| 161 |
% \end{enumerate} |
| 162 |
% |
| 163 |
% \begin{function}{starred \vara} |
| 164 |
% If for any reason, the user chooses to retain the word as it is then |
| 165 |
% it is possible by using the starred version of the macro: |
| 166 |
% \begin{syntax} |
| 167 |
% \cs{vara*}\Arg{word} |
| 168 |
% \end{syntax} |
| 169 |
% \end{function} |
| 170 |
% |
| 171 |
% \subsection{Close-up, Hyphenation, Spaced Words} |
| 172 |
% |
| 173 |
% \begin{function}{\hyp,\closeup,\sword} |
| 174 |
% \begin{syntax} |
| 175 |
% \cs{hyp}\Arg{word}\Arg{word}\\ |
| 176 |
% \cs{closeup}\Arg{word}\Arg{word}\\ |
| 177 |
% \cs{sword}\Arg{word}\Arg{word} |
| 178 |
% \end{syntax} |
| 179 |
% \end{function} |
| 180 |
% \noindent There are three commands that make the above possible: |
| 181 |
% \begin{enumerate}[itemsep=0pt] |
| 182 |
% \item |\hyp{anti}{body}| $\longrightarrow$ anti-body (hyphenate) |
| 183 |
% \item |\closeup{anti}{body}| $\longrightarrow$ antibody (close up) |
| 184 |
% \item |\sword{Civil}{War}| $\longrightarrow$ Civil War (space our) |
| 185 |
% \end{enumerate} |
| 186 |
% |
| 187 |
% \subsection{Latin Abbreviation} |
| 188 |
% |
| 189 |
% \begin{function}{\definelat,\lat} |
| 190 |
% \begin{syntax} |
| 191 |
% \cs{definelat} \Arg{abbr} \Arg{abbr without dots} \Arg{English form}\\ |
| 192 |
% \cs{lat} \Arg{abbr} |
| 193 |
% \end{syntax} |
| 194 |
% \end{function} |
| 195 |
% \noindent Latin abbreviations can be used in different ways. The |
| 196 |
% option |lat=0| will keep the Latin abbreviation as such in form in |
| 197 |
% italic shape. |abbr=italic| will make the abbreviation italicized |
| 198 |
% (which is also default). |abbr=rm| will make it upshape. |lat=1| |
| 199 |
% will take away the periods in the abbreviated Latin forms while |
| 200 |
% |lat=2| will replace the abbreviation with its English language |
| 201 |
% equivalents. |
| 202 |
% |
| 203 |
% The package comes with a default list of abbreviations. Users shall |
| 204 |
% use the command \cs{lat}\Arg{abbr} to invoke the desired format of |
| 205 |
% abbeviation in the document instance. |
| 206 |
% |
| 207 |
% |
| 208 |
% \subsection{Acronyms} |
| 209 |
% |
| 210 |
% \begin{function}{\newacro,\ac} |
| 211 |
% \begin{syntax} |
| 212 |
% \cs{newacro} \Arg{short form} \Arg{long form}\\ |
| 213 |
% \cs{ac} \Arg{short form} |
| 214 |
% \end{syntax} |
| 215 |
% \end{function} |
| 216 |
% \noindent The highly aclaimed package, namely, \pkg{acronym} has |
| 217 |
% been made use of to achieve the extensive features available |
| 218 |
% therein. Kindly refer to its documentation for getting an |
| 219 |
% understanding of the usage. |
| 220 |
% |
| 221 |
% \subsection{Itemization and Non-local Lists} |
| 222 |
% |
| 223 |
% A list environment, namely, |eitem| has been defined which can be |
| 224 |
% used for a variety of purposes as enlisted below by changing its |
| 225 |
% options. |
| 226 |
% |
| 227 |
% \begin{flushleft} |
| 228 |
% \begin{tabular}{@{}ll} |
| 229 |
% \bfseries Option & \bfseries Rendering\\[3pt] |
| 230 |
% |eitem=0| & normal list: Firstly, Secondly, Thirdly, \dots\\ |
| 231 |
% |eitem=1| & normal list: First, Second, Third, \dots\\ |
| 232 |
% |eitem=2| & enumerated list: 1, 2, 3, \dots\\ |
| 233 |
% |eitem=3| & itemized bulletted list\\ |
| 234 |
% |eitem=4| & para list: Firstly, secondly, thirdly, \dots\\ |
| 235 |
% |eitem=5| & para list: First, second, third, \dots\\ |
| 236 |
% \end{tabular} |
| 237 |
% \end{flushleft} |
| 238 |
% |
| 239 |
% In the para list forms, each item will be separated by semicolon |
| 240 |
% (|;|) and the penultimate item will be connected to the last one by |
| 241 |
% the `|and|' automatically. |
| 242 |
% |
| 243 |
% \begin{function}{\elist} |
| 244 |
% \begin{syntax} |
| 245 |
% \cs{elist} \Arg{comma separated list} |
| 246 |
% \end{syntax} |
| 247 |
% \end{function} |
| 248 |
% \noindent |
| 249 |
% There is also a convenient command, ``|elist|'' that helps to format |
| 250 |
% a comma separated list in a proper way with proper spacing. For |
| 251 |
% example, |
| 252 |
% \begin{verbatim} |
| 253 |
% \elist{warblers,tits,wrens,hummingbirds} |
| 254 |
% \elist{warblers , tits, wrens ,hummingbirds} |
| 255 |
% \end{verbatim} |
| 256 |
% will be formatted in the proper way with right spacing and correct |
| 257 |
% punctuation: |
| 258 |
% \begin{quote}\color{vcolor} |
| 259 |
% warblers, tits, wrens and hummingbirds |
| 260 |
% \end{quote} |
| 261 |
% |
| 262 |
% \subsection{Parenthetical and Serial Comma} |
| 263 |
% |
| 264 |
% \begin{function}{\pc} |
| 265 |
% \begin{syntax} |
| 266 |
% \cs{pc} \Arg{text to be included} |
| 267 |
% \end{syntax} |
| 268 |
% \end{function} |
| 269 |
% \noindent This is accomplished with the command \cs{pc} and the text |
| 270 |
% to be distiguished shall be its argument. Different values for |
| 271 |
% option with the same name, |pc|, provide different functionality as |
| 272 |
% detailed below: |
| 273 |
% |
| 274 |
% \begin{flushleft} |
| 275 |
% \begin{tabular}{@{}ll} |
| 276 |
% \bfseries Option & \bfseries Rendering\\[3pt] |
| 277 |
% |pc=0| & argument is separated by parenthetical commas\\ |
| 278 |
% |pc=1| & separated by parenthesis\\ |
| 279 |
% |pc=2| & separated by emdashes\\ |
| 280 |
% |pc=3| & formatted as a footnote \\ |
| 281 |
% |pc=4| & formatted as a sidenote (marginpar) |
| 282 |
% \end{tabular} |
| 283 |
% \end{flushleft} |
| 284 |
% |
| 285 |
% \subsection{Non-local Tokenization} |
| 286 |
% |
| 287 |
% \begin{function}{\definetoken,\tkn} |
| 288 |
% \begin{syntax} |
| 289 |
% \cs{definetoken} \Arg{label} \Arg{full tokens} \Arg{less tokens} |
| 290 |
% \Arg{least tokens} \\ |
| 291 |
% \cs{tkn} \Arg{label} |
| 292 |
% \end{syntax} |
| 293 |
% \end{function} |
| 294 |
% \noindent A sequence of minimization operation can be brought out by |
| 295 |
% first defining the tokens to be minimized and then using the same |
| 296 |
% consecutively will typeset the tokens in differently and minimized |
| 297 |
% manner each time it is called. We define a token as: |
| 298 |
% \begin{verbatim} |
| 299 |
% \definetoken{mango}{His Holyness, the Prince of Mangoistan} |
| 300 |
% {The Prince of Mangoistan}{He} |
| 301 |
% \end{verbatim} |
| 302 |
% will have different output as given below: |
| 303 |
% |
| 304 |
% \begin{flushleft} |
| 305 |
% \begin{tabular}{@{}ll} |
| 306 |
% \bfseries Command & \bfseries Rendering\\[3pt] |
| 307 |
% First instance: \cs{tkn}|{mango}| & His Holyness, the Prince of Mangoistan\\ |
| 308 |
% Second: \cs{tkn}|{mango}|& The Prince of Mangoistan\\ |
| 309 |
% Third: \cs{tkn}|{mango}|& He \\ |
| 310 |
% Fourth: \cs{tkn}|{mango}|& He |
| 311 |
% \end{tabular} |
| 312 |
% \end{flushleft} |
| 313 |
% |
| 314 |
% \end{documentation} |
| 315 |
% |
| 316 |
% \begin{implementation} |
| 317 |
% |
| 318 |
% \section{\pkg{copyedit} implementation} |
| 319 |
% |
| 320 |
% \begin{macrocode} |
| 321 |
%<*initex|package> |
| 322 |
% \end{macrocode} |
| 323 |
% |
| 324 |
% \begin{macrocode} |
| 325 |
%<@@=cedt> |
| 326 |
% \end{macrocode} |
| 327 |
% |
| 328 |
% \begin{macrocode} |
| 329 |
\ProvidesExplPackage |
| 330 |
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} |
| 331 |
% \end{macrocode} |
| 332 |
% |
| 333 |
%\begin{macro}{\@@_load_check:n} |
| 334 |
% There are also a number of packages that are incompatible with |
| 335 |
% \pkg{copyedit}. These are all checked for next. Some of the |
| 336 |
% incompatible packages will not raise an error if loaded after |
| 337 |
% \pkg{copyedit}. So a test is made at the beginning of the |
| 338 |
% document as well. The message for this may be needed immediately, so |
| 339 |
% it is created here not with the other messages. |
| 340 |
% \begin{macrocode} |
| 341 |
\msg_new:nnnn { copyedit } { incompatible-package } |
| 342 |
{ Package~'#1'~incompatible. } |
| 343 |
{ The~#1~package~and~copyedit~are~incompatible. } |
| 344 |
\cs_new_protected:Npn \@@_load_check:n #1 |
| 345 |
{ |
| 346 |
\group_begin: |
| 347 |
\@ifpackageloaded {#1} |
| 348 |
{ \msg_error:nnx { copyedit } { incompatible-package } {#1} } |
| 349 |
{ } |
| 350 |
\group_end: |
| 351 |
} |
| 352 |
\clist_map_function:nN |
| 353 |
{ Array , MyPackage } |
| 354 |
\@@_load_check:n |
| 355 |
\AtBeginDocument { |
| 356 |
\clist_map_function:nN { Array , MyPackage } |
| 357 |
\@@_load_check:n |
| 358 |
} |
| 359 |
% \end{macrocode} |
| 360 |
%\end{macro} |
| 361 |
% |
| 362 |
% \begin{macro}{\wrAux} |
| 363 |
% \begin{macrocode} |
| 364 |
\NewDocumentCommand \wrAux { m } |
| 365 |
{ \iow_now:Nx \@auxout { #1 } } |
| 366 |
% \end{macrocode} |
| 367 |
% A simple scratch macro to write out stuff to the auxiliary file. |
| 368 |
% There should be some elegant way or macro for the job. |
| 369 |
% |
| 370 |
% \end{macro} |
| 371 |
% |
| 372 |
% \begin{macro}{\l@@_lat_int,\l@@_pc_int,\l@@_lang_int,\l@@_eitem_int} |
| 373 |
% Needed counters and functions to use the counters are defined in advance. |
| 374 |
% \begin{macrocode} |
| 375 |
\int_new:N \l@@_lat_int |
| 376 |
\NewDocumentCommand \setlat { m } |
| 377 |
{ \int_set:Nn \l@@_lat_int { #1 } } |
| 378 |
|
| 379 |
\int_new:N \l@@_pc_int |
| 380 |
\NewDocumentCommand \setpc { m } |
| 381 |
{ \int_set:Nn \l@@_pc_int { #1 } } |
| 382 |
|
| 383 |
\int_new:N \l@@_lang_int |
| 384 |
\NewDocumentCommand \setlang { m } |
| 385 |
{ \int_set:Nn \l@@_lang_int { #1 } } |
| 386 |
|
| 387 |
\int_new:N \l@@_eitem_int |
| 388 |
\NewDocumentCommand \seteitem { m } |
| 389 |
{ \int_set:Nn \l@@_eitem_int { #1 } } |
| 390 |
\int_new:N \l@@_abbr_int |
| 391 |
|
| 392 |
\NewDocumentCommand \setabbr { m } |
| 393 |
{ |
| 394 |
\str_if_eq:nnTF { #1 } { italic } |
| 395 |
{ \int_set:Nn \l@@_abbr_int { 0 } } |
| 396 |
{ \int_set:Nn \l@@_abbr_int { 1 } } |
| 397 |
} |
| 398 |
% \end{macrocode} |
| 399 |
% \end{macro} |
| 400 |
% |
| 401 |
% \begin{macro}{\@@_lang_check:n} |
| 402 |
% |
| 403 |
% Define a function to check language code |
| 404 |
% and set the language numeric counter. |
| 405 |
% |
| 406 |
% \begin{macrocode} |
| 407 |
\cs_new_protected:Npn \@@_lang_check:n #1 |
| 408 |
{ |
| 409 |
\str_if_eq:nnT { #1 } { uk } { \setlang { 0 } } |
| 410 |
\str_if_eq:nnT { #1 } { us } { \setlang { 1 } } |
| 411 |
\str_if_eq:nnT { #1 } { ca } { \setlang { 2 } } |
| 412 |
\str_if_eq:nnT { #1 } { au } { \setlang { 3 } } |
| 413 |
} |
| 414 |
% \end{macrocode} |
| 415 |
% |
| 416 |
% \end{macro} |
| 417 |
% |
| 418 |
% \begin{macro}{} |
| 419 |
% |
| 420 |
% Define key-values as per expl3 syntax: |
| 421 |
% \begin{macrocode} |
| 422 |
\keys_define:nn { copyedit } |
| 423 |
{ |
| 424 |
lang .code:n = \@@_lang_check:n { #1 } , |
| 425 |
lat .code:n = \setlat { #1 } , |
| 426 |
abbr .code:n = \setabbr{ #1 } , |
| 427 |
pc .code:n = \setpc { #1 } , |
| 428 |
draft .bool_set:N = \l@@_draft_bool , |
| 429 |
last .bool_set:N = \l@@_last_bool , |
| 430 |
eitem .code:n = \seteitem { #1 } , |
| 431 |
key-unknown .code:n = |
| 432 |
{ |
| 433 |
\msg_error:nnx { copyedit } { unknown-option } |
| 434 |
{ \exp_not:V \l_keys_key_tl } |
| 435 |
} |
| 436 |
} |
| 437 |
% \end{macrocode} |
| 438 |
% |
| 439 |
% Set key-values and process key-value options. |
| 440 |
% |
| 441 |
% \begin{macrocode} |
| 442 |
\keys_set:nn { copyedit } |
| 443 |
{ |
| 444 |
lang = { uk } , |
| 445 |
lat = { 0 } , |
| 446 |
abbr = { italic } , |
| 447 |
pc = { 0 } , |
| 448 |
draft = { false } , |
| 449 |
last = { false } , |
| 450 |
eitem = { 0 } , |
| 451 |
} |
| 452 |
|
| 453 |
\ProcessKeysOptions { copyedit } |
| 454 |
% \end{macrocode} |
| 455 |
% |
| 456 |
% \end{macro} |
| 457 |
% |
| 458 |
% \begin{macro}{\ceset,\cesetup} |
| 459 |
% |
| 460 |
% A macro, \cs{ceset} has been defined to invoke any option at any |
| 461 |
% point in the document instance. A variant, \cs{cesetup}, has also |
| 462 |
% been defined. |
| 463 |
% |
| 464 |
% \begin{macrocode} |
| 465 |
\NewDocumentCommand \ceset { m } |
| 466 |
{ |
| 467 |
\keys_set:nn { copyedit } { #1 } |
| 468 |
\@@_lang_check:n { \l@@_lang_tl } |
| 469 |
} |
| 470 |
\cs_set_eq:NN \cesetup \ceset |
| 471 |
% \end{macrocode} |
| 472 |
% \end{macro} |
| 473 |
% |
| 474 |
% \begin{macro}{\switchvariant,\definevariant,\vara} |
| 475 |
% \cs{swtchvariant} is an internal function that will help to switch |
| 476 |
% between different locale as per the language option chosen. |
| 477 |
% \cs{definevariant} is the one for defining different locale and |
| 478 |
% \cs{vara} is the user level command for using in document |
| 479 |
% instance. |
| 480 |
% |
| 481 |
% \begin{macrocode} |
| 482 |
\NewDocumentCommand \switchvariant { m m m m } |
| 483 |
{ |
| 484 |
\int_case:nn { \l@@_lang_int } |
| 485 |
{ |
| 486 |
{ 0 } { #1 } |
| 487 |
{ 1 } { #2 } |
| 488 |
{ 2 } { #3 } |
| 489 |
{ 3 } { #4 } |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
\NewDocumentCommand \definevariant { m m m m } |
| 494 |
{ |
| 495 |
\tl_set:cn { g_vara_#1_tl } |
| 496 |
{ \switchvariant { #1 } { #2 } { #3 } { #4 } } |
| 497 |
\tl_set:cn { g_vara_#2_tl } |
| 498 |
{ \switchvariant { #1 } { #2 } { #3 } { #4 } } |
| 499 |
\tl_set:cn { g_vara_#3_tl } |
| 500 |
{ \switchvariant { #1 } { #2 } { #3 } { #4 } } |
| 501 |
\tl_set:cn { g_vara_#4_tl } |
| 502 |
{ \switchvariant { #1 } { #2 } { #3 } { #4 } } |
| 503 |
} |
| 504 |
|
| 505 |
\DeclareDocumentCommand \vara { s m } |
| 506 |
{ |
| 507 |
\IfBooleanTF {#1} |
| 508 |
{ #2 } |
| 509 |
{ \normalvara {#2} } |
| 510 |
} |
| 511 |
|
| 512 |
\NewDocumentCommand \normalvara { m } |
| 513 |
{ |
| 514 |
\use:c { g_vara_#1_tl } |
| 515 |
} |
| 516 |
% \end{macrocode} |
| 517 |
% |
| 518 |
% \end{macro} |
| 519 |
% |
| 520 |
% \begin{macro}{\hyp,\closeup,sword} |
| 521 |
% |
| 522 |
% \cs{hyp}, \cs{closeup} and \cs{sword} are three simple macros to |
| 523 |
% hyphenate, close up and separate two words respectively. |
| 524 |
% \begin{macrocode} |
| 525 |
\NewDocumentCommand \hyp { m m } { #1-#2 } |
| 526 |
\NewDocumentCommand \closeup { m m } { #1#2 } |
| 527 |
\NewDocumentCommand \sword { m m } { #1~#2 } |
| 528 |
% \end{macrocode} |
| 529 |
% \end{macro} |
| 530 |
% |
| 531 |
% |
| 532 |
%\begin{macro}{\definelat,\lat} |
| 533 |
% |
| 534 |
% Latin abbreviation and its variant forms can be brought in by these |
| 535 |
% macros. |
| 536 |
% \begin{macrocode} |
| 537 |
\NewDocumentCommand \definelat { m m m } |
| 538 |
{ |
| 539 |
\tl_set:cn { g_@@_lat_#1_tl } |
| 540 |
{ |
| 541 |
\group_begin: |
| 542 |
\int_case:nn { \l@@_abbr_int} |
| 543 |
{ |
| 544 |
{ 0 } { \itshape } |
| 545 |
{ 1 } { \upshape } |
| 546 |
} |
| 547 |
\int_case:nn { \l@@_lat_int } |
| 548 |
{ |
| 549 |
{ 0 } { #1 } |
| 550 |
{ 1 } { #2 } |
| 551 |
{ 2 } { #3 } |
| 552 |
} |
| 553 |
\group_end: |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
\NewDocumentCommand \lat { m } { \use:c { g_@@_lat_#1_tl } } |
| 558 |
% \end{macrocode} |
| 559 |
% \end{macro} |
| 560 |
% |
| 561 |
% \begin{macro}{\pc,\elist} |
| 562 |
% |
| 563 |
% Parenthetical comma (pc) and its variants are chosen with this macro |
| 564 |
% in combination with different options. |
| 565 |
% \begin{macrocode} |
| 566 |
\NewDocumentCommand \pc { m } |
| 567 |
{ |
| 568 |
\int_case:nn { \l@@_pc_int } |
| 569 |
{ |
| 570 |
{ 0 } { \unskip,~#1,~ } |
| 571 |
{ 1 } { (#1) } |
| 572 |
{ 2 } { ---~#1~--- } |
| 573 |
{ 3 } { \unskip\footnote{#1} } |
| 574 |
{ 4 } { \marginpar{ \footnotesize\raggedright#1} } |
| 575 |
} |
| 576 |
} |
| 577 |
\clist_new:N \l@@_clist |
| 578 |
\NewDocumentCommand \elist { m } |
| 579 |
{ |
| 580 |
\clist_set:Nn \l@@_clist { #1 } |
| 581 |
\clist_use:Nnnn \l@@_clist { ~and~ } { ,~ } { ~and~ } |
| 582 |
} |
| 583 |
% \end{macrocode} |
| 584 |
% \end{macro} |
| 585 |
% |
| 586 |
% \begin{macro}{\definetoken,\tkn,\Token} |
| 587 |
% |
| 588 |
% Non-local tokenization |
| 589 |
% |
| 590 |
% \begin{macrocode} |
| 591 |
\NewDocumentCommand \definetoken { m m m m } |
| 592 |
{ |
| 593 |
\tl_gset:cn { #1num } { 0 } |
| 594 |
\tl_gset:cn { g_toks_#1_0_tl } { #2 \tl_gset:cn { #1num } { 1 } } |
| 595 |
\tl_gset:cn { g_toks_#1_1_tl } { #3 \tl_gset:cn { #1num } { 2 } } |
| 596 |
\tl_gset:cn { g_toks_#1_2_tl } { #4 \tl_gset:cn { #1num } { 2 } } |
| 597 |
} |
| 598 |
\NewDocumentCommand \tkn { m } |
| 599 |
{ \use:c { g_toks_#1_\use:c{#1num}_tl } } |
| 600 |
\cs_set_eq:NN \Token \tkn |
| 601 |
% \end{macrocode} |
| 602 |
% \end{macro} |
| 603 |
% |
| 604 |
% \begin{environment}{eitem} |
| 605 |
% \env{eitem} is defined to switch between non-local list of |
| 606 |
% different types. We make use of the package \pkg{enumitem} for |
| 607 |
% this purpose. |
| 608 |
% |
| 609 |
% \begin{macrocode} |
| 610 |
\RequirePackage{enumitem} |
| 611 |
\chardef\thre@=3 |
| 612 |
\newenvironment{enumerate*}[1][]% |
| 613 |
{\@nameuse{enit@enumerate*}\enitdp@enumerate{enum}\thre@{#1}} |
| 614 |
{\@nameuse{enit@endenumerate*}} |
| 615 |
% \end{macrocode} |
| 616 |
% |
| 617 |
% A few macros like, \cs{lastlabel}, \cs{mysep}, \cs{myseplast}, |
| 618 |
% \cs{elistcnt}, \cs{LastItem} are defined to make the job easier. |
| 619 |
% |
| 620 |
% \begin{macrocode} |
| 621 |
\int_new:N \l@@_elistcnt_int |
| 622 |
\NewDocumentCommand \lastlabel { } { \tex_xdef:D\@itemlabel{Lastly}} |
| 623 |
\NewDocumentCommand \mysep { } { ;\hskip .5em plus .1em minus .1em } |
| 624 |
\NewDocumentCommand \myseplast { } {\space and \space } |
| 625 |
\NewDocumentCommand \elistcnt { } { \int_use:N \l@@_elistcnt_int } |
| 626 |
\NewDocumentCommand \LastItem { m m } |
| 627 |
{ \tl_gset:cn { l@@_tmpa_#1_tl } { #2 } } |
| 628 |
% \end{macrocode} |
| 629 |
% |
| 630 |
% \begin{macro}{\checklast} |
| 631 |
% \cs{checklast} is the macro that finds the last item number and |
| 632 |
% substitutes with |Last| or |Lastly| depending upon the option |
| 633 |
% chosen. |
| 634 |
% |
| 635 |
% \begin{macrocode} |
| 636 |
\NewDocumentCommand \checklast { m } |
| 637 |
{ |
| 638 |
\tl_if_exist:cTF { l@@_tmpa_ \elistcnt _tl } |
| 639 |
{ \int_set:Nn \l_tmpa_int { \use:c{ l@@_tmpa_\elistcnt _tl }} } |
| 640 |
{ \int_set:Nn \l_tmpa_int { 0 } } |
| 641 |
\int_set:Nn \l_tmpb_int { \the\c@enumi } |
| 642 |
\int_compare:nNnTF { \l_tmpa_int } = { \l_tmpb_int } |
| 643 |
{ |
| 644 |
\bool_if:NTF \l@@_last_bool |
| 645 |
{ |
| 646 |
\int_case:nn { \l@@_eitem_int } |
| 647 |
{ |
| 648 |
{ 0 } { Lastly, } |
| 649 |
{ 1 } { Last, } |
| 650 |
{ 4 } { lastly, } |
| 651 |
{ 5 } { last, } |
| 652 |
} |
| 653 |
} |
| 654 |
{ #1 } |
| 655 |
} |
| 656 |
{ #1 } |
| 657 |
} |
| 658 |
% \end{macrocode} |
| 659 |
% \end{macro} |
| 660 |
% |
| 661 |
% Smallish set up changes are made to the \pkg{enumitem} to suit the |
| 662 |
% requirements. |
| 663 |
% |
| 664 |
% \begin{macro}{\ctext,\@ctext,\ltext,\@ltext,\paratext,\@paractext,\paraltext,\@paraltext} |
| 665 |
% |
| 666 |
% These macros act as variables to hold textual values for each item number. |
| 667 |
% |
| 668 |
% \begin{macrocode} |
| 669 |
\makeatletter |
| 670 |
\def\ctext#1{\expandafter\@ctext\csname c@#1\endcsname} |
| 671 |
\def\@ctext#1{\ifcase#1\or \checklast{First,}\or |
| 672 |
\checklast{Second,}\or \checklast{Third,}\or |
| 673 |
\checklast{Fourth,}\or \checklast{Fifth,}\or |
| 674 |
\checklast{Sixth,}\or \checklast{Seventh,}\or |
| 675 |
\checklast{Eigth,}\or \checklast{Nineth,}\or |
| 676 |
\checklast{Tenth,}\fi} |
| 677 |
\AddEnumerateCounter{\ctext}{\@ctext}{Second,} |
| 678 |
|
| 679 |
\def\ltext#1{\expandafter\@ltext\csname c@#1\endcsname} |
| 680 |
\def\@ltext#1{\ifcase#1\or \checklast{Firstly,}\or |
| 681 |
\checklast{Secondly,}\or \checklast{Thirdly,}\or |
| 682 |
\checklast{Fourthly,}\or \checklast{Fifthly,}\or |
| 683 |
\checklast{Sixthly,}\or \checklast{Seventhly,}\or |
| 684 |
\checklast{Eigthly,}\or \checklast{Ninethly,}\or |
| 685 |
\checklast{Tenthly,}\fi} |
| 686 |
\AddEnumerateCounter{\ltext}{\@ltext}{Secondly,} |
| 687 |
|
| 688 |
\def\paractext#1{\expandafter\@paractext\csname c@#1\endcsname} |
| 689 |
\def\@paractext#1{\ifcase#1\or \checklast{First,}\or |
| 690 |
\checklast{second,}\or \checklast{third,}\or |
| 691 |
\checklast{fourth,}\or \checklast{fifth,}\or |
| 692 |
\checklast{sixth,}\or \checklast{seventh,}\or |
| 693 |
\checklast{eigth,}\or \checklast{nineth,}\or |
| 694 |
\checklast{tenth,}\fi} |
| 695 |
\AddEnumerateCounter{\paractext}{\@paractext}{second,} |
| 696 |
|
| 697 |
\def\paraltext#1{\expandafter\@paraltext\csname c@#1\endcsname} |
| 698 |
\def\@paraltext#1{\ifcase#1\or \checklast{Firstly,}\or |
| 699 |
\checklast{secondly,}\or \checklast{thirdly,}\or |
| 700 |
\checklast{fourthly,}\or \checklast{fifthly,}\or |
| 701 |
\checklast{sixthly,}\or \checklast{seventhly,}\or |
| 702 |
\checklast{eigthly,}\or \checklast{ninethly,}\or |
| 703 |
\checklast{tenthly,}\fi} |
| 704 |
\AddEnumerateCounter{\paraltext}{\@paraltext}{secondly,} |
| 705 |
% \end{macrocode} |
| 706 |
% \end{macro} |
| 707 |
% |
| 708 |
% At last \env{eitem} has been defined. |
| 709 |
% |
| 710 |
% \begin{macrocode} |
| 711 |
\NewDocumentEnvironment { eitem } { } |
| 712 |
{ |
| 713 |
\int_gincr:N \l@@_elistcnt_int |
| 714 |
\int_case:nn { \l@@_eitem_int } |
| 715 |
{ |
| 716 |
{ 0 } { \begin{enumerate} |
| 717 |
[label=\ltext*,align=left,itemjoin=\mysep,itemjoin*=\myseplast] } |
| 718 |
{ 1 } { \begin{enumerate} |
| 719 |
[label=\ctext*,align=left,itemjoin=\mysep,itemjoin*=\myseplast] } |
| 720 |
{ 2 } { \begin{enumerate}[label=\arabic*.] } |
| 721 |
{ 3 } { \begin{enumerate}[label=\textbullet] } |
| 722 |
{ 4 } { \begin{enumerate*} |
| 723 |
[label=\paraltext*,itemjoin=\mysep,itemjoin*=\myseplast] } |
| 724 |
{ 5 } { \begin{enumerate*} |
| 725 |
[label=\paractext*,itemjoin=\mysep,itemjoin*=\myseplast] } |
| 726 |
} |
| 727 |
} |
| 728 |
{ |
| 729 |
\wrAux { \token_to_str:N \LastItem |
| 730 |
{ \int_use:N \l@@_elistcnt_int } {\the\c@enumi} } |
| 731 |
\int_case:nn { \l@@_eitem_int } |
| 732 |
{ |
| 733 |
{ 0 } { \end{enumerate} } |
| 734 |
{ 1 } { \end{enumerate} } |
| 735 |
{ 2 } { \end{enumerate} } |
| 736 |
{ 3 } { \end{enumerate} } |
| 737 |
{ 4 } { \end{enumerate*} } |
| 738 |
{ 5 } { \end{enumerate*} } |
| 739 |
} |
| 740 |
} |
| 741 |
% |
| 742 |
% \end{macrocode} |
| 743 |
% \end{environment} |
| 744 |
% |
| 745 |
% |
| 746 |
% |
| 747 |
% |
| 748 |
% \begin{macrocode} |
| 749 |
%</initex|package> |
| 750 |
% \end{macrocode} |
| 751 |
%% |
| 752 |
% \end{implementation} |
| 753 |
% |
| 754 |
% \PrintIndex |
| 755 |
% |
| 756 |
% \endinput |
| 757 |
|