| 1 |
%\iffalse |
| 2 |
% mfirstuc.dtx generated using makedtx version 1.2 (c) Nicola Talbot |
| 3 |
% Command line args: |
| 4 |
% -author "Nicola Talbot" |
| 5 |
% -codetitle "Main Package Code" |
| 6 |
% -comment ".*\.l2h" |
| 7 |
% -comment ".*\.tex" |
| 8 |
% -setambles ".*\.l2h=>\nopreamble\nopostamble" |
| 9 |
% -setambles ".*\.tex=>\nopreamble\nopostamble" |
| 10 |
% -src "mfirstuc.sty\Z=>mfirstuc.sty" |
| 11 |
% -src "mfirstuc-english.sty\Z=>mfirstuc-english.sty" |
| 12 |
% -src "(mfirstuc-[0-9]+-[0-9]+-[0-9]+.sty)\Z=>\1" |
| 13 |
% -src "(sample.*\.tex)\Z=>\1" |
| 14 |
% -src "(.*\.l2h)\Z=>\1" |
| 15 |
% -doc "mfirstuc-codedoc.tex" |
| 16 |
% -macrocode ".*\.l2h" |
| 17 |
% -macrocode ".*\.tex" |
| 18 |
% mfirstuc |
| 19 |
% Created on 2025/4/3 16:03 |
| 20 |
%\fi |
| 21 |
%\iffalse |
| 22 |
%<*package> |
| 23 |
%% \CharacterTable |
| 24 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 25 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 26 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 27 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 28 |
%% Dollar \$ Percent \% Ampersand \& |
| 29 |
%% Acute accent \' Left paren \( Right paren \) |
| 30 |
%% Asterisk \* Plus \+ Comma \, |
| 31 |
%% Minus \- Point \. Solidus \/ |
| 32 |
%% Colon \: Semicolon \; Less than \< |
| 33 |
%% Equals \= Greater than \> Question mark \? |
| 34 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 35 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 36 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 37 |
%% Right brace \} Tilde \~} |
| 38 |
%</package> |
| 39 |
%\fi |
| 40 |
% \iffalse |
| 41 |
% Doc-Source file to use with LaTeX2e |
| 42 |
% Copyright (C) 2025 Nicola Talbot, all rights reserved. |
| 43 |
% \fi |
| 44 |
% \iffalse |
| 45 |
%<*driver> |
| 46 |
\iffalse |
| 47 |
mfirstuc-codedoc.tex is a stub file used by makedtx to create |
| 48 |
mfirstuc.dtx |
| 49 |
\fi |
| 50 |
|
| 51 |
\documentclass{article} |
| 52 |
\usepackage{doc} |
| 53 |
|
| 54 |
\CheckSum{1753} |
| 55 |
|
| 56 |
\RecordChanges |
| 57 |
\PageIndex |
| 58 |
\SetupDoc{reportchangedates} |
| 59 |
\setcounter{IndexColumns}{2} |
| 60 |
|
| 61 |
\usepackage[T1]{fontenc} |
| 62 |
\usepackage{tcolorbox} |
| 63 |
|
| 64 |
\definecolor{defbackground}{rgb}{1,1,0.75} |
| 65 |
|
| 66 |
\newtcolorbox{definition}{halign=flush left, |
| 67 |
colframe=black,colback=defbackground, |
| 68 |
fontupper=\ttfamily, |
| 69 |
before upper={\frenchspacing\obeylines}, |
| 70 |
after={\par\noindent\ignorespacesafterend} |
| 71 |
} |
| 72 |
|
| 73 |
\NewDocElement{Option}{option} |
| 74 |
|
| 75 |
\providecommand{\sty}[1]{\textsf{#1}} |
| 76 |
|
| 77 |
\providecommand\marg[1]{% |
| 78 |
\texorpdfstring{\allowbreak{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}} |
| 79 |
{\{#1\}}} |
| 80 |
\providecommand\oarg[1]{% |
| 81 |
\texorpdfstring{\allowbreak{\ttfamily[}\meta{#1}{\ttfamily]}} |
| 82 |
{[#1]}} |
| 83 |
|
| 84 |
\begin{document} |
| 85 |
\DocInput{mfirstuc.dtx} |
| 86 |
\end{document} |
| 87 |
%</driver> |
| 88 |
%\fi |
| 89 |
% |
| 90 |
% \title{Documented Code For mfirstuc v2.09} |
| 91 |
% \author{Nicola L.C. Talbot\\[10pt] |
| 92 |
%Dickimaw Books\\ |
| 93 |
%\url{http://www.dickimaw-books.com/}} |
| 94 |
% |
| 95 |
% \date{2025-04-03} |
| 96 |
% \maketitle |
| 97 |
% |
| 98 |
%\tableofcontents |
| 99 |
% |
| 100 |
%\section{Introduction} |
| 101 |
% |
| 102 |
%This is the documented code for the \sty{mfirstuc} package. |
| 103 |
%See \texttt{mfirstuc-manual.pdf} for the main user guide. |
| 104 |
% |
| 105 |
%\StopEventually{\clearpage\PrintChanges \clearpage\PrintIndex} |
| 106 |
% |
| 107 |
% |
| 108 |
%\section{Main Package Code} |
| 109 |
%\iffalse |
| 110 |
% \begin{macrocode} |
| 111 |
%<*mfirstuc.sty> |
| 112 |
% \end{macrocode} |
| 113 |
%\fi |
| 114 |
%\section{Mfirstuc Documented Code} |
| 115 |
%\label{sec:code:mfirstuc} |
| 116 |
%\changes{2.0}{2015/09/09}{package split from glossaries} |
| 117 |
% \begin{macrocode} |
| 118 |
\NeedsTeXFormat{LaTeX2e} |
| 119 |
% \end{macrocode} |
| 120 |
% Rollback releases: |
| 121 |
% \begin{macrocode} |
| 122 |
\DeclareRelease{v2.07}{2021-10-15}{mfirstuc-2021-10-15.sty} |
| 123 |
\DeclareCurrentRelease{v2.09}{2025-04-03} |
| 124 |
% \end{macrocode} |
| 125 |
% Declare package: |
| 126 |
% \begin{macrocode} |
| 127 |
\ProvidesPackage{mfirstuc}[2025/04/03 v2.09 (NLCT)] |
| 128 |
% \end{macrocode} |
| 129 |
%\changes{1.06}{2012/05/21}{now requires etoolbox} |
| 130 |
% Requires \sty{etoolbox}: |
| 131 |
% \begin{macrocode} |
| 132 |
\RequirePackage{etoolbox} |
| 133 |
% \end{macrocode} |
| 134 |
%Version 2.07 has switched to LaTeX3 for the actual case-changing. |
| 135 |
%The original \cs{makefirstuc} has been reimplemented to use LaTeX3 |
| 136 |
%code. There is also a new command \cs{MFUsentencecase} which just |
| 137 |
%uses \cs{text\_titlecase\_first:n}. Note that \cs{MFUsentencecase} is |
| 138 |
%internally used by \cs{glsmakefirstuc}, which in turn is used by |
| 139 |
%\cs{makefirstuc} to perform the actual case-change. |
| 140 |
% |
| 141 |
%\begin{macro}{\glsmakefirstuc} |
| 142 |
%\changes{1.05}{2011/04/02}{new} |
| 143 |
%\changes{2.09}{2025/04/03}{made long} |
| 144 |
% Provide a user command to make it easier to customise. This is |
| 145 |
% used internally by \cs{makefirstuc}. (The original commands |
| 146 |
% provided by \sty{mfirstuc} were part of the \sty{glossaries} |
| 147 |
% package, hence the ``gls'' prefix.) |
| 148 |
% \begin{macrocode} |
| 149 |
\newcommand{\glsmakefirstuc}[1]{\MFUsentencecase{\unexpanded{#1}}} |
| 150 |
% \end{macrocode} |
| 151 |
%\end{macro} |
| 152 |
% |
| 153 |
%\begin{macro}{\mfirstucMakeUppercase} |
| 154 |
%\changes{2.09}{2025/04/03}{made long} |
| 155 |
% This was originally provided to allow user to replace |
| 156 |
%\cs{MakeUppercase} with another case-changing command. |
| 157 |
% This is now only used with \cs{mfugrabfirstuc}. |
| 158 |
% \begin{macrocode} |
| 159 |
\ExplSyntaxOn |
| 160 |
\newcommand{\mfirstucMakeUppercase}[1]{\text_uppercase:n{#1}} |
| 161 |
% \end{macrocode} |
| 162 |
%\end{macro} |
| 163 |
% |
| 164 |
%\begin{option}{expanded} |
| 165 |
%\changes{2.08}{2022-10-14}{new} |
| 166 |
%\changes{2.09}{2025/04/03}{made long} |
| 167 |
%Allow argument to expand. |
| 168 |
%This also resets the definition of \cs{mfirstucMakeUppercase} |
| 169 |
%in case it was changed by grabfirst. |
| 170 |
% \begin{macrocode} |
| 171 |
\DeclareOption{expanded}{% |
| 172 |
\renewcommand{\glsmakefirstuc}[1]{\MFUsentencecase{#1}}% |
| 173 |
\renewcommand{\mfirstucMakeUppercase}[1]{\text_uppercase:n{#1}}% |
| 174 |
} |
| 175 |
% \end{macrocode} |
| 176 |
%\end{option} |
| 177 |
% |
| 178 |
%\begin{option}{unexpanded} |
| 179 |
%\changes{2.08}{2022-10-14}{new} |
| 180 |
%\changes{2.09}{2025/04/03}{made long} |
| 181 |
%Prevent argument of \cs{glsmakefirstuc} from expanding. |
| 182 |
%This also resets the definition of \cs{mfirstucMakeUppercase} |
| 183 |
%in case it was changed by grabfirst, but note that it doesn't use |
| 184 |
%\cs{unexpanded}. |
| 185 |
% \begin{macrocode} |
| 186 |
\DeclareOption{unexpanded}{% |
| 187 |
\renewcommand{\glsmakefirstuc}[1]{\MFUsentencecase{\unexpanded{#1}}}% |
| 188 |
\renewcommand{\mfirstucMakeUppercase}[1]{\text_uppercase:n{#1}}% |
| 189 |
} |
| 190 |
\ExplSyntaxOff |
| 191 |
% \end{macrocode} |
| 192 |
%\end{option} |
| 193 |
% |
| 194 |
%\begin{macro}{\mfugrabfirstuc} |
| 195 |
%\changes{2.08}{2022-10-14}{new} |
| 196 |
%Used by the grabfirst option to emulate v2.07. |
| 197 |
% \begin{macrocode} |
| 198 |
\newrobustcmd*{\mfugrabfirstuc}[1]{\@mfu@grabfirstuc#1\empty} |
| 199 |
% \end{macrocode} |
| 200 |
%\end{macro} |
| 201 |
% |
| 202 |
%\begin{macro}{\@mfu@grabfirstuc} |
| 203 |
%\changes{2.08}{2022-10-14}{new} |
| 204 |
% \begin{macrocode} |
| 205 |
\newcommand*{\@mfu@grabfirstuc}[2]{\mfirstucMakeUppercase{#1}#2} |
| 206 |
% \end{macrocode} |
| 207 |
%\end{macro} |
| 208 |
% |
| 209 |
%\begin{option}{grabfirst} |
| 210 |
%\changes{2.08}{2022-10-14}{new} |
| 211 |
%Emulate v2.07 method. Note that this redefines the commands as |
| 212 |
%short not long since it's emulating v2.07. |
| 213 |
% \begin{macrocode} |
| 214 |
\DeclareOption{grabfirst}{% |
| 215 |
\renewcommand*{\glsmakefirstuc}[1]{\mfugrabfirstuc{#1}}% |
| 216 |
\renewcommand*{\mfirstucMakeUppercase}[1]{\MakeUppercase{#1}}% |
| 217 |
} |
| 218 |
% \end{macrocode} |
| 219 |
%\end{option} |
| 220 |
% |
| 221 |
%Process options. |
| 222 |
% \begin{macrocode} |
| 223 |
\ProcessOptions |
| 224 |
% \end{macrocode} |
| 225 |
% |
| 226 |
%There are differences between \cs{makefirstuc} and |
| 227 |
%\cs{MFUsentencecase}, the principle ones being expansion occurs differently and |
| 228 |
%\cs{makefirstuc} stops at exclusions whereas |
| 229 |
%\cs{MFUsentencecase} skips them. |
| 230 |
% \begin{macrocode} |
| 231 |
\ExplSyntaxOn |
| 232 |
% \end{macrocode} |
| 233 |
%\begin{macro}{\MFUsentencecase} |
| 234 |
%\changes{2.08}{2022-10-14}{new} |
| 235 |
%New command provided that simply uses LaTeX3, which expands the |
| 236 |
%content. This may be preferred over \cs{makefirstuc} depending on |
| 237 |
%the content. |
| 238 |
% \begin{macrocode} |
| 239 |
\newcommand{\MFUsentencecase}[1]{\text_titlecase_first:n{#1}} |
| 240 |
% \end{macrocode} |
| 241 |
%\end{macro} |
| 242 |
%\begin{macro}{\MFUexcl} |
| 243 |
%\changes{2.08}{2022-10-14}{new} |
| 244 |
%Add a command to the exclusion list. This is used by |
| 245 |
%\cs{text\_titlecase\_first:n} |
| 246 |
%to skip commands that shouldn't have their argument changed (such |
| 247 |
%as \cs{ref}). It's also used by \cs{makefirstuc}. |
| 248 |
% \begin{macrocode} |
| 249 |
\newcommand{\MFUexcl}[1]{ |
| 250 |
\tl_if_empty:nF { #1 } |
| 251 |
{ |
| 252 |
\tl_if_in:NnF \l_text_case_exclude_arg_tl {#1} |
| 253 |
{ |
| 254 |
\tl_put_right:Nn \l_text_case_exclude_arg_tl {#1} |
| 255 |
} |
| 256 |
} |
| 257 |
} |
| 258 |
% \end{macrocode} |
| 259 |
%\end{macro} |
| 260 |
%Add \cs{ensuremath} as an exclusion otherwise \cs{makefirstuc} |
| 261 |
%will try passing its argument to \cs{MFUsentencecase}, which will |
| 262 |
%fail. |
| 263 |
% \begin{macrocode} |
| 264 |
\MFUexcl{\ensuremath} |
| 265 |
% \end{macrocode} |
| 266 |
% |
| 267 |
%Test if the given command is in the exclusion list. |
| 268 |
% \begin{macrocode} |
| 269 |
\cs_new:Npn \mfirstuc_if_excluded:NTF #1 #2 #3 |
| 270 |
{ |
| 271 |
\tl_if_in:NnTF \l_text_case_exclude_arg_tl {#1} {#2} {#3} |
| 272 |
} |
| 273 |
% \end{macrocode} |
| 274 |
%Provide an implementation of \cs{makefirstuc} that matches |
| 275 |
%older versions as much as possible. |
| 276 |
% \begin{macrocode} |
| 277 |
\tl_new:N \l__mfirstuc_stack_tl |
| 278 |
\tl_new:N \l__mfirstuc_head_tl |
| 279 |
\tl_new:N \l__mfirstuc_next_tl |
| 280 |
% \end{macrocode} |
| 281 |
%In addition to exclusions, also provide blockers. These are only |
| 282 |
%supported by \cs{makefirstuc}. Exclusions and |
| 283 |
%their argument are skipped, whereas blockers prevent case-change. |
| 284 |
%For example, sentence-casing \verb|\label{ex}some text| should skip |
| 285 |
%\verb|\label{ex}|, whereas \verb|\nameref{ex} some text| shouldn't |
| 286 |
%have any case change applied. |
| 287 |
% \begin{macrocode} |
| 288 |
\tl_new:N \l__mfirstuc_blocker_tl |
| 289 |
% \end{macrocode} |
| 290 |
% |
| 291 |
%\begin{macro}{\MFUblocker} |
| 292 |
%\changes{2.08}{2022-10-14}{new} |
| 293 |
%Add a command to the blocker list. |
| 294 |
% \begin{macrocode} |
| 295 |
\newcommand{\MFUblocker}[1]{ |
| 296 |
\tl_if_empty:nF { #1 } |
| 297 |
{ |
| 298 |
\tl_if_in:NnF \l__mfirstuc_blocker_tl {#1} |
| 299 |
{ |
| 300 |
\tl_put_right:Nn \l__mfirstuc_blocker_tl {#1} |
| 301 |
} |
| 302 |
\MFUexcl { #1 } |
| 303 |
} |
| 304 |
} |
| 305 |
% \end{macrocode} |
| 306 |
%\end{macro} |
| 307 |
%Test if the given command is in the blocker list. |
| 308 |
% \begin{macrocode} |
| 309 |
\cs_new:Npn \tl_if_mfirstuc_blocker:nTF #1 #2 #3 |
| 310 |
{ |
| 311 |
\tl_if_in:NnTF \l__mfirstuc_blocker_tl {#1} {#2} {#3} |
| 312 |
} |
| 313 |
% \end{macrocode} |
| 314 |
%Is there a way to do this without \cs{expandafter}? |
| 315 |
% \begin{macrocode} |
| 316 |
\cs_new:Npn \tl_if_mfirstuc_blocker:VTF #1 #2 #3 |
| 317 |
{ |
| 318 |
\expandafter \tl_if_mfirstuc_blocker:nTF \expandafter {#1} {#2} {#3} |
| 319 |
} |
| 320 |
% \end{macrocode} |
| 321 |
% |
| 322 |
%\begin{macro}{\makefirstuc} |
| 323 |
%\begin{definition} |
| 324 |
% \cs{makefirstuc}\marg{text} |
| 325 |
%\end{definition} |
| 326 |
%\changes{1.08}{2013-11-04}{made robust} |
| 327 |
%\changes{2.08}{2022-10-14}{reimplement using \LaTeX3} |
| 328 |
% \begin{macrocode} |
| 329 |
\newrobustcmd{\makefirstuc}[1]{% |
| 330 |
\tl_set:Nn \l__mfirstuc_stack_tl {#1} |
| 331 |
\tl_if_empty:NF \l__mfirstuc_stack_tl |
| 332 |
{ |
| 333 |
\tl_if_single:NTF \l__mfirstuc_stack_tl |
| 334 |
{ |
| 335 |
\glsmakefirstuc{#1} |
| 336 |
} |
| 337 |
{ |
| 338 |
\tl_if_head_is_group:nTF {#1} |
| 339 |
{ |
| 340 |
\glsmakefirstuc{#1} |
| 341 |
} |
| 342 |
{ |
| 343 |
\tl_if_head_eq_catcode:nNTF {#1} \relax |
| 344 |
{ |
| 345 |
\tl_set:NV \l_tmpa_tl \l__mfirstuc_stack_tl |
| 346 |
\tl_set:Nx \l__mfirstuc_head_tl { \tl_head:V \l_tmpa_tl } |
| 347 |
\tl_set:Nx \l__mfirstuc_stack_tl { \tl_tail:N \l__mfirstuc_stack_tl } |
| 348 |
\tl_if_eq:NnTF \l__mfirstuc_head_tl { \protect } |
| 349 |
{ |
| 350 |
\tl_set:NV \l_tmpa_tl \l__mfirstuc_stack_tl |
| 351 |
\tl_set:Nx \l__mfirstuc_head_tl { \tl_head:V \l_tmpa_tl } |
| 352 |
\tl_set:Nx \l__mfirstuc_stack_tl { \tl_tail:N \l__mfirstuc_stack_tl } |
| 353 |
} |
| 354 |
{} |
| 355 |
\tl_if_mfirstuc_blocker:VTF \l__mfirstuc_head_tl |
| 356 |
{ #1 } |
| 357 |
{ |
| 358 |
\let \l_tmpa_tl \l__mfirstuc_stack_tl |
| 359 |
\tl_set:Nx \l__mfirstuc_next_tl { \tl_head:N \l_tmpa_tl } |
| 360 |
\tl_if_single:NTF \l__mfirstuc_next_tl |
| 361 |
{ |
| 362 |
\glsmakefirstuc{#1} |
| 363 |
} |
| 364 |
{ |
| 365 |
\tl_set:Nx \l__mfirstuc_stack_tl { \tl_tail:N \l__mfirstuc_stack_tl } |
| 366 |
\tl_clear:N \l_tmpa_tl |
| 367 |
\tl_put_right:Nn \l_tmpa_tl { \__mfirstuc_inner:nnn } |
| 368 |
\tl_put_right:NV \l_tmpa_tl \l__mfirstuc_head_tl |
| 369 |
\tl_put_right:Nx \l_tmpa_tl |
| 370 |
{ |
| 371 |
{ \expandonce \l__mfirstuc_next_tl } |
| 372 |
{ \expandonce \l__mfirstuc_stack_tl } |
| 373 |
} |
| 374 |
\tl_use:N \l_tmpa_tl |
| 375 |
} |
| 376 |
} |
| 377 |
} |
| 378 |
{ |
| 379 |
\glsmakefirstuc{#1} |
| 380 |
} |
| 381 |
} |
| 382 |
} |
| 383 |
} |
| 384 |
} |
| 385 |
% \end{macrocode} |
| 386 |
%\end{macro} |
| 387 |
% |
| 388 |
% \begin{macrocode} |
| 389 |
\cs_new_protected:Npn \__mfirstuc_inner:nnn #1 #2 #3 |
| 390 |
{ |
| 391 |
% \end{macrocode} |
| 392 |
% Mappings trump exclusions. |
| 393 |
% \begin{macrocode} |
| 394 |
\mfirstuc_get_map:NN #1 \l_tmpb_tl |
| 395 |
\quark_if_no_value:NTF \l_tmpb_tl |
| 396 |
{ |
| 397 |
\mfirstuc_if_excluded:NTF #1 |
| 398 |
{ #1{#2}\makefirstuc{#3} } |
| 399 |
{ #1{\makefirstuc{#2}}#3 } |
| 400 |
} |
| 401 |
{ |
| 402 |
\l_tmpb_tl {#2} #3 |
| 403 |
} |
| 404 |
} |
| 405 |
% \end{macrocode} |
| 406 |
%Mappings. |
| 407 |
% \begin{macrocode} |
| 408 |
\prop_new:N \l__mfirstuc_mappings_prop |
| 409 |
% \end{macrocode} |
| 410 |
%\begin{macro}{\MFUaddmap} |
| 411 |
%\changes{2.08}{2022-10-14}{new} |
| 412 |
%Adds a mapping from a control sequence to the appropriate sentence |
| 413 |
%case version. No map is added if either argument is empty. |
| 414 |
% \begin{macrocode} |
| 415 |
\newrobustcmd*{\MFUaddmap}[2]{% |
| 416 |
\tl_if_empty:nF { #1 } |
| 417 |
{ |
| 418 |
\tl_if_empty:nF { #2 } |
| 419 |
{ |
| 420 |
\prop_put:Nnn \l__mfirstuc_mappings_prop {#1} {#2} |
| 421 |
} |
| 422 |
} |
| 423 |
\MFUexcl { #1 } |
| 424 |
\MFUblocker { #2 } |
| 425 |
} |
| 426 |
% \end{macrocode} |
| 427 |
%\end{macro} |
| 428 |
% \begin{macrocode} |
| 429 |
\cs_new:Npn \mfirstuc_get_map:NN #1 #2 |
| 430 |
{ |
| 431 |
\prop_get:NnN \l__mfirstuc_mappings_prop {#1} #2 |
| 432 |
} |
| 433 |
% \end{macrocode} |
| 434 |
%\begin{macro}{\MFUsaveatend} |
| 435 |
%\changes{2.08}{2022-10-14}{new} |
| 436 |
%Save exclusions, blockers and mappings in the aux file, if required |
| 437 |
%by some external tool, but delays action to the end of the document. |
| 438 |
% \begin{macrocode} |
| 439 |
\newcommand{\MFUsaveatend}{ |
| 440 |
\AtEndDocument { \@MFUsavetoaux } |
| 441 |
% \end{macrocode} |
| 442 |
%Disable this command. |
| 443 |
% \begin{macrocode} |
| 444 |
\let\MFUsaveatend\relax |
| 445 |
} |
| 446 |
% \end{macrocode} |
| 447 |
%\end{macro} |
| 448 |
%\begin{macro}{\MFUsave} |
| 449 |
%\changes{2.08}{2022-10-14}{new} |
| 450 |
%As above but do now. |
| 451 |
% \begin{macrocode} |
| 452 |
\newcommand{\MFUsave}{ |
| 453 |
\@MFUsavetoaux |
| 454 |
% \end{macrocode} |
| 455 |
%Disable further attempts. |
| 456 |
% \begin{macrocode} |
| 457 |
\let\@MFUsavetoaux\relax |
| 458 |
\let\MFUsave\relax |
| 459 |
\let\MFUsaveatend\relax |
| 460 |
} |
| 461 |
% \end{macrocode} |
| 462 |
%\end{macro} |
| 463 |
%\begin{macro}{\@MFUsavetoaux} |
| 464 |
%\changes{2.08}{2022-10-14}{new} |
| 465 |
%Save exclusions, blockers and mappings in the aux file, if required |
| 466 |
%by some external tool. |
| 467 |
% \begin{macrocode} |
| 468 |
\newcommand{\@MFUsavetoaux}{ |
| 469 |
\protected@write\@auxout{} |
| 470 |
{ \tl_to_str:n { \providecommand{\@mfu@excls}[1]{} } } |
| 471 |
\protected@write\@auxout{} |
| 472 |
{ \tl_to_str:n { \providecommand{\@mfu@blockers}[1]{} } } |
| 473 |
\protected@write\@auxout{} |
| 474 |
{ \tl_to_str:n { \providecommand{\@mfu@mappings}[1]{} } } |
| 475 |
% \end{macrocode} |
| 476 |
%Save current values. |
| 477 |
% \begin{macrocode} |
| 478 |
\protected@write\@auxout{} |
| 479 |
{ |
| 480 |
\string\@mfu@excls { \tl_to_str:V \l_text_case_exclude_arg_tl } |
| 481 |
} |
| 482 |
\protected@write\@auxout{} |
| 483 |
{ |
| 484 |
\string\@mfu@blockers { \tl_to_str:V \l__mfirstuc_blocker_tl } |
| 485 |
} |
| 486 |
\protected@write\@auxout{} |
| 487 |
{ |
| 488 |
\string\@mfu@mappings |
| 489 |
{ \expandonce { \prop_to_keyval:N \l__mfirstuc_mappings_prop } } |
| 490 |
} |
| 491 |
} |
| 492 |
% \end{macrocode} |
| 493 |
%\end{macro} |
| 494 |
% \begin{macrocode} |
| 495 |
\ExplSyntaxOff |
| 496 |
% \end{macrocode} |
| 497 |
%The remaining code hasn't been converted to LaTeX3 yet, but may in |
| 498 |
%the future, so don't rely on internal commands. |
| 499 |
% |
| 500 |
%\begin{macro}{\emakefirstuc} |
| 501 |
%\changes{1.10}{2015/05/03}{new} |
| 502 |
%\changes{2.09}{2025/04/03}{made long} |
| 503 |
% Fully expand argument before applying case-change. |
| 504 |
% \begin{macrocode} |
| 505 |
\newrobustcmd{\emakefirstuc}[1]{% |
| 506 |
\protected@edef\@MFU@caparg{#1}% |
| 507 |
\expandafter\makefirstuc\expandafter{\@MFU@caparg}% |
| 508 |
} |
| 509 |
% \end{macrocode} |
| 510 |
%\end{macro} |
| 511 |
% |
| 512 |
%\begin{macro}{\xmakefirstuc} |
| 513 |
%\changes{2.09}{2025/04/03}{made long} |
| 514 |
% \begin{macrocode} |
| 515 |
\newcommand{\xmakefirstuc}[1]{\expandafter\makefirstuc\expandafter{#1}} |
| 516 |
% \end{macrocode} |
| 517 |
%\end{macro} |
| 518 |
% |
| 519 |
%\begin{macro}{\MFUskippunc} |
| 520 |
%\changes{2.07}{2021-10-15}{new} |
| 521 |
% \begin{macrocode} |
| 522 |
\newrobustcmd*{\MFUskippunc}[1]{#1} |
| 523 |
\MFUexcl{\MFUskippunc} |
| 524 |
% \end{macrocode} |
| 525 |
%\end{macro} |
| 526 |
% |
| 527 |
%Title case commands. Each word has the first letter converted to |
| 528 |
%upper case using \cs{MFUcapwordfirstuc}. This uses \cs{makefirstuc} |
| 529 |
%by default. It may be redefined to use \cs{MFUsentencecase} or |
| 530 |
%\cs{text\_titlecase:n} as applicable. |
| 531 |
%\begin{macro}{\MFUcapwordfirstuc} |
| 532 |
%\changes{2.07}{2021-10-15}{new} |
| 533 |
%\changes{2.09}{2025/04/03}{made long} |
| 534 |
%Only a word is expected as the argument, however it's now a long |
| 535 |
%command for consistency. |
| 536 |
% \begin{macrocode} |
| 537 |
\newcommand{\MFUcapwordfirstuc}[1]{% |
| 538 |
\makefirstuc{#1}% |
| 539 |
} |
| 540 |
% \end{macrocode} |
| 541 |
%\end{macro} |
| 542 |
% |
| 543 |
%\begin{macro}{\capitalisewords} |
| 544 |
%\changes{1.06}{2012/05/21}{new} |
| 545 |
% Capitalise each word in the argument. Words are considered to be |
| 546 |
% separated by plain spaces (i.e.\ non-breakable spaces won't be |
| 547 |
% considered a word break). |
| 548 |
%\changes{1.08}{2013-11-04}{made robust} |
| 549 |
%\changes{1.09}{2017-07-30}{added check for words that shouldn't be |
| 550 |
%capitalised} |
| 551 |
%This is not intended for use with multiple paragraphs so it's still |
| 552 |
%a short command. |
| 553 |
% \begin{macrocode} |
| 554 |
\newrobustcmd*{\capitalisewords}[1]{% |
| 555 |
\let\@mfu@checkword\@gobble |
| 556 |
\def\gls@add@space{}% |
| 557 |
\let\@mfu@domakefirstuc\@MFU@dofirst@capword |
| 558 |
\mfu@capitalisewords#1 \@nil\mfu@endcap |
| 559 |
} |
| 560 |
% \end{macrocode} |
| 561 |
%\end{macro} |
| 562 |
% |
| 563 |
%\begin{macro}{\@mfu@mid@capitalisewords} |
| 564 |
%\changes{2.03}{2016-07-29}{new} |
| 565 |
%\cs{@mfu@checkword} needs to be set before use. |
| 566 |
% \begin{macrocode} |
| 567 |
\newcommand*{\@mfu@mid@capitalisewords}[1]{% |
| 568 |
\def\gls@add@space{}% |
| 569 |
\let\@mfu@domakefirstuc\@MFU@do@capword |
| 570 |
\mfu@capitalisewords#1 \@nil\mfu@endcap |
| 571 |
} |
| 572 |
% \end{macrocode} |
| 573 |
%\end{macro} |
| 574 |
% |
| 575 |
% \begin{macrocode} |
| 576 |
\def\mfu@capitalisewords#1 #2\mfu@endcap{% |
| 577 |
\def\mfu@cap@first{#1}% |
| 578 |
\def\mfu@cap@second{#2}% |
| 579 |
\gls@add@space |
| 580 |
\@mfu@checkword{#1}% |
| 581 |
\@mfu@domakefirstuc{#1}% |
| 582 |
\def\gls@add@space{ }% |
| 583 |
\ifx\mfu@cap@second\@nnil |
| 584 |
\let\next@mfu@cap\mfu@noop |
| 585 |
\else |
| 586 |
\let\next@mfu@cap\mfu@capitalisewords |
| 587 |
\let\@mfu@checkword\mfu@checkword |
| 588 |
\fi |
| 589 |
\next@mfu@cap#2\mfu@endcap |
| 590 |
} |
| 591 |
\def\mfu@noop#1\mfu@endcap{} |
| 592 |
% \end{macrocode} |
| 593 |
% |
| 594 |
%\begin{macro}{\ifMFUhyphen} |
| 595 |
%\changes{2.03}{2016-07-29}{new} |
| 596 |
%Split on hyphens. |
| 597 |
% \begin{macrocode} |
| 598 |
\newif\ifMFUhyphen |
| 599 |
\MFUhyphenfalse |
| 600 |
% \end{macrocode} |
| 601 |
%\end{macro} |
| 602 |
% |
| 603 |
%\begin{macro}{\@MFU@do@capword} |
| 604 |
%\changes{2.07}{2021-10-15}{new} |
| 605 |
% \begin{macrocode} |
| 606 |
\newcommand*{\@MFU@do@capword}[1]{% |
| 607 |
\let\@MFU@cappingword\MFUcapword |
| 608 |
\@MFUwordbreak#1\MFUwordbreak{}\@nil\@endMFUwordbreak |
| 609 |
} |
| 610 |
% \end{macrocode} |
| 611 |
%\end{macro} |
| 612 |
% |
| 613 |
%\begin{macro}{\@MFU@dofirst@capword} |
| 614 |
%\changes{2.07}{2021-10-15}{new} |
| 615 |
% \begin{macrocode} |
| 616 |
\newcommand*{\@MFU@dofirst@capword}[1]{% |
| 617 |
\let\@MFU@cappingword\MFUcapword |
| 618 |
\@MFUfirstwordbreak#1\MFUwordbreak{}\@nil\@endMFUfirstwordbreak |
| 619 |
} |
| 620 |
% \end{macrocode} |
| 621 |
%\end{macro} |
| 622 |
% |
| 623 |
%\begin{macro}{\MFUcapword} |
| 624 |
%\changes{2.03}{2016-07-29}{new} |
| 625 |
% \begin{macrocode} |
| 626 |
\newcommand*{\MFUcapword}[1]{% |
| 627 |
\ifMFUhyphen |
| 628 |
\MFUhyphencapword{#1}% |
| 629 |
\else |
| 630 |
\MFUcapwordfirstuc{#1}% |
| 631 |
\fi |
| 632 |
} |
| 633 |
% \end{macrocode} |
| 634 |
%\end{macro} |
| 635 |
% |
| 636 |
%\begin{macro}{\MFUwordbreak} |
| 637 |
%\changes{2.07}{2021-10-15}{new} |
| 638 |
%Markup a character (or command) that should be treated as a word |
| 639 |
%break. |
| 640 |
% \begin{macrocode} |
| 641 |
\newrobustcmd*{\MFUwordbreak}[1]{#1} |
| 642 |
% \end{macrocode} |
| 643 |
%\end{macro} |
| 644 |
% |
| 645 |
%\begin{macro}{\MFUhyphencapword} |
| 646 |
%\changes{2.07}{2021-10-15}{new} |
| 647 |
% \begin{macrocode} |
| 648 |
\newcommand*{\MFUhyphencapword}[1]{% |
| 649 |
\@MFUcapword#1-\@nil\@endMFUcapword |
| 650 |
} |
| 651 |
% \end{macrocode} |
| 652 |
%\end{macro} |
| 653 |
% |
| 654 |
%\begin{macro}{\@MFUcapword} |
| 655 |
%\changes{2.03}{2016-07-29}{new} |
| 656 |
% \begin{macrocode} |
| 657 |
\def\@MFUcapword#1-#2\@endMFUcapword{% |
| 658 |
\MFUcapwordfirstuc{#1}% |
| 659 |
\def\@mfu@argii{#2}% |
| 660 |
\ifx\@mfu@argii\@nnil |
| 661 |
\else |
| 662 |
-\@MFUcapword#2\@endMFUcapword |
| 663 |
\fi |
| 664 |
} |
| 665 |
% \end{macrocode} |
| 666 |
%\end{macro} |
| 667 |
% |
| 668 |
%\begin{macro}{\@MFUwordbreak} |
| 669 |
%\changes{2.07}{2021-10-15}{new} |
| 670 |
% \begin{macrocode} |
| 671 |
\def\@MFUwordbreak#1\MFUwordbreak#2#3\@endMFUwordbreak{% |
| 672 |
\def\@mfu@argiii{#3}% |
| 673 |
\ifx\@mfu@argiii\@nnil |
| 674 |
\@MFU@cappingword{#1}% |
| 675 |
\else |
| 676 |
\let\@MFU@cappingword\@MFU@wordbreakcapword |
| 677 |
\@MFU@cappingword{#1}% |
| 678 |
#2\@MFUwordbreak#3\@endMFUwordbreak |
| 679 |
\fi |
| 680 |
} |
| 681 |
% \end{macrocode} |
| 682 |
%\end{macro} |
| 683 |
% |
| 684 |
%\begin{macro}{\@MFU@wordbreakcapword} |
| 685 |
%\changes{2.07}{2021-10-15}{new} |
| 686 |
% \begin{macrocode} |
| 687 |
\newcommand*{\@MFU@wordbreakcapword}[1]{% |
| 688 |
\mfu@checkword{#1}% |
| 689 |
\@mfu@domakefirstuc{#1}% |
| 690 |
} |
| 691 |
% \end{macrocode} |
| 692 |
%\end{macro} |
| 693 |
% |
| 694 |
%\begin{macro}{\@MFUfirstwordbreak} |
| 695 |
%\changes{2.07}{2021-10-15}{new} |
| 696 |
% \begin{macrocode} |
| 697 |
\def\@MFUfirstwordbreak#1\MFUwordbreak#2#3\@endMFUfirstwordbreak{% |
| 698 |
\def\@mfu@argiii{#3}% |
| 699 |
\ifx\@mfu@argiii\@nnil |
| 700 |
\@MFU@cappingword{#1}% |
| 701 |
\else |
| 702 |
\let\@MFU@cappingword\@MFU@firstwordbreakcapword |
| 703 |
\@MFU@cappingword{#1}% |
| 704 |
#2\@MFUfirstwordbreak#3\@endMFUfirstwordbreak |
| 705 |
\fi |
| 706 |
} |
| 707 |
% \end{macrocode} |
| 708 |
%\end{macro} |
| 709 |
% |
| 710 |
%\begin{macro}{\@MFU@firstwordbreakcapword} |
| 711 |
%\changes{2.07}{2021-10-15}{new} |
| 712 |
% \begin{macrocode} |
| 713 |
\newcommand*{\@MFU@firstwordbreakcapword}[1]{% |
| 714 |
\@mfu@domakefirstuc{#1}% |
| 715 |
} |
| 716 |
% \end{macrocode} |
| 717 |
%\end{macro} |
| 718 |
% |
| 719 |
%\begin{macro}{\mfu@checkword} |
| 720 |
% Check if word should be capitalised. |
| 721 |
% This originally used \sty{etoolbox}'s \cs{ifinlist} command |
| 722 |
% but this doesn't work if the word contains grouping. |
| 723 |
%\changes{1.09}{2017-07-30}{new} |
| 724 |
%\changes{2.02}{2015-12-17}{modified to use loop instead of \cs{ifinlist}} |
| 725 |
% \begin{macrocode} |
| 726 |
\newcommand*\mfu@checkword[1]{% |
| 727 |
\def\mfu@checkword@arg{#1}% |
| 728 |
\let\@mfu@domakefirstuc\@MFU@do@capword |
| 729 |
\forlistloop\mfu@checkword@do\@mfu@nocaplist |
| 730 |
} |
| 731 |
% \end{macrocode} |
| 732 |
%\end{macro} |
| 733 |
% |
| 734 |
%\begin{macro}{\mfu@checkword@do} |
| 735 |
% Handler for loop used by \cs{mfu@checkword} |
| 736 |
%\changes{2.02}{2015-12-17}{new} |
| 737 |
% \begin{macrocode} |
| 738 |
\newcommand*{\mfu@checkword@do}[1]{% |
| 739 |
\def\mfu@checkword@argii{#1}% |
| 740 |
\ifdefequal\mfu@checkword@arg\mfu@checkword@argii |
| 741 |
{% |
| 742 |
\let\@mfu@domakefirstuc\@firstofone |
| 743 |
\listbreak |
| 744 |
}% |
| 745 |
{% |
| 746 |
% \end{macrocode} |
| 747 |
%Need to check if \cs{@mfu@terminator} has been tacked onto the end. |
| 748 |
% \begin{macrocode} |
| 749 |
\def\mfu@checkword@argii{#1{\@mfu@terminator}}% |
| 750 |
\ifdefequal\mfu@checkword@arg\mfu@checkword@argii |
| 751 |
{% |
| 752 |
\let\@mfu@domakefirstuc\@firstofone |
| 753 |
\listbreak |
| 754 |
}% |
| 755 |
{}% |
| 756 |
}% |
| 757 |
} |
| 758 |
% \end{macrocode} |
| 759 |
%\end{macro} |
| 760 |
% |
| 761 |
%\begin{macro}{\@mfu@nocaplist} |
| 762 |
% List of words that shouldn't be capitalised. |
| 763 |
%\changes{1.09}{2017-07-30}{new} |
| 764 |
% \begin{macrocode} |
| 765 |
\newcommand*{\@mfu@nocaplist}{} |
| 766 |
% \end{macrocode} |
| 767 |
%\end{macro} |
| 768 |
% |
| 769 |
%\begin{macro}{\MFUnocap} |
| 770 |
% Provide the user with a means to add a word to the list. |
| 771 |
% (No expansion performed on the argument.) |
| 772 |
%\changes{1.09}{2017-07-30}{new} |
| 773 |
% \begin{macrocode} |
| 774 |
\newcommand*{\MFUnocap}[1]{\listadd{\@mfu@nocaplist}{#1}} |
| 775 |
% \end{macrocode} |
| 776 |
%\end{macro} |
| 777 |
%\begin{macro}{\gMFUnocap} |
| 778 |
% Global version. |
| 779 |
%\changes{1.09}{2017-07-30}{new} |
| 780 |
% \begin{macrocode} |
| 781 |
\newcommand*{\gMFUnocap}[1]{\listgadd{\@mfu@nocaplist}{#1}} |
| 782 |
% \end{macrocode} |
| 783 |
%\end{macro} |
| 784 |
% |
| 785 |
%\begin{macro}{\MFUclear} |
| 786 |
% Clear the list |
| 787 |
%\changes{1.09}{2017-07-30}{new} |
| 788 |
% \begin{macrocode} |
| 789 |
\newcommand*{\MFUclear}{\renewcommand*{\@mfu@nocaplist}{}} |
| 790 |
% \end{macrocode} |
| 791 |
%\end{macro} |
| 792 |
% |
| 793 |
%\begin{macro}{\xcapitalisewords} |
| 794 |
%\changes{1.06}{2012/05/21}{new} |
| 795 |
% Short-cut command: |
| 796 |
% \begin{macrocode} |
| 797 |
\newcommand*{\xcapitalisewords}[1]{% |
| 798 |
\expandafter\capitalisewords\expandafter{#1}% |
| 799 |
} |
| 800 |
% \end{macrocode} |
| 801 |
%\end{macro} |
| 802 |
% |
| 803 |
%\begin{macro}{\ecapitalisewords} |
| 804 |
%\changes{1.10}{2015/05/03}{new} |
| 805 |
% Fully expand argument before applying \cs{capitalisewords} |
| 806 |
% \begin{macrocode} |
| 807 |
\newrobustcmd*{\ecapitalisewords}[1]{% |
| 808 |
\protected@edef\@MFU@caparg{#1}% |
| 809 |
\expandafter\capitalisewords\expandafter{\@MFU@caparg}% |
| 810 |
} |
| 811 |
% \end{macrocode} |
| 812 |
%\end{macro} |
| 813 |
% |
| 814 |
%\begin{macro}{\@mfu@nil} |
| 815 |
% \begin{macrocode} |
| 816 |
\newcommand\@mfu@nil{\unskip} |
| 817 |
% \end{macrocode} |
| 818 |
%\end{macro} |
| 819 |
% |
| 820 |
%\begin{macro}{\@mfu@nnil} |
| 821 |
% \begin{macrocode} |
| 822 |
\newcommand*\@mfu@nnil{\@mfu@nil} |
| 823 |
% \end{macrocode} |
| 824 |
%\end{macro} |
| 825 |
% |
| 826 |
%\begin{macro}{\capitalisefmtwords} |
| 827 |
%\changes{2.03}{2016-07-29}{new} |
| 828 |
%Like \cs{capitalisewords} but assumes that the phrase contains |
| 829 |
%formatting text-block commands. |
| 830 |
% \begin{macrocode} |
| 831 |
\newcommand*{\capitalisefmtwords}{% |
| 832 |
\@ifstar\@s@capitalisefmtwords\@ns@capitalisefmtwords |
| 833 |
} |
| 834 |
% \end{macrocode} |
| 835 |
%\end{macro} |
| 836 |
% |
| 837 |
%\begin{macro}{\@s@capitalisefmtwords} |
| 838 |
%\changes{2.04}{2016-07-31}{new} |
| 839 |
% Starred form. |
| 840 |
% \begin{macrocode} |
| 841 |
\newcommand*{\@s@capitalisefmtwords}[1]{% |
| 842 |
\@@s@checkgrp@@capitalisefmtwords#1\@nil |
| 843 |
} |
| 844 |
% \end{macrocode} |
| 845 |
%\end{macro} |
| 846 |
% |
| 847 |
%\begin{macro}{\@@s@checkgrp@capitalisefmtwords} |
| 848 |
%\changes{2.04}{2016-07-31}{new} |
| 849 |
% \begin{macrocode} |
| 850 |
\newcommand*{\@@s@checkgrp@@capitalisefmtwords}{% |
| 851 |
\@ifnextchar\bgroup{\@@s@nocs@capitalisefmtwords}{\@@s@capitalisefmtwords}% |
| 852 |
} |
| 853 |
% \end{macrocode} |
| 854 |
%\end{macro} |
| 855 |
% |
| 856 |
%\begin{macro}{\@@s@nocs@capitalisefmtwords} |
| 857 |
%\changes{2.04}{2016-07-31}{new} |
| 858 |
%Argument starts with a group. |
| 859 |
% \begin{macrocode} |
| 860 |
\def\@@s@nocs@capitalisefmtwords#1\@nil{% |
| 861 |
\capitalisewords{#1}% |
| 862 |
} |
| 863 |
% \end{macrocode} |
| 864 |
%\end{macro} |
| 865 |
% |
| 866 |
%\begin{macro}{\@@s@capitalisefmtwords} |
| 867 |
%\changes{2.04}{2016-07-31}{new} |
| 868 |
% \begin{macrocode} |
| 869 |
\newcommand*{\@@s@capitalisefmtwords}[1]{% |
| 870 |
\def\gls@argi{#1}% |
| 871 |
\ifx\gls@argi\@MFU@protect |
| 872 |
% \end{macrocode} |
| 873 |
%Skip \cs{protect} |
| 874 |
% \begin{macrocode} |
| 875 |
\let\@mfu@capfmtwordsnext\@@s@capitalisefmtwords |
| 876 |
\else |
| 877 |
\ifx\gls@argi\@nnil |
| 878 |
% \end{macrocode} |
| 879 |
%Nothing to do. |
| 880 |
% \begin{macrocode} |
| 881 |
\let\@mfu@capfmtwordsnext\relax |
| 882 |
\else |
| 883 |
\def\@gls@tmp{\ #1}% |
| 884 |
\@onelevel@sanitize\@gls@tmp |
| 885 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 886 |
\if@glscs |
| 887 |
\def\@mfu@capfmtwordsnext{\@@s@cs@capitalisefmtwords#1}% |
| 888 |
\else |
| 889 |
\def\@mfu@capfmtwordsnext{\@@s@nocs@capitalisefmtwords#1}% |
| 890 |
\fi |
| 891 |
\fi |
| 892 |
\fi |
| 893 |
\@mfu@capfmtwordsnext |
| 894 |
} |
| 895 |
% \end{macrocode} |
| 896 |
%\end{macro} |
| 897 |
% |
| 898 |
%\begin{macro}{\@@s@cs@capitalisefmtwords} |
| 899 |
%\changes{2.04}{2016-07-31}{new} |
| 900 |
% \begin{macrocode} |
| 901 |
\newcommand*{\@@s@cs@capitalisefmtwords}[1]{% |
| 902 |
\@ifnextchar\bgroup |
| 903 |
{\@@s@cs@g@capitalisefmtwords#1}% |
| 904 |
{\@@s@cs@ng@capitalisefmtwords#1}% |
| 905 |
} |
| 906 |
% \end{macrocode} |
| 907 |
%\end{macro} |
| 908 |
% |
| 909 |
%\begin{macro}{\@@s@cs@g@capitalisefmtwords} |
| 910 |
%\changes{2.04}{2016-07-31}{new} |
| 911 |
% \begin{macrocode} |
| 912 |
\def\@@s@cs@g@capitalisefmtwords#1#2#3\@nil{% |
| 913 |
#1{\capitalisewords{#2}}% |
| 914 |
\ifblank{#3}% |
| 915 |
{}% |
| 916 |
{% |
| 917 |
\def\gls@add@space{}% |
| 918 |
\let\@mfu@checkword\mfu@checkword |
| 919 |
\mfu@capitalisewords#3 \@nil\mfu@endcap |
| 920 |
}% |
| 921 |
} |
| 922 |
% \end{macrocode} |
| 923 |
%\end{macro} |
| 924 |
% |
| 925 |
%\begin{macro}{\@@s@cs@ng@capitalisefmtwords} |
| 926 |
%\changes{2.04}{2016-07-31}{new} |
| 927 |
% \begin{macrocode} |
| 928 |
\def\@@s@cs@ng@capitalisefmtwords#1#2\@nil{% |
| 929 |
\capitalisewords{#1#2}% |
| 930 |
} |
| 931 |
% \end{macrocode} |
| 932 |
%\end{macro} |
| 933 |
% |
| 934 |
%\begin{macro}{\@ns@capitalisefmtwords} |
| 935 |
%\changes{2.04}{2016-07-31}{new} |
| 936 |
% Unstarred form. |
| 937 |
% \begin{macrocode} |
| 938 |
\newcommand*{\@ns@capitalisefmtwords}[1]{% |
| 939 |
\let\@mfu@checkword\@gobble |
| 940 |
\def\gls@add@space{}% |
| 941 |
\@capitalisefmtwords#1 \@mfu@nil{} \unskip |
| 942 |
} |
| 943 |
% \end{macrocode} |
| 944 |
%\end{macro} |
| 945 |
%\begin{macro}{\@capitalisefmtwords} |
| 946 |
%\changes{2.03}{2016-07-29}{new} |
| 947 |
%Take care of group at the start of the word. |
| 948 |
% \begin{macrocode} |
| 949 |
\newcommand*{\@capitalisefmtwords}{% |
| 950 |
\@ifnextchar\bgroup{\@capitalise@g@fmtwords}{\@capitalise@ng@fmtwords}% |
| 951 |
} |
| 952 |
\newcommand*{\@capitalise@g@fmtwords}[1]{% |
| 953 |
\@capitalise@ng@fmtwords{{#1}}% |
| 954 |
} |
| 955 |
\def\@mfu@ifnil#1#2\@mfu@end@nil#3#4{% |
| 956 |
\def\gls@argi{#1}% |
| 957 |
\ifx\gls@argi\@mfu@nnil |
| 958 |
#3% |
| 959 |
\else |
| 960 |
#4% |
| 961 |
\fi |
| 962 |
} |
| 963 |
\def\@capitalise@ng@fmtwords#1 {% |
| 964 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 965 |
{% |
| 966 |
\def\@mfu@capfmtwordsnext{#1}% |
| 967 |
}% |
| 968 |
{% |
| 969 |
\def\@mfu@capfmtwordsnext{% |
| 970 |
\@capitalise@fmtwords#1\@mfu@nil |
| 971 |
\def\gls@add@space{ }% |
| 972 |
\let\@mfu@checkword\mfu@checkword |
| 973 |
\@@cap@nofmtphrase}% |
| 974 |
}% |
| 975 |
\@mfu@capfmtwordsnext |
| 976 |
}% |
| 977 |
% \end{macrocode} |
| 978 |
%\end{macro} |
| 979 |
%\begin{macro}{\@capitalise@fmtwords} |
| 980 |
%\changes{2.03}{2016-07-29}{new} |
| 981 |
% \begin{macrocode} |
| 982 |
\def\@capitalise@fmtwords#1{% |
| 983 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 984 |
{% |
| 985 |
% \end{macrocode} |
| 986 |
%Do nothing. |
| 987 |
% \begin{macrocode} |
| 988 |
\def\@mfu@capfmtwordsnext{#1}% |
| 989 |
}% |
| 990 |
{% |
| 991 |
\def\gls@argi{#1}% |
| 992 |
\ifx\gls@argi\@MFU@protect |
| 993 |
% \end{macrocode} |
| 994 |
%Skip \cs{protect} |
| 995 |
% \begin{macrocode} |
| 996 |
\def\@mfu@capfmtwordsnext{\@capitalise@fmtwords}% |
| 997 |
\else |
| 998 |
\def\@gls@tmp{\ #1}% |
| 999 |
\@onelevel@sanitize\@gls@tmp |
| 1000 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1001 |
\if@glscs |
| 1002 |
\def\@mfu@capfmtwordsnext{\@@capitalisefmtwords#1}% |
| 1003 |
\else |
| 1004 |
\ifx\gls@argi\@empty |
| 1005 |
\def\@mfu@capfmtwordsnext{\@@capnofmtphrase{}}% |
| 1006 |
\else |
| 1007 |
\def\@mfu@capfmtwordsnext{\@@capnofmtphrase#1}% |
| 1008 |
\fi |
| 1009 |
\fi |
| 1010 |
\fi |
| 1011 |
}% |
| 1012 |
\@mfu@capfmtwordsnext |
| 1013 |
} |
| 1014 |
% \end{macrocode} |
| 1015 |
%\end{macro} |
| 1016 |
% |
| 1017 |
%\begin{macro}{\@@capitalisefmtwords} |
| 1018 |
%\changes{2.03}{2016-07-29}{new} |
| 1019 |
%Check for a group following argument. |
| 1020 |
% \begin{macrocode} |
| 1021 |
\def\@@capitalisefmtwords#1{% |
| 1022 |
\@ifnextchar\bgroup{\@@capfmtsubphrase#1}{\@@capnofmtphrase#1}% |
| 1023 |
} |
| 1024 |
% \end{macrocode} |
| 1025 |
%\end{macro} |
| 1026 |
% |
| 1027 |
%\begin{macro}{\@@capnofmtphrase} |
| 1028 |
%\changes{2.03}{2016-07-29}{new} |
| 1029 |
% \begin{macrocode} |
| 1030 |
\def\@@capnofmtphrase{% |
| 1031 |
\@ifnextchar\bgroup{\@@cap@g@nofmtphrase}{\@@cap@ng@nofmtphrase}% |
| 1032 |
} |
| 1033 |
% \end{macrocode} |
| 1034 |
%\end{macro} |
| 1035 |
%\begin{macro}{\@@cap@ng@nofmtphrase} |
| 1036 |
%\changes{2.04}{2016-07-31}{new} |
| 1037 |
% \begin{macrocode} |
| 1038 |
\def\@@cap@ng@nofmtphrase#1\@mfu@nil{% |
| 1039 |
\gls@add@space |
| 1040 |
\@mfu@mid@capitalisewords{#1}% |
| 1041 |
\def\gls@add@space{ }% |
| 1042 |
} |
| 1043 |
% \end{macrocode} |
| 1044 |
%\end{macro} |
| 1045 |
%\begin{macro}{\@@cap@g@nofmtphrase} |
| 1046 |
%\changes{2.04}{2016-07-31}{new} |
| 1047 |
% \begin{macrocode} |
| 1048 |
\def\@@cap@g@nofmtphrase#1{% |
| 1049 |
\@@cap@ng@nofmtphrase{{#1}}% |
| 1050 |
} |
| 1051 |
% \end{macrocode} |
| 1052 |
%\end{macro} |
| 1053 |
% |
| 1054 |
%\begin{macro}{\@mfu@terminator} |
| 1055 |
%\changes{2.04}{2016-07-31}{new} |
| 1056 |
% \begin{macrocode} |
| 1057 |
\newcommand*\@mfu@terminator{\hbox{}} |
| 1058 |
% \end{macrocode} |
| 1059 |
%\end{macro} |
| 1060 |
% |
| 1061 |
%\begin{macro}{\@@capfmtsubphrase} |
| 1062 |
%\changes{2.03}{2016-07-29}{new} |
| 1063 |
% \begin{macrocode} |
| 1064 |
\def\@@capfmtsubphrase#1#2#3{% |
| 1065 |
% \end{macrocode} |
| 1066 |
%Protect any trailing space at the end of the second argument. |
| 1067 |
% \begin{macrocode} |
| 1068 |
#1{\@capitalisefmtwords#2{\@mfu@terminator} \@mfu@nil{} \unskip}% |
| 1069 |
\def\gls@add@space{ }% |
| 1070 |
\let\@mfu@checkword\mfu@checkword |
| 1071 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 1072 |
{\let\@mfu@fmtsubphrasenext\relax}% |
| 1073 |
{\def\@mfu@fmtsubphrasenext{#3}}% |
| 1074 |
\@mfu@fmtsubphrasenext |
| 1075 |
} |
| 1076 |
% \end{macrocode} |
| 1077 |
%\end{macro} |
| 1078 |
% |
| 1079 |
%\begin{macro}{\@@cap@nofmtphrase} |
| 1080 |
%\changes{2.03}{2016-07-29}{new} |
| 1081 |
% \begin{macrocode} |
| 1082 |
\def\@@cap@nofmtphrase#1 {% |
| 1083 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 1084 |
{% |
| 1085 |
\def\@mfu@capnofmtwordsnext{#1 }% |
| 1086 |
}% |
| 1087 |
{% |
| 1088 |
\def\@mfu@capnofmtwordsnext{% |
| 1089 |
\@capitalisefmtwords#1 \@mfu@nil{} \unskip |
| 1090 |
\def\gls@add@space{ }% |
| 1091 |
\let\@mfu@checkword\mfu@checkword |
| 1092 |
\@capitalisefmtwords |
| 1093 |
}% |
| 1094 |
}% |
| 1095 |
\@mfu@capnofmtwordsnext |
| 1096 |
} |
| 1097 |
% \end{macrocode} |
| 1098 |
%\end{macro} |
| 1099 |
% |
| 1100 |
%\begin{macro}{\xcapitalisefmtwords} |
| 1101 |
%\changes{2.03}{2016-07-29}{new} |
| 1102 |
% Short-cut command: |
| 1103 |
% \begin{macrocode} |
| 1104 |
\newcommand*{\xcapitalisefmtwords}{% |
| 1105 |
\@ifstar\@s@xcapitalisefmtwords\@ns@xcapitalisefmtwords |
| 1106 |
} |
| 1107 |
% \end{macrocode} |
| 1108 |
%\end{macro} |
| 1109 |
%\begin{macro}{\@s@xcapitalisefmtwords} |
| 1110 |
%\changes{2.04}{2016-07-31}{new} |
| 1111 |
% Starred version |
| 1112 |
% \begin{macrocode} |
| 1113 |
\newcommand*{\@s@xcapitalisefmtwords}[1]{% |
| 1114 |
\expandafter\@s@capitalisefmtwords\expandafter{#1}% |
| 1115 |
} |
| 1116 |
% \end{macrocode} |
| 1117 |
%\end{macro} |
| 1118 |
% |
| 1119 |
%\begin{macro}{\@ns@xcapitalisefmtwords} |
| 1120 |
%\changes{2.04}{2016-07-31}{new} |
| 1121 |
% Unstarred version |
| 1122 |
% \begin{macrocode} |
| 1123 |
\newcommand*{\@ns@xcapitalisefmtwords}[1]{% |
| 1124 |
\expandafter\@ns@capitalisefmtwords\expandafter{#1}% |
| 1125 |
} |
| 1126 |
% \end{macrocode} |
| 1127 |
%\end{macro} |
| 1128 |
% |
| 1129 |
%\begin{macro}{\ecapitalisefmtwords} |
| 1130 |
%\changes{2.03}{2016-07-29}{new} |
| 1131 |
% \begin{macrocode} |
| 1132 |
\newrobustcmd*{\ecapitalisefmtwords}{% |
| 1133 |
\@ifstar\@s@ecapitalisefmtwords\@ns@ecapitalisefmtwords |
| 1134 |
} |
| 1135 |
% \end{macrocode} |
| 1136 |
%\end{macro} |
| 1137 |
%\begin{macro}{\@s@ecapitalisefmtwords} |
| 1138 |
%\changes{2.04}{2016-07-31}{new} |
| 1139 |
%Starred version |
| 1140 |
% \begin{macrocode} |
| 1141 |
\newcommand*{\@s@ecapitalisefmtwords}[1]{% |
| 1142 |
\protected@edef\@MFU@caparg{#1}% |
| 1143 |
\expandafter\@s@capitalisefmtwords\expandafter{\@MFU@caparg}% |
| 1144 |
} |
| 1145 |
% \end{macrocode} |
| 1146 |
%\end{macro} |
| 1147 |
% |
| 1148 |
%\begin{macro}{\@ns@ecapitalisefmtwords} |
| 1149 |
%\changes{2.04}{2016-07-31}{new} |
| 1150 |
%Unstarred version |
| 1151 |
% \begin{macrocode} |
| 1152 |
\newcommand*{\@ns@ecapitalisefmtwords}[1]{% |
| 1153 |
\protected@edef\@MFU@caparg{#1}% |
| 1154 |
\expandafter\@ns@capitalisefmtwords\expandafter{\@MFU@caparg}% |
| 1155 |
} |
| 1156 |
% \end{macrocode} |
| 1157 |
%\end{macro} |
| 1158 |
% |
| 1159 |
%The remaining code is redundant and will be removed in future. |
| 1160 |
% |
| 1161 |
%\begin{macro}{\@org@makefirstuc} |
| 1162 |
% This is the original definition of \cs{makefirstuc}. It will be |
| 1163 |
% removed in later versions. |
| 1164 |
% Syntax: |
| 1165 |
%\begin{definition} |
| 1166 |
% \cs{makefirstuc}\marg{text} |
| 1167 |
%\end{definition} |
| 1168 |
%\changes{1.08}{2013-11-04}{made robust} |
| 1169 |
%\changes{2.08}{2022-10-14}{updated to use \cs{MFUsentencecase}} |
| 1170 |
% \begin{macrocode} |
| 1171 |
\newif\if@glscs |
| 1172 |
\newtoks\@glsmfirst |
| 1173 |
\newtoks\@glsmrest |
| 1174 |
\newrobustcmd*{\@org@makefirstuc}[1]{% |
| 1175 |
% \end{macrocode} |
| 1176 |
% Check if argument starts with \cs{protect} which needs to be |
| 1177 |
% skipped. |
| 1178 |
%\changes{2.01}{2015-12-08}{added check for \cs{protect}} |
| 1179 |
% \begin{macrocode} |
| 1180 |
\@MFU@p@makefirstuc#1\relax\relax\relax\@end@MFU@protected{#1}% |
| 1181 |
} |
| 1182 |
% \end{macrocode} |
| 1183 |
%\end{macro} |
| 1184 |
% |
| 1185 |
%\begin{macro}{\@MFU@protect} |
| 1186 |
%\changes{2.03}{2016-07-29}{new} |
| 1187 |
% \begin{macrocode} |
| 1188 |
\newcommand*{\@MFU@protect}{\protect} |
| 1189 |
% \end{macrocode} |
| 1190 |
%\end{macro} |
| 1191 |
% |
| 1192 |
%\begin{macro}{\@MFU@skippunc} |
| 1193 |
%\changes{2.07}{2021-10-15}{new} |
| 1194 |
% \begin{macrocode} |
| 1195 |
\newcommand*{\@MFU@skippunc}{\MFUskippunc} |
| 1196 |
% \end{macrocode} |
| 1197 |
%\end{macro} |
| 1198 |
% |
| 1199 |
%\begin{macro}{\@MFU@p@makefirstuc} |
| 1200 |
% Internal command to do the required action. |
| 1201 |
% \begin{macrocode} |
| 1202 |
\def\@MFU@p@makefirstuc#1#2#3\@end@MFU@protected#4{% |
| 1203 |
% \end{macrocode} |
| 1204 |
%\changes{2.03}{2016-07-29}{changed test} |
| 1205 |
%Test if the first argument is \cs{protect}. |
| 1206 |
% \begin{macrocode} |
| 1207 |
\def\gls@argi{#1}% |
| 1208 |
\ifx\gls@argi\@MFU@protect |
| 1209 |
\@makefirstuc{#2#3}% |
| 1210 |
\else |
| 1211 |
% \end{macrocode} |
| 1212 |
% v2.07+ also check for \cs{MFUskippunc} |
| 1213 |
%\changes{2.07}{2021-10-15}{check for \cs{MFUskippunc}} |
| 1214 |
% \begin{macrocode} |
| 1215 |
\ifx\gls@argi\@MFU@skippunc |
| 1216 |
#2\@makefirstuc{#3}% |
| 1217 |
\else |
| 1218 |
\@makefirstuc{#4}% |
| 1219 |
\fi |
| 1220 |
\fi |
| 1221 |
} |
| 1222 |
% \end{macrocode} |
| 1223 |
%\end{macro} |
| 1224 |
% |
| 1225 |
%\begin{macro}{\@makefirstuc} |
| 1226 |
% Internal command to do the required action. |
| 1227 |
% \begin{macrocode} |
| 1228 |
\newcommand*{\@makefirstuc}[1]{% |
| 1229 |
\def\gls@argi{#1}% |
| 1230 |
\ifx\gls@argi\@empty |
| 1231 |
% \end{macrocode} |
| 1232 |
% If the argument is empty, do nothing. |
| 1233 |
% \begin{macrocode} |
| 1234 |
\else |
| 1235 |
% \end{macrocode} |
| 1236 |
%\changes{1.03}{2008/12/22}{changed \cs{protected@edef} to \cs{def}} |
| 1237 |
% \begin{macrocode} |
| 1238 |
\def\@gls@tmp{\ #1}% |
| 1239 |
\@onelevel@sanitize\@gls@tmp |
| 1240 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1241 |
\if@glscs |
| 1242 |
% \end{macrocode} |
| 1243 |
% Check if we have two sequential control sequences. |
| 1244 |
%\changes{2.0}{2015/09/09}{added check for two control sequences} |
| 1245 |
% \begin{macrocode} |
| 1246 |
\expandafter\def\expandafter\@gls@tmp\expandafter{\expandafter |
| 1247 |
\ \@gobble #1}% |
| 1248 |
\@onelevel@sanitize\@gls@tmp |
| 1249 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1250 |
\if@glscs\@glscsfalse\else\@glscstrue\fi |
| 1251 |
\fi |
| 1252 |
\if@glscs |
| 1253 |
\@gls@getbody #1{}\@nil |
| 1254 |
\ifx\@gls@rest\@empty |
| 1255 |
\glsmakefirstuc{#1}% |
| 1256 |
\else |
| 1257 |
\expandafter\@gls@split\@gls@rest\@nil |
| 1258 |
\ifx\@gls@first\@empty |
| 1259 |
\glsmakefirstuc{#1}% |
| 1260 |
\else |
| 1261 |
% \end{macrocode} |
| 1262 |
%\changes{2.06}{2017-11-14}{check for inner control sequence} |
| 1263 |
%Does \cs{@gls@first} start with a control sequence? |
| 1264 |
% \begin{macrocode} |
| 1265 |
\edef\@gls@tmp\expandafter{\noexpand\ \expandonce\@gls@first}% |
| 1266 |
\@onelevel@sanitize\@gls@tmp |
| 1267 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1268 |
\if@glscs |
| 1269 |
\edef\@gls@domfirstuc{\expandonce\@gls@body |
| 1270 |
{\noexpand\makefirstuc{\expandonce\@gls@first |
| 1271 |
\expandonce\@gls@rest}% |
| 1272 |
}% |
| 1273 |
}% |
| 1274 |
\else |
| 1275 |
\expandafter\@glsmfirst\expandafter{\@gls@first}% |
| 1276 |
\expandafter\@glsmrest\expandafter{\@gls@rest}% |
| 1277 |
% \end{macrocode} |
| 1278 |
%\changes{2.06}{2017-11-14}{added braces to \cs{glsmakefirstuc} argument} |
| 1279 |
% \begin{macrocode} |
| 1280 |
\edef\@gls@domfirstuc{\noexpand\@gls@body |
| 1281 |
{\noexpand\glsmakefirstuc{\the\@glsmfirst}}% |
| 1282 |
\the\@glsmrest}% |
| 1283 |
\fi |
| 1284 |
\@gls@domfirstuc |
| 1285 |
\fi |
| 1286 |
\fi |
| 1287 |
\else |
| 1288 |
\glsmakefirstuc{#1}% |
| 1289 |
\fi |
| 1290 |
\fi |
| 1291 |
} |
| 1292 |
% \end{macrocode} |
| 1293 |
%\end{macro} |
| 1294 |
%\begin{macro}{\@gls@split} |
| 1295 |
% Put first argument in \cs{@gls@first} and second argument in |
| 1296 |
% \cs{@gls@rest}: |
| 1297 |
%\changes{2.03}{2016-07-29}{added check for datatool-base UTF-8 support} |
| 1298 |
% \begin{macrocode} |
| 1299 |
\ifdef\dtl@getfirst@UTFviii |
| 1300 |
{% |
| 1301 |
\def\@gls@split#1#2\@nil{% |
| 1302 |
\ifbool{@dtl@utf8} |
| 1303 |
{% |
| 1304 |
\expandafter\dtl@if@two@octets#1#2\relax\dtl@end@if@two@octets |
| 1305 |
{% |
| 1306 |
\dtl@getfirst@UTFviii#1#2\@nil\end@dtl@getfirst@UTFviii |
| 1307 |
\let\@gls@first\dtl@first |
| 1308 |
\let\@gls@rest\dtl@rest |
| 1309 |
}% |
| 1310 |
{% |
| 1311 |
\def\@gls@first{#1}\def\@gls@rest{#2}% |
| 1312 |
}% |
| 1313 |
}% |
| 1314 |
{% |
| 1315 |
% \end{macrocode} |
| 1316 |
%\changes{2.04}{2016-07-31}{added missing false part} |
| 1317 |
% \begin{macrocode} |
| 1318 |
\def\@gls@first{#1}\def\@gls@rest{#2}% |
| 1319 |
}% |
| 1320 |
} |
| 1321 |
}% |
| 1322 |
{% |
| 1323 |
\def\@gls@split#1#2\@nil{% |
| 1324 |
\def\@gls@first{#1}\def\@gls@rest{#2}% |
| 1325 |
} |
| 1326 |
} |
| 1327 |
% \end{macrocode} |
| 1328 |
%\end{macro} |
| 1329 |
% \begin{macrocode} |
| 1330 |
\def\@gls@checkcs#1 #2#3\relax{% |
| 1331 |
\def\@gls@argi{#1}\def\@gls@argii{#2}% |
| 1332 |
\ifx\@gls@argi\@gls@argii |
| 1333 |
\@glscstrue |
| 1334 |
\else |
| 1335 |
\@glscsfalse |
| 1336 |
\fi |
| 1337 |
} |
| 1338 |
% \end{macrocode} |
| 1339 |
% Has \sty{datatool-base} v2.24 (or above) been loaded? If so and we |
| 1340 |
% have UTF-8 enabled, we can grab the first octet. |
| 1341 |
%\begin{macro}{\@mfu@applytofirst} |
| 1342 |
%\changes{2.03}{2016-07-29}{new} |
| 1343 |
% \begin{macrocode} |
| 1344 |
\ifdef\dtl@getfirst@UTFviii |
| 1345 |
{% |
| 1346 |
\def\@mfu@applytofirst#1#2\@mfu@end@applytofirst#3{% |
| 1347 |
\expandafter\dtl@if@two@octets#1#2\relax\dtl@end@if@two@octets |
| 1348 |
{% |
| 1349 |
\dtl@getfirst@UTFviii#1#2\@nil\end@dtl@getfirst@UTFviii |
| 1350 |
\expandafter#3\expandafter{\dtl@first}\dtl@rest |
| 1351 |
}% |
| 1352 |
{% |
| 1353 |
% \end{macrocode} |
| 1354 |
%First argument needs to be grouped in case it consists of more than |
| 1355 |
%one token. |
| 1356 |
%\changes{2.05}{2017-11-10}{grouped first argument} |
| 1357 |
% \begin{macrocode} |
| 1358 |
#3{#1}#2% |
| 1359 |
}% |
| 1360 |
}% |
| 1361 |
}% |
| 1362 |
{% |
| 1363 |
% \end{macrocode} |
| 1364 |
%First argument needs to be grouped in case it consists of more than |
| 1365 |
%one token. |
| 1366 |
%\changes{2.05}{2017-11-10}{grouped first argument} |
| 1367 |
% \begin{macrocode} |
| 1368 |
\def\@mfu@applytofirst#1#2\@mfu@end@applytofirst#3{% |
| 1369 |
#3{#1}#2% |
| 1370 |
} |
| 1371 |
} |
| 1372 |
% \end{macrocode} |
| 1373 |
%\end{macro} |
| 1374 |
% |
| 1375 |
%\begin{macro}{\MFUapplytofirst} |
| 1376 |
%\changes{2.03}{2016-07-29}{new} |
| 1377 |
%\changes{2.08}{2022-10-14}{deprecated} |
| 1378 |
%\begin{definition} |
| 1379 |
%\cs{MFUapplytofirst}\marg{cs}\marg{text} |
| 1380 |
%\end{definition} |
| 1381 |
% Apply \meta{cs} to first token of text, or first UTF-8 character |
| 1382 |
% if \sty{datatool-base} v2.24 above has been loaded with the utf8 |
| 1383 |
% support enabled. Deprecated as from v2.08. |
| 1384 |
% \begin{macrocode} |
| 1385 |
\ifdef\dtl@getfirst@UTFviii |
| 1386 |
{% |
| 1387 |
\newcommand*{\MFUapplytofirst}[2]{% |
| 1388 |
\ifbool{@dtl@utf8} |
| 1389 |
{% |
| 1390 |
\ifblank{#2}% |
| 1391 |
{#1{#2}}% |
| 1392 |
{% |
| 1393 |
\ifblank{#1}% |
| 1394 |
{#1#2}% |
| 1395 |
{% |
| 1396 |
\@mfu@applytofirst#2\@mfu@end@applytofirst#1\relax |
| 1397 |
}% |
| 1398 |
}% |
| 1399 |
}% |
| 1400 |
{% |
| 1401 |
#1#2% |
| 1402 |
}% |
| 1403 |
} |
| 1404 |
}% |
| 1405 |
{% |
| 1406 |
\newcommand*{\MFUapplytofirst}[2]{% |
| 1407 |
#1#2% |
| 1408 |
} |
| 1409 |
} |
| 1410 |
% \end{macrocode} |
| 1411 |
%\end{macro} |
| 1412 |
% |
| 1413 |
%\begin{macro}{\@gls@makefirstuc} |
| 1414 |
%\changes{2.08}{2022-10-14}{updated to use \cs{MFUsentencecase}} |
| 1415 |
%Deprecated. |
| 1416 |
% \begin{macrocode} |
| 1417 |
\def\@gls@makefirstuc#1{\MFUsentencecase{#1}} |
| 1418 |
% \end{macrocode} |
| 1419 |
%\end{macro} |
| 1420 |
% |
| 1421 |
% Get the first grouped argument and store in \cs{@gls@body}. |
| 1422 |
% \begin{macrocode} |
| 1423 |
\def\@gls@getbody#1#{\def\@gls@body{#1}\@gls@gobbletonil} |
| 1424 |
% \end{macrocode} |
| 1425 |
% Scoup up everything to \cs{@nil} and store in \cs{@gls@rest}: |
| 1426 |
% \begin{macrocode} |
| 1427 |
\def\@gls@gobbletonil#1\@nil{\def\@gls@rest{#1}} |
| 1428 |
% \end{macrocode} |
| 1429 |
% |
| 1430 |
%\iffalse |
| 1431 |
% \begin{macrocode} |
| 1432 |
%</mfirstuc.sty> |
| 1433 |
% \end{macrocode} |
| 1434 |
%\fi |
| 1435 |
%\iffalse |
| 1436 |
% \begin{macrocode} |
| 1437 |
%<*mfirstuc-english.sty> |
| 1438 |
% \end{macrocode} |
| 1439 |
%\fi |
| 1440 |
%\subsection{Mfirstuc-english Documented Code} |
| 1441 |
%\label{sec:code:mfirstuc-english} |
| 1442 |
% \begin{macrocode} |
| 1443 |
\NeedsTeXFormat{LaTeX2e} |
| 1444 |
\ProvidesPackage{mfirstuc-english}[2025/04/03 v2.09 (NLCT)] |
| 1445 |
% \end{macrocode} |
| 1446 |
% Load \sty{mfirstuc} if not already loaded: |
| 1447 |
% \begin{macrocode} |
| 1448 |
\RequirePackage{mfirstuc} |
| 1449 |
% \end{macrocode} |
| 1450 |
% Add no-cap words. This list isn't complete. I~don't intend adding |
| 1451 |
% disputed words. Additional words can be added to the document in |
| 1452 |
% a~similar manner. |
| 1453 |
% \begin{macrocode} |
| 1454 |
\MFUnocap{a} |
| 1455 |
\MFUnocap{an} |
| 1456 |
\MFUnocap{and} |
| 1457 |
\MFUnocap{but} |
| 1458 |
\MFUnocap{for} |
| 1459 |
\MFUnocap{in} |
| 1460 |
\MFUnocap{of} |
| 1461 |
\MFUnocap{or} |
| 1462 |
\MFUnocap{no} |
| 1463 |
\MFUnocap{nor} |
| 1464 |
\MFUnocap{so} |
| 1465 |
\MFUnocap{some} |
| 1466 |
\MFUnocap{the} |
| 1467 |
\MFUnocap{with} |
| 1468 |
\MFUnocap{yet} |
| 1469 |
% \end{macrocode} |
| 1470 |
%\iffalse |
| 1471 |
% \begin{macrocode} |
| 1472 |
%</mfirstuc-english.sty> |
| 1473 |
% \end{macrocode} |
| 1474 |
%\fi |
| 1475 |
%\iffalse |
| 1476 |
% \begin{macrocode} |
| 1477 |
%<*mfirstuc-2021-10-15.sty> |
| 1478 |
% \end{macrocode} |
| 1479 |
%\fi |
| 1480 |
% \section{Rollback v2.07 (mfirstuc-2021-10-15.sty)} |
| 1481 |
% Version 2.07 preserved for rollback. |
| 1482 |
% \begin{macrocode} |
| 1483 |
\NeedsTeXFormat{LaTeX2e} |
| 1484 |
\ProvidesPackage{mfirstuc}[2021/10/15 v2.07 (NLCT)] |
| 1485 |
\RequirePackage{etoolbox} |
| 1486 |
\newif\if@glscs |
| 1487 |
\newtoks\@glsmfirst |
| 1488 |
\newtoks\@glsmrest |
| 1489 |
\newrobustcmd*{\makefirstuc}[1]{% |
| 1490 |
\@MFU@p@makefirstuc#1\relax\relax\relax\@end@MFU@protected{#1}% |
| 1491 |
} |
| 1492 |
\newcommand*{\@MFU@protect}{\protect} |
| 1493 |
\newcommand*{\@MFU@skippunc}{\MFUskippunc} |
| 1494 |
\newrobustcmd*{\MFUskippunc}[1]{#1} |
| 1495 |
\def\@MFU@p@makefirstuc#1#2#3\@end@MFU@protected#4{% |
| 1496 |
\def\gls@argi{#1}% |
| 1497 |
\ifx\gls@argi\@MFU@protect |
| 1498 |
\@makefirstuc{#2#3}% |
| 1499 |
\else |
| 1500 |
\ifx\gls@argi\@MFU@skippunc |
| 1501 |
#2\@makefirstuc{#3}% |
| 1502 |
\else |
| 1503 |
\@makefirstuc{#4}% |
| 1504 |
\fi |
| 1505 |
\fi |
| 1506 |
} |
| 1507 |
\newcommand*{\@makefirstuc}[1]{% |
| 1508 |
\def\gls@argi{#1}% |
| 1509 |
\ifx\gls@argi\@empty |
| 1510 |
\else |
| 1511 |
\def\@gls@tmp{\ #1}% |
| 1512 |
\@onelevel@sanitize\@gls@tmp |
| 1513 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1514 |
\if@glscs |
| 1515 |
\expandafter\def\expandafter\@gls@tmp\expandafter{\expandafter |
| 1516 |
\ \@gobble #1}% |
| 1517 |
\@onelevel@sanitize\@gls@tmp |
| 1518 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1519 |
\if@glscs\@glscsfalse\else\@glscstrue\fi |
| 1520 |
\fi |
| 1521 |
\if@glscs |
| 1522 |
\@gls@getbody #1{}\@nil |
| 1523 |
\ifx\@gls@rest\@empty |
| 1524 |
\glsmakefirstuc{#1}% |
| 1525 |
\else |
| 1526 |
\expandafter\@gls@split\@gls@rest\@nil |
| 1527 |
\ifx\@gls@first\@empty |
| 1528 |
\glsmakefirstuc{#1}% |
| 1529 |
\else |
| 1530 |
\edef\@gls@tmp\expandafter{\noexpand\ \expandonce\@gls@first}% |
| 1531 |
\@onelevel@sanitize\@gls@tmp |
| 1532 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1533 |
\if@glscs |
| 1534 |
\edef\@gls@domfirstuc{\expandonce\@gls@body |
| 1535 |
{\noexpand\makefirstuc{\expandonce\@gls@first |
| 1536 |
\expandonce\@gls@rest}% |
| 1537 |
}% |
| 1538 |
}% |
| 1539 |
\else |
| 1540 |
\expandafter\@glsmfirst\expandafter{\@gls@first}% |
| 1541 |
\expandafter\@glsmrest\expandafter{\@gls@rest}% |
| 1542 |
\edef\@gls@domfirstuc{\noexpand\@gls@body |
| 1543 |
{\noexpand\glsmakefirstuc{\the\@glsmfirst}}% |
| 1544 |
\the\@glsmrest}% |
| 1545 |
\fi |
| 1546 |
\@gls@domfirstuc |
| 1547 |
\fi |
| 1548 |
\fi |
| 1549 |
\else |
| 1550 |
\glsmakefirstuc{#1}% |
| 1551 |
\fi |
| 1552 |
\fi |
| 1553 |
} |
| 1554 |
\ifdef\dtl@getfirst@UTFviii |
| 1555 |
{% |
| 1556 |
\def\@gls@split#1#2\@nil{% |
| 1557 |
\ifbool{@dtl@utf8} |
| 1558 |
{% |
| 1559 |
\expandafter\dtl@if@two@octets#1#2\relax\dtl@end@if@two@octets |
| 1560 |
{% |
| 1561 |
\dtl@getfirst@UTFviii#1#2\@nil\end@dtl@getfirst@UTFviii |
| 1562 |
\let\@gls@first\dtl@first |
| 1563 |
\let\@gls@rest\dtl@rest |
| 1564 |
}% |
| 1565 |
{% |
| 1566 |
\def\@gls@first{#1}\def\@gls@rest{#2}% |
| 1567 |
}% |
| 1568 |
}% |
| 1569 |
{% |
| 1570 |
\def\@gls@first{#1}\def\@gls@rest{#2}% |
| 1571 |
}% |
| 1572 |
} |
| 1573 |
}% |
| 1574 |
{% |
| 1575 |
\def\@gls@split#1#2\@nil{% |
| 1576 |
\def\@gls@first{#1}\def\@gls@rest{#2}% |
| 1577 |
} |
| 1578 |
} |
| 1579 |
\def\@gls@checkcs#1 #2#3\relax{% |
| 1580 |
\def\@gls@argi{#1}\def\@gls@argii{#2}% |
| 1581 |
\ifx\@gls@argi\@gls@argii |
| 1582 |
\@glscstrue |
| 1583 |
\else |
| 1584 |
\@glscsfalse |
| 1585 |
\fi |
| 1586 |
} |
| 1587 |
\ifdef\dtl@getfirst@UTFviii |
| 1588 |
{% |
| 1589 |
\def\@mfu@applytofirst#1#2\@mfu@end@applytofirst#3{% |
| 1590 |
\expandafter\dtl@if@two@octets#1#2\relax\dtl@end@if@two@octets |
| 1591 |
{% |
| 1592 |
\dtl@getfirst@UTFviii#1#2\@nil\end@dtl@getfirst@UTFviii |
| 1593 |
\expandafter#3\expandafter{\dtl@first}\dtl@rest |
| 1594 |
}% |
| 1595 |
{% |
| 1596 |
#3{#1}#2% |
| 1597 |
}% |
| 1598 |
}% |
| 1599 |
}% |
| 1600 |
{% |
| 1601 |
\def\@mfu@applytofirst#1#2\@mfu@end@applytofirst#3{#3{#1}#2} |
| 1602 |
} |
| 1603 |
\ifdef\dtl@getfirst@UTFviii |
| 1604 |
{% |
| 1605 |
\newcommand*{\MFUapplytofirst}[2]{% |
| 1606 |
\ifbool{@dtl@utf8} |
| 1607 |
{% |
| 1608 |
\ifblank{#2}% |
| 1609 |
{#1{#2}}% |
| 1610 |
{% |
| 1611 |
\ifblank{#1}% |
| 1612 |
{#1#2}% |
| 1613 |
{% |
| 1614 |
\@mfu@applytofirst#2\@mfu@end@applytofirst#1\relax |
| 1615 |
}% |
| 1616 |
}% |
| 1617 |
}% |
| 1618 |
{% |
| 1619 |
#1#2% |
| 1620 |
}% |
| 1621 |
} |
| 1622 |
}% |
| 1623 |
{% |
| 1624 |
\newcommand*{\MFUapplytofirst}[2]{#1#2} |
| 1625 |
} |
| 1626 |
\def\@gls@makefirstuc#1{\MFUapplytofirst\mfirstucMakeUppercase{#1}} |
| 1627 |
\newcommand*{\mfirstucMakeUppercase}{\MakeUppercase} |
| 1628 |
\newcommand*{\glsmakefirstuc}[1]{\@gls@makefirstuc{#1}} |
| 1629 |
\def\@gls@getbody#1#{\def\@gls@body{#1}\@gls@gobbletonil} |
| 1630 |
\def\@gls@gobbletonil#1\@nil{\def\@gls@rest{#1}} |
| 1631 |
\newcommand*{\xmakefirstuc}[1]{% |
| 1632 |
\expandafter\makefirstuc\expandafter{#1}% |
| 1633 |
} |
| 1634 |
\newrobustcmd*{\emakefirstuc}[1]{% |
| 1635 |
\protected@edef\@MFU@caparg{#1}% |
| 1636 |
\expandafter\makefirstuc\expandafter{\@MFU@caparg}% |
| 1637 |
} |
| 1638 |
\newrobustcmd*{\capitalisewords}[1]{% |
| 1639 |
\let\@mfu@checkword\@gobble |
| 1640 |
\def\gls@add@space{}% |
| 1641 |
\let\@mfu@domakefirstuc\@MFU@dofirst@capword |
| 1642 |
\mfu@capitalisewords#1 \@nil\mfu@endcap |
| 1643 |
} |
| 1644 |
\newcommand*{\@mfu@mid@capitalisewords}[1]{% |
| 1645 |
\def\gls@add@space{}% |
| 1646 |
\let\@mfu@domakefirstuc\@MFU@do@capword |
| 1647 |
\mfu@capitalisewords#1 \@nil\mfu@endcap |
| 1648 |
} |
| 1649 |
\def\mfu@capitalisewords#1 #2\mfu@endcap{% |
| 1650 |
\def\mfu@cap@first{#1}% |
| 1651 |
\def\mfu@cap@second{#2}% |
| 1652 |
\gls@add@space |
| 1653 |
\@mfu@checkword{#1}% |
| 1654 |
\@mfu@domakefirstuc{#1}% |
| 1655 |
\def\gls@add@space{ }% |
| 1656 |
\ifx\mfu@cap@second\@nnil |
| 1657 |
\let\next@mfu@cap\mfu@noop |
| 1658 |
\else |
| 1659 |
\let\next@mfu@cap\mfu@capitalisewords |
| 1660 |
\let\@mfu@checkword\mfu@checkword |
| 1661 |
\fi |
| 1662 |
\next@mfu@cap#2\mfu@endcap |
| 1663 |
} |
| 1664 |
\def\mfu@noop#1\mfu@endcap{} |
| 1665 |
\newif\ifMFUhyphen |
| 1666 |
\MFUhyphenfalse |
| 1667 |
\newcommand*{\@MFU@do@capword}[1]{% |
| 1668 |
\let\@MFU@cappingword\MFUcapword |
| 1669 |
\@MFUwordbreak#1\MFUwordbreak{}\@nil\@endMFUwordbreak |
| 1670 |
} |
| 1671 |
\newcommand*{\@MFU@dofirst@capword}[1]{% |
| 1672 |
\let\@MFU@cappingword\MFUcapword |
| 1673 |
\@MFUfirstwordbreak#1\MFUwordbreak{}\@nil\@endMFUfirstwordbreak |
| 1674 |
} |
| 1675 |
\newcommand*{\MFUcapword}[1]{% |
| 1676 |
\ifMFUhyphen |
| 1677 |
\MFUhyphencapword{#1}% |
| 1678 |
\else |
| 1679 |
\MFUcapwordfirstuc{#1}% |
| 1680 |
\fi |
| 1681 |
} |
| 1682 |
\newcommand*{\MFUcapwordfirstuc}[1]{% |
| 1683 |
\makefirstuc{#1}% |
| 1684 |
} |
| 1685 |
\newrobustcmd*{\MFUwordbreak}[1]{#1} |
| 1686 |
\newcommand*{\MFUhyphencapword}[1]{% |
| 1687 |
\@MFUcapword#1-\@nil\@endMFUcapword |
| 1688 |
} |
| 1689 |
\def\@MFUcapword#1-#2\@endMFUcapword{% |
| 1690 |
\MFUcapwordfirstuc{#1}% |
| 1691 |
\def\@mfu@argii{#2}% |
| 1692 |
\ifx\@mfu@argii\@nnil |
| 1693 |
\else |
| 1694 |
-\@MFUcapword#2\@endMFUcapword |
| 1695 |
\fi |
| 1696 |
} |
| 1697 |
\def\@MFUwordbreak#1\MFUwordbreak#2#3\@endMFUwordbreak{% |
| 1698 |
\def\@mfu@argiii{#3}% |
| 1699 |
\ifx\@mfu@argiii\@nnil |
| 1700 |
\@MFU@cappingword{#1}% |
| 1701 |
\else |
| 1702 |
\let\@MFU@cappingword\@MFU@wordbreakcapword |
| 1703 |
\@MFU@cappingword{#1}% |
| 1704 |
#2\@MFUwordbreak#3\@endMFUwordbreak |
| 1705 |
\fi |
| 1706 |
} |
| 1707 |
\newcommand*{\@MFU@wordbreakcapword}[1]{% |
| 1708 |
\mfu@checkword{#1}% |
| 1709 |
\@mfu@domakefirstuc{#1}% |
| 1710 |
} |
| 1711 |
\def\@MFUfirstwordbreak#1\MFUwordbreak#2#3\@endMFUfirstwordbreak{% |
| 1712 |
\def\@mfu@argiii{#3}% |
| 1713 |
\ifx\@mfu@argiii\@nnil |
| 1714 |
\@MFU@cappingword{#1}% |
| 1715 |
\else |
| 1716 |
\let\@MFU@cappingword\@MFU@firstwordbreakcapword |
| 1717 |
\@MFU@cappingword{#1}% |
| 1718 |
#2\@MFUfirstwordbreak#3\@endMFUfirstwordbreak |
| 1719 |
\fi |
| 1720 |
} |
| 1721 |
\newcommand*{\@MFU@firstwordbreakcapword}[1]{% |
| 1722 |
\@mfu@domakefirstuc{#1}% |
| 1723 |
} |
| 1724 |
\newcommand*\mfu@checkword[1]{% |
| 1725 |
\def\mfu@checkword@arg{#1}% |
| 1726 |
\let\@mfu@domakefirstuc\@MFU@do@capword |
| 1727 |
\forlistloop\mfu@checkword@do\@mfu@nocaplist |
| 1728 |
} |
| 1729 |
\newcommand*{\mfu@checkword@do}[1]{% |
| 1730 |
\def\mfu@checkword@argii{#1}% |
| 1731 |
\ifdefequal\mfu@checkword@arg\mfu@checkword@argii |
| 1732 |
{% |
| 1733 |
\let\@mfu@domakefirstuc\@firstofone |
| 1734 |
\listbreak |
| 1735 |
}% |
| 1736 |
{% |
| 1737 |
\def\mfu@checkword@argii{#1{\@mfu@terminator}}% |
| 1738 |
\ifdefequal\mfu@checkword@arg\mfu@checkword@argii |
| 1739 |
{% |
| 1740 |
\let\@mfu@domakefirstuc\@firstofone |
| 1741 |
\listbreak |
| 1742 |
}% |
| 1743 |
{}% |
| 1744 |
}% |
| 1745 |
} |
| 1746 |
\newcommand*{\@mfu@nocaplist}{} |
| 1747 |
\newcommand*{\MFUnocap}[1]{\listadd{\@mfu@nocaplist}{#1}} |
| 1748 |
\newcommand*{\gMFUnocap}[1]{\listgadd{\@mfu@nocaplist}{#1}} |
| 1749 |
\newcommand*{\MFUclear}{\renewcommand*{\@mfu@nocaplist}{}} |
| 1750 |
\newcommand*{\xcapitalisewords}[1]{% |
| 1751 |
\expandafter\capitalisewords\expandafter{#1}% |
| 1752 |
} |
| 1753 |
\newrobustcmd*{\ecapitalisewords}[1]{% |
| 1754 |
\protected@edef\@MFU@caparg{#1}% |
| 1755 |
\expandafter\capitalisewords\expandafter{\@MFU@caparg}% |
| 1756 |
} |
| 1757 |
\newcommand\@mfu@nil{\unskip} |
| 1758 |
\newcommand*\@mfu@nnil{\@mfu@nil} |
| 1759 |
\newcommand*{\capitalisefmtwords}{% |
| 1760 |
\@ifstar\@s@capitalisefmtwords\@ns@capitalisefmtwords |
| 1761 |
} |
| 1762 |
\newcommand*{\@s@capitalisefmtwords}[1]{% |
| 1763 |
\@@s@checkgrp@@capitalisefmtwords#1\@nil |
| 1764 |
} |
| 1765 |
\newcommand*{\@@s@checkgrp@@capitalisefmtwords}{% |
| 1766 |
\@ifnextchar\bgroup{\@@s@nocs@capitalisefmtwords}{\@@s@capitalisefmtwords}% |
| 1767 |
} |
| 1768 |
\def\@@s@nocs@capitalisefmtwords#1\@nil{% |
| 1769 |
\capitalisewords{#1}% |
| 1770 |
} |
| 1771 |
\newcommand*{\@@s@capitalisefmtwords}[1]{% |
| 1772 |
\def\gls@argi{#1}% |
| 1773 |
\ifx\gls@argi\@MFU@protect |
| 1774 |
\let\@mfu@capfmtwordsnext\@@s@capitalisefmtwords |
| 1775 |
\else |
| 1776 |
\ifx\gls@argi\@nnil |
| 1777 |
\let\@mfu@capfmtwordsnext\relax |
| 1778 |
\else |
| 1779 |
\def\@gls@tmp{\ #1}% |
| 1780 |
\@onelevel@sanitize\@gls@tmp |
| 1781 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1782 |
\if@glscs |
| 1783 |
\def\@mfu@capfmtwordsnext{\@@s@cs@capitalisefmtwords#1}% |
| 1784 |
\else |
| 1785 |
\def\@mfu@capfmtwordsnext{\@@s@nocs@capitalisefmtwords#1}% |
| 1786 |
\fi |
| 1787 |
\fi |
| 1788 |
\fi |
| 1789 |
\@mfu@capfmtwordsnext |
| 1790 |
} |
| 1791 |
\newcommand*{\@@s@cs@capitalisefmtwords}[1]{% |
| 1792 |
\@ifnextchar\bgroup |
| 1793 |
{\@@s@cs@g@capitalisefmtwords#1}% |
| 1794 |
{\@@s@cs@ng@capitalisefmtwords#1}% |
| 1795 |
} |
| 1796 |
\def\@@s@cs@g@capitalisefmtwords#1#2#3\@nil{% |
| 1797 |
#1{\capitalisewords{#2}}% |
| 1798 |
\ifblank{#3}% |
| 1799 |
{}% |
| 1800 |
{% |
| 1801 |
\def\gls@add@space{}% |
| 1802 |
\let\@mfu@checkword\mfu@checkword |
| 1803 |
\mfu@capitalisewords#3 \@nil\mfu@endcap |
| 1804 |
}% |
| 1805 |
} |
| 1806 |
\def\@@s@cs@ng@capitalisefmtwords#1#2\@nil{% |
| 1807 |
\capitalisewords{#1#2}% |
| 1808 |
} |
| 1809 |
\newcommand*{\@ns@capitalisefmtwords}[1]{% |
| 1810 |
\let\@mfu@checkword\@gobble |
| 1811 |
\def\gls@add@space{}% |
| 1812 |
\@capitalisefmtwords#1 \@mfu@nil{} \unskip |
| 1813 |
} |
| 1814 |
\newcommand*{\@capitalisefmtwords}{% |
| 1815 |
\@ifnextchar\bgroup{\@capitalise@g@fmtwords}{\@capitalise@ng@fmtwords}% |
| 1816 |
} |
| 1817 |
\newcommand*{\@capitalise@g@fmtwords}[1]{% |
| 1818 |
\@capitalise@ng@fmtwords{{#1}}% |
| 1819 |
} |
| 1820 |
\def\@mfu@ifnil#1#2\@mfu@end@nil#3#4{% |
| 1821 |
\def\gls@argi{#1}% |
| 1822 |
\ifx\gls@argi\@mfu@nnil |
| 1823 |
#3% |
| 1824 |
\else |
| 1825 |
#4% |
| 1826 |
\fi |
| 1827 |
} |
| 1828 |
\def\@capitalise@ng@fmtwords#1 {% |
| 1829 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 1830 |
{% |
| 1831 |
\def\@mfu@capfmtwordsnext{#1}% |
| 1832 |
}% |
| 1833 |
{% |
| 1834 |
\def\@mfu@capfmtwordsnext{% |
| 1835 |
\@capitalise@fmtwords#1\@mfu@nil |
| 1836 |
\def\gls@add@space{ }% |
| 1837 |
\let\@mfu@checkword\mfu@checkword |
| 1838 |
\@@cap@nofmtphrase}% |
| 1839 |
}% |
| 1840 |
\@mfu@capfmtwordsnext |
| 1841 |
}% |
| 1842 |
\def\@capitalise@fmtwords#1{% |
| 1843 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 1844 |
{% |
| 1845 |
\def\@mfu@capfmtwordsnext{#1}% |
| 1846 |
}% |
| 1847 |
{% |
| 1848 |
\def\gls@argi{#1}% |
| 1849 |
\ifx\gls@argi\@MFU@protect |
| 1850 |
\def\@mfu@capfmtwordsnext{\@capitalise@fmtwords}% |
| 1851 |
\else |
| 1852 |
\def\@gls@tmp{\ #1}% |
| 1853 |
\@onelevel@sanitize\@gls@tmp |
| 1854 |
\expandafter\@gls@checkcs\@gls@tmp\relax\relax |
| 1855 |
\if@glscs |
| 1856 |
\def\@mfu@capfmtwordsnext{\@@capitalisefmtwords#1}% |
| 1857 |
\else |
| 1858 |
\ifx\gls@argi\@empty |
| 1859 |
\def\@mfu@capfmtwordsnext{\@@capnofmtphrase{}}% |
| 1860 |
\else |
| 1861 |
\def\@mfu@capfmtwordsnext{\@@capnofmtphrase#1}% |
| 1862 |
\fi |
| 1863 |
\fi |
| 1864 |
\fi |
| 1865 |
}% |
| 1866 |
\@mfu@capfmtwordsnext |
| 1867 |
} |
| 1868 |
\def\@@capitalisefmtwords#1{% |
| 1869 |
\@ifnextchar\bgroup{\@@capfmtsubphrase#1}{\@@capnofmtphrase#1}% |
| 1870 |
} |
| 1871 |
\def\@@capnofmtphrase{% |
| 1872 |
\@ifnextchar\bgroup{\@@cap@g@nofmtphrase}{\@@cap@ng@nofmtphrase}% |
| 1873 |
} |
| 1874 |
\def\@@cap@ng@nofmtphrase#1\@mfu@nil{% |
| 1875 |
\gls@add@space |
| 1876 |
\@mfu@mid@capitalisewords{#1}% |
| 1877 |
\def\gls@add@space{ }% |
| 1878 |
} |
| 1879 |
\def\@@cap@g@nofmtphrase#1{% |
| 1880 |
\@@cap@ng@nofmtphrase{{#1}}% |
| 1881 |
} |
| 1882 |
\newcommand*\@mfu@terminator{\hbox{}} |
| 1883 |
\def\@@capfmtsubphrase#1#2#3{% |
| 1884 |
#1{\@capitalisefmtwords#2{\@mfu@terminator} \@mfu@nil{} \unskip}% |
| 1885 |
\def\gls@add@space{ }% |
| 1886 |
\let\@mfu@checkword\mfu@checkword |
| 1887 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 1888 |
{\let\@mfu@fmtsubphrasenext\relax}% |
| 1889 |
{\def\@mfu@fmtsubphrasenext{#3}}% |
| 1890 |
\@mfu@fmtsubphrasenext |
| 1891 |
} |
| 1892 |
\def\@@cap@nofmtphrase#1 {% |
| 1893 |
\@mfu@ifnil#1\relax\relax\@mfu@end@nil |
| 1894 |
{% |
| 1895 |
\def\@mfu@capnofmtwordsnext{#1 }% |
| 1896 |
}% |
| 1897 |
{% |
| 1898 |
\def\@mfu@capnofmtwordsnext{% |
| 1899 |
\@capitalisefmtwords#1 \@mfu@nil{} \unskip |
| 1900 |
\def\gls@add@space{ }% |
| 1901 |
\let\@mfu@checkword\mfu@checkword |
| 1902 |
\@capitalisefmtwords |
| 1903 |
}% |
| 1904 |
}% |
| 1905 |
\@mfu@capnofmtwordsnext |
| 1906 |
} |
| 1907 |
\newcommand*{\xcapitalisefmtwords}{% |
| 1908 |
\@ifstar\@s@xcapitalisefmtwords\@ns@xcapitalisefmtwords |
| 1909 |
} |
| 1910 |
\newcommand*{\@s@xcapitalisefmtwords}[1]{% |
| 1911 |
\expandafter\@s@capitalisefmtwords\expandafter{#1}% |
| 1912 |
} |
| 1913 |
\newcommand*{\@ns@xcapitalisefmtwords}[1]{% |
| 1914 |
\expandafter\@ns@capitalisefmtwords\expandafter{#1}% |
| 1915 |
} |
| 1916 |
\newrobustcmd*{\ecapitalisefmtwords}{% |
| 1917 |
\@ifstar\@s@ecapitalisefmtwords\@ns@ecapitalisefmtwords |
| 1918 |
} |
| 1919 |
\newcommand*{\@s@ecapitalisefmtwords}[1]{% |
| 1920 |
\protected@edef\@MFU@caparg{#1}% |
| 1921 |
\expandafter\@s@capitalisefmtwords\expandafter{\@MFU@caparg}% |
| 1922 |
} |
| 1923 |
\newcommand*{\@ns@ecapitalisefmtwords}[1]{% |
| 1924 |
\protected@edef\@MFU@caparg{#1}% |
| 1925 |
\expandafter\@ns@capitalisefmtwords\expandafter{\@MFU@caparg}% |
| 1926 |
} |
| 1927 |
% \end{macrocode} |
| 1928 |
%\iffalse |
| 1929 |
% \begin{macrocode} |
| 1930 |
%</mfirstuc-2021-10-15.sty> |
| 1931 |
% \end{macrocode} |
| 1932 |
%\fi |
| 1933 |
%\iffalse |
| 1934 |
% \begin{macrocode} |
| 1935 |
%<*sample-mfirstuc.tex> |
| 1936 |
% \end{macrocode} |
| 1937 |
%\fi |
| 1938 |
%\iffalse |
| 1939 |
% \begin{macrocode} |
| 1940 |
% This file is public domain |
| 1941 |
% If you want to use arara, you need the following directive: |
| 1942 |
% arara: pdflatex: { synctex: on } |
| 1943 |
% arara: pdflatex: { synctex: on } |
| 1944 |
\documentclass{article} |
| 1945 |
|
| 1946 |
\usepackage[a4paper]{geometry} |
| 1947 |
\usepackage{color} |
| 1948 |
\usepackage{mfirstuc-english}% also loads mfirstuc.sty |
| 1949 |
\usepackage[hidelinks]{hyperref} |
| 1950 |
|
| 1951 |
\title{Sample Document Illustrating the mfirstuc Package} |
| 1952 |
\author{Nicola Talbot} |
| 1953 |
|
| 1954 |
\begin{document} |
| 1955 |
\maketitle |
| 1956 |
|
| 1957 |
\tableofcontents |
| 1958 |
|
| 1959 |
\section{Sentence Case (First Letter Upper Case)} |
| 1960 |
\label{sec:sentencecase} |
| 1961 |
|
| 1962 |
\verb|\MFUsentencecase{abc}.| |
| 1963 |
\MFUsentencecase{abc}. |
| 1964 |
|
| 1965 |
\verb|\MFUsentencecase{{\em abc}}.| |
| 1966 |
\MFUsentencecase{{\em abc}}. |
| 1967 |
|
| 1968 |
\verb|\MFUsentencecase{\emph{abc}}.| |
| 1969 |
\MFUsentencecase{\emph{abc}}. |
| 1970 |
|
| 1971 |
\verb|\MFUsentencecase{\ae bc}.| |
| 1972 |
\MFUsentencecase{\ae bc}. |
| 1973 |
|
| 1974 |
\verb|\MFUsentencecase{{\ae}bc}.| |
| 1975 |
\MFUsentencecase{{\ae}bc}. |
| 1976 |
|
| 1977 |
\verb|\newcommand{\abc}{abc}\MFUsentencecase{\abc}.| |
| 1978 |
\newcommand{\abc}{abc}% |
| 1979 |
\MFUsentencecase{\abc}. |
| 1980 |
|
| 1981 |
\verb|\MFUsentencecase{\ref{sec:sentencecase}bc}.| |
| 1982 |
\MFUsentencecase{\ref{sec:sentencecase}bc}. |
| 1983 |
|
| 1984 |
\verb|\makefirstuc| doesn't expand its argument and skips exclusions. |
| 1985 |
|
| 1986 |
\verb|\makefirstuc{abc}.| |
| 1987 |
\makefirstuc{abc}. |
| 1988 |
|
| 1989 |
\verb|\makefirstuc{{\em abc}}.| |
| 1990 |
\makefirstuc{{\em abc}}. |
| 1991 |
|
| 1992 |
\verb|\makefirstuc{\emph{abc}}.| |
| 1993 |
\makefirstuc{\emph{abc}}. |
| 1994 |
|
| 1995 |
\verb|\makefirstuc{\ref{sec:sentencecase}bc}.| |
| 1996 |
\makefirstuc{\ref{sec:sentencecase}bc}. |
| 1997 |
|
| 1998 |
\newcommand{\strong}[1]{\textcolor{red}{#1}} |
| 1999 |
\verb|\makefirstuc{\strong{abc}d}| |
| 2000 |
\makefirstuc{\strong{abc}d} |
| 2001 |
|
| 2002 |
\verb|\makefirstuc{\protect\strong{abc}d}| |
| 2003 |
\makefirstuc{\protect\strong{abc}d} |
| 2004 |
|
| 2005 |
Exclusions vs blockers: |
| 2006 |
|
| 2007 |
\verb|\MFUsentencecase{\NoCaseChange{abc} xyz}| |
| 2008 |
\MFUsentencecase{\NoCaseChange{abc} xyz} |
| 2009 |
|
| 2010 |
\verb|\makefirstuc{\NoCaseChange{abc} xyz}| |
| 2011 |
\makefirstuc{\NoCaseChange{abc} xyz} |
| 2012 |
|
| 2013 |
\begingroup |
| 2014 |
\verb|\MFUblocker{\NoCaseChange}\makefirstuc{\NoCaseChange{abc} xyz}| |
| 2015 |
\MFUblocker{\NoCaseChange}\makefirstuc{\NoCaseChange{abc} xyz} |
| 2016 |
|
| 2017 |
\endgroup |
| 2018 |
|
| 2019 |
\section{Title Case (No Formatting Commands)} |
| 2020 |
|
| 2021 |
\bgroup |
| 2022 |
%Clearing ``nocap'' words. |
| 2023 |
%\verb|\MFUclear| |
| 2024 |
%\MFUclear |
| 2025 |
%(localised by group) |
| 2026 |
|
| 2027 |
\verb|\capitalisewords{the wind in the willows}| |
| 2028 |
\capitalisewords{the wind in the willows} |
| 2029 |
|
| 2030 |
\verb|\capitalisewords{a small book of rhyme.}| |
| 2031 |
\capitalisewords{a small book of rhyme.} |
| 2032 |
|
| 2033 |
\medskip |
| 2034 |
|
| 2035 |
\verb|\space| isn't considered a word boundary for |
| 2036 |
\verb|\capitalisewords| as shown below: |
| 2037 |
|
| 2038 |
\begin{verbatim} |
| 2039 |
\capitalisewords{a small\space book of rhyme.} |
| 2040 |
\end{verbatim} |
| 2041 |
\capitalisewords{a small\space book of rhyme.} |
| 2042 |
|
| 2043 |
\medskip |
| 2044 |
No expansion is performed on the argument of |
| 2045 |
\verb|\capitalisewords|: |
| 2046 |
|
| 2047 |
\verb|\newcommand{\mytitle}{a small book of rhyme.}| |
| 2048 |
\newcommand{\mytitle}{a small book of rhyme.} |
| 2049 |
|
| 2050 |
\verb|\capitalisewords{\mytitle}| |
| 2051 |
\capitalisewords{\mytitle} |
| 2052 |
|
| 2053 |
\verb|\xcapitalisewords{\mytitle}| |
| 2054 |
\xcapitalisewords{\mytitle} |
| 2055 |
|
| 2056 |
\egroup |
| 2057 |
|
| 2058 |
Formatting for the entire phrase must go outside |
| 2059 |
\verb|\capitalisewords| (unlike \verb|\makefirstuc|). Compare: |
| 2060 |
|
| 2061 |
\begin{verbatim} |
| 2062 |
\capitalisewords{\textbf{a small book of rhyme.}} |
| 2063 |
\end{verbatim} |
| 2064 |
\capitalisewords{\textbf{a small book of rhyme.}} |
| 2065 |
|
| 2066 |
\begin{verbatim} |
| 2067 |
\textbf{\capitalisewords{a small book of rhyme.}} |
| 2068 |
\end{verbatim} |
| 2069 |
\textbf{\capitalisewords{a small book of rhyme.}} |
| 2070 |
|
| 2071 |
\medskip |
| 2072 |
|
| 2073 |
Use \verb|\capitalisefmtwords| instead. The starred form |
| 2074 |
is limited to one text-block command at the start of the argument. |
| 2075 |
|
| 2076 |
\begin{verbatim} |
| 2077 |
\capitalisefmtwords*{\emph{a small book of rhyme}} |
| 2078 |
\end{verbatim} |
| 2079 |
\capitalisefmtwords*{\emph{a small book of rhyme}} |
| 2080 |
|
| 2081 |
Additional text-block commands can cause unexpected results. |
| 2082 |
|
| 2083 |
\begin{verbatim} |
| 2084 |
\capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}} |
| 2085 |
\end{verbatim} |
| 2086 |
\capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}} |
| 2087 |
|
| 2088 |
|
| 2089 |
\section{Title Case (Contains Text-Block Formatting Commands)} |
| 2090 |
|
| 2091 |
The unstarred form of \verb|\capitalisefmtwords| is still a bit |
| 2092 |
experimental and is only designed |
| 2093 |
for phrases that contain text-block commands with a single |
| 2094 |
argument, which should be a word or sub-phrase. |
| 2095 |
|
| 2096 |
\verb|\capitalisefmtwords{\textbf{a small book of rhyme}}.| |
| 2097 |
\capitalisefmtwords{\textbf{a small book of rhyme}}. |
| 2098 |
|
| 2099 |
\verb|\capitalisefmtwords{\textbf{a small book} of rhyme}.| |
| 2100 |
\capitalisefmtwords{\textbf{a small book} of rhyme}. |
| 2101 |
|
| 2102 |
\verb|\capitalisefmtwords{a \textbf{small book} of rhyme}.| |
| 2103 |
\capitalisefmtwords{a \textbf{small book} of rhyme}. |
| 2104 |
|
| 2105 |
\verb|\capitalisefmtwords{\textbf{a} small book of rhyme}.| |
| 2106 |
\capitalisefmtwords{\textbf{a} small book of rhyme}. |
| 2107 |
|
| 2108 |
\verb|\capitalisefmtwords{a small book \textbf{of rhyme}}.| |
| 2109 |
\capitalisefmtwords{a small book \textbf{of rhyme}}. |
| 2110 |
|
| 2111 |
\medskip |
| 2112 |
|
| 2113 |
Be careful of trailing spaces at the end a group. They can confuse |
| 2114 |
things. |
| 2115 |
|
| 2116 |
\verb|\capitalisefmtwords{\textbf{a small }book of rhyme}.| |
| 2117 |
\capitalisefmtwords{\textbf{a small }book of rhyme}. |
| 2118 |
|
| 2119 |
\verb|\capitalisefmtwords{\textbf{a small book }of rhyme}.| |
| 2120 |
\capitalisefmtwords{\textbf{a small book }of rhyme}. |
| 2121 |
|
| 2122 |
\verb|\capitalisefmtwords{\textbf{a small book of }rhyme}.| |
| 2123 |
\capitalisefmtwords{\textbf{a small book of }rhyme}. |
| 2124 |
|
| 2125 |
\medskip |
| 2126 |
|
| 2127 |
Use semantic commands for things like quotations: |
| 2128 |
|
| 2129 |
\begin{verbatim} |
| 2130 |
\newcommand*{\qt}[1]{``#1''} |
| 2131 |
\capitalisefmtwords{\qt{a small book of rhyme.}} |
| 2132 |
\end{verbatim} |
| 2133 |
\newcommand*{\qt}[1]{``#1''} |
| 2134 |
\capitalisefmtwords{\qt{a small book of rhyme.}} |
| 2135 |
|
| 2136 |
\smallskip |
| 2137 |
|
| 2138 |
(But make them robust if you intend using commands like |
| 2139 |
\verb|\ecapitalisefmtwords|.) |
| 2140 |
Similarly for other types of punctuation: |
| 2141 |
\begin{verbatim} |
| 2142 |
\newcommand*{\esq}[1]{'?#1?} |
| 2143 |
\capitalisefmtwords{\esq{D\'onde est\'a libro}} |
| 2144 |
\end{verbatim} |
| 2145 |
\newcommand*{\esq}[1]{?`#1?} |
| 2146 |
\capitalisefmtwords{\esq{D\'onde est\'a libro}} |
| 2147 |
|
| 2148 |
\medskip |
| 2149 |
|
| 2150 |
Anything more complicated than a simple one-argument text-block |
| 2151 |
command requires the starred version. |
| 2152 |
|
| 2153 |
\begin{verbatim} |
| 2154 |
\newcommand*{\swap}[2]{{#2}{#1}} |
| 2155 |
\capitalisefmtwords*{\textbf{an \swap{un}{usually} small book of} rhyme}. |
| 2156 |
\end{verbatim} |
| 2157 |
\newcommand*{\swap}[2]{{#2}{#1}} |
| 2158 |
\capitalisefmtwords*{\textbf{an \swap{un}{usually} small book of} rhyme}. |
| 2159 |
|
| 2160 |
\medskip |
| 2161 |
|
| 2162 |
Nested text-block commands: |
| 2163 |
|
| 2164 |
\begin{verbatim} |
| 2165 |
\capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}. |
| 2166 |
\end{verbatim} |
| 2167 |
\capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}. |
| 2168 |
|
| 2169 |
\begin{verbatim} |
| 2170 |
\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}. |
| 2171 |
\end{verbatim} |
| 2172 |
\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}. |
| 2173 |
|
| 2174 |
\begin{verbatim} |
| 2175 |
\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}. |
| 2176 |
\end{verbatim} |
| 2177 |
\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}. |
| 2178 |
|
| 2179 |
\medskip |
| 2180 |
|
| 2181 |
An empty brace at the start of a word will suppress the |
| 2182 |
case-changing. |
| 2183 |
|
| 2184 |
\begin{verbatim} |
| 2185 |
\capitalisefmtwords{\textbf{a small {}book of} rhyme}. |
| 2186 |
\end{verbatim} |
| 2187 |
\capitalisefmtwords{\textbf{a small {}book of} rhyme}. |
| 2188 |
|
| 2189 |
\medskip |
| 2190 |
|
| 2191 |
Suppress case-changing for problematic commands by inserting |
| 2192 |
an empty group in front: |
| 2193 |
|
| 2194 |
\begin{verbatim} |
| 2195 |
\capitalisefmtwords{{}\textcolor{red}{a} small book of |
| 2196 |
{}\textcolor{red}{rhyme}}. |
| 2197 |
\end{verbatim} |
| 2198 |
\capitalisefmtwords{{}\textcolor{red}{a} small book of |
| 2199 |
{}\textcolor{red}{rhyme}}. |
| 2200 |
|
| 2201 |
\medskip |
| 2202 |
|
| 2203 |
If possible provide semantic command instead. |
| 2204 |
|
| 2205 |
\begin{verbatim} |
| 2206 |
\newcommand*{\alert}[1]{\textcolor{red}{#1}} |
| 2207 |
\capitalisefmtwords{\alert{a} small book of \alert{rhyme}}. |
| 2208 |
\end{verbatim} |
| 2209 |
\newcommand*{\alert}[1]{\textcolor{red}{#1}} |
| 2210 |
\capitalisefmtwords{\alert{a} small book of \alert{rhyme}}. |
| 2211 |
|
| 2212 |
\medskip |
| 2213 |
|
| 2214 |
No formatting commands in the following example: |
| 2215 |
|
| 2216 |
\verb|\capitalisefmtwords{a small book of rhyme}.| |
| 2217 |
\capitalisefmtwords{a small book of rhyme}. |
| 2218 |
|
| 2219 |
\medskip |
| 2220 |
|
| 2221 |
Avoid scoped declarations. The next example doesn't work. |
| 2222 |
|
| 2223 |
\begin{verbatim} |
| 2224 |
\capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.} |
| 2225 |
\end{verbatim} |
| 2226 |
\capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.} |
| 2227 |
|
| 2228 |
\medskip |
| 2229 |
|
| 2230 |
If a command isn't followed by a grouped argument, the |
| 2231 |
case-change is applied to the command (on the assumption |
| 2232 |
that it's a character command, such as \verb|\ae|). This can |
| 2233 |
have an odd effect if case-changing has no meaning for that command. |
| 2234 |
As illustrated next: |
| 2235 |
|
| 2236 |
\verb|\capitalisefmtwords{\relax a book of rhyme.}| |
| 2237 |
\capitalisefmtwords{\relax a book of rhyme.} |
| 2238 |
|
| 2239 |
\section{Compound Words} |
| 2240 |
|
| 2241 |
Use \verb|\MFUhyphentrue| to title case each part of |
| 2242 |
a compound word. |
| 2243 |
|
| 2244 |
Default: |
| 2245 |
\begin{verbatim} |
| 2246 |
\capitalisewords{a fast-paced book of rhyme}. |
| 2247 |
\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. |
| 2248 |
\end{verbatim} |
| 2249 |
\capitalisewords{a fast-paced book of rhyme}. |
| 2250 |
\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. |
| 2251 |
|
| 2252 |
Compare with |
| 2253 |
\begin{verbatim} |
| 2254 |
\MFUhyphentrue |
| 2255 |
\capitalisewords{a fast-paced book of rhyme}. |
| 2256 |
\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. |
| 2257 |
\end{verbatim} |
| 2258 |
\MFUhyphentrue |
| 2259 |
\capitalisewords{a fast-paced book of rhyme}. |
| 2260 |
\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. |
| 2261 |
|
| 2262 |
\end{document} |
| 2263 |
% \end{macrocode} |
| 2264 |
%\fi |
| 2265 |
%\iffalse |
| 2266 |
% \begin{macrocode} |
| 2267 |
%</sample-mfirstuc.tex> |
| 2268 |
% \end{macrocode} |
| 2269 |
%\fi |
| 2270 |
%\iffalse |
| 2271 |
% \begin{macrocode} |
| 2272 |
%<*mfirstuc.l2h> |
| 2273 |
% \end{macrocode} |
| 2274 |
%\fi |
| 2275 |
%\iffalse |
| 2276 |
% \begin{macrocode} |
| 2277 |
# File : mfirstuc.l2h |
| 2278 |
# Author : Nicola L. C. Talbot |
| 2279 |
# Version : 2.08 (2022-10-14) |
| 2280 |
# Description : LaTeX2HTML (limited!) implementation of mfirstuc package |
| 2281 |
|
| 2282 |
# This is a LaTeX2HTML style implementing the mfirstuc package, and |
| 2283 |
# was distributed as part of the glossaries package, but is now |
| 2284 |
# distributed as part of the mfirstuc package. There's no guarantee |
| 2285 |
# that it still works with new versions of LaTeX2HTML. |
| 2286 |
# |
| 2287 |
# v2.08: |
| 2288 |
# - The version number has been updated |
| 2289 |
# - file extension changed from .perl to .l2h to more easily identify it as a |
| 2290 |
# LaTeX2HTML file rather than a standalone Perl script. |
| 2291 |
# - Added MFUsentencecase but it's identical to makefirstuc |
| 2292 |
# |
| 2293 |
# Copyright 2007-2022 Nicola L.C. Talbot |
| 2294 |
# This work may be distributed and/or modified under the |
| 2295 |
# conditions of the LaTeX Project Public License, either version 1.3 |
| 2296 |
# of this license of (at your option) any later version. |
| 2297 |
# The latest version of this license is in |
| 2298 |
# http://www.latex-project.org/lppl.txt |
| 2299 |
# and version 1.3 or later is part of all distributions of LaTeX |
| 2300 |
# version 2005/12/01 or later. |
| 2301 |
# |
| 2302 |
# This work has the LPPL maintenance status `maintained'. |
| 2303 |
# |
| 2304 |
# The Current Maintainer of this work is Nicola Talbot. |
| 2305 |
|
| 2306 |
use warnings; |
| 2307 |
|
| 2308 |
package main; |
| 2309 |
|
| 2310 |
sub do_cmd_makefirstuc{ |
| 2311 |
local($_) = @_; |
| 2312 |
|
| 2313 |
local($id,$text); |
| 2314 |
|
| 2315 |
$text = &missing_braces unless |
| 2316 |
s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; |
| 2317 |
|
| 2318 |
&translate_commands("\\glsmakefirstuc $text") . $_; |
| 2319 |
} |
| 2320 |
|
| 2321 |
sub do_cmd_MFUsentencecase{ |
| 2322 |
local($_) = @_; |
| 2323 |
|
| 2324 |
local($id,$text); |
| 2325 |
|
| 2326 |
$text = &missing_braces unless |
| 2327 |
s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; |
| 2328 |
|
| 2329 |
&translate_commands("\\glsmakefirstuc $text") . $_; |
| 2330 |
} |
| 2331 |
|
| 2332 |
sub do_cmd_xmakefirstuc{ |
| 2333 |
local($_) = @_; |
| 2334 |
|
| 2335 |
local($id,$text); |
| 2336 |
|
| 2337 |
$text = &missing_braces unless |
| 2338 |
s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; |
| 2339 |
|
| 2340 |
unless ($id) |
| 2341 |
{ |
| 2342 |
$id = ++$global{'max_id'}; |
| 2343 |
} |
| 2344 |
|
| 2345 |
&translate_commands("\\expandafter \\makefirstuc $OP$id$CP$text$OP$id$CP") |
| 2346 |
. $_; |
| 2347 |
} |
| 2348 |
|
| 2349 |
sub do_cmd_glsmakefirstuc{ |
| 2350 |
local($_) = @_; |
| 2351 |
|
| 2352 |
local($id,$text); |
| 2353 |
|
| 2354 |
$text = &get_next_object unless |
| 2355 |
s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; |
| 2356 |
|
| 2357 |
&do_real_makefirstuc($text).$_; |
| 2358 |
} |
| 2359 |
|
| 2360 |
sub do_real_makefirstuc{ |
| 2361 |
local($text) = @_; |
| 2362 |
|
| 2363 |
if ($text=~/^((?:\s*<[^>]+>\s*)+)(.*)/) |
| 2364 |
{ |
| 2365 |
$text = $1 . ucfirst($2); |
| 2366 |
} |
| 2367 |
else |
| 2368 |
{ |
| 2369 |
$text = ucfirst($text); |
| 2370 |
} |
| 2371 |
|
| 2372 |
$text; |
| 2373 |
} |
| 2374 |
|
| 2375 |
sub do_cmd_capitalisewords{ |
| 2376 |
local($_) = @_; |
| 2377 |
|
| 2378 |
local($id,$text); |
| 2379 |
|
| 2380 |
$text = &missing_braces unless |
| 2381 |
s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; |
| 2382 |
|
| 2383 |
local($newtext) = ''; |
| 2384 |
|
| 2385 |
foreach my $word (split ' ', $text) |
| 2386 |
{ |
| 2387 |
$id = ++$global{'max_id'}; |
| 2388 |
|
| 2389 |
$word = &translate_commands("\\makefirstuc $OP$id$CP$word$OP$id$CP"); |
| 2390 |
|
| 2391 |
if ($newtext) |
| 2392 |
{ |
| 2393 |
$newtext .= ' ' . $word; |
| 2394 |
} |
| 2395 |
else |
| 2396 |
{ |
| 2397 |
$newtext = $word; |
| 2398 |
} |
| 2399 |
} |
| 2400 |
|
| 2401 |
$newtext.$_; |
| 2402 |
} |
| 2403 |
|
| 2404 |
sub get_next_object{ |
| 2405 |
local($next, $revert, $thisline); |
| 2406 |
local($this_cmd) = $cmd; |
| 2407 |
$this_cmd =~ s/^\\// unless ($cmd eq "\\"); |
| 2408 |
if (/^[\s%]*([^\n]*)\n/ ) { |
| 2409 |
$thisline = &revert_to_raw_tex($1) |
| 2410 |
} else { |
| 2411 |
$thisline = &revert_to_raw_tex($_); |
| 2412 |
} |
| 2413 |
s/^\s*//; |
| 2414 |
if ($_ =~ s/$next_token_rx//) { $next = $& }; |
| 2415 |
$next =~ s/$comment_mark(\d+\n?)?//g; |
| 2416 |
if ($next =~ /^\\(\W|\d|[a-zA-z]*\b)/) { |
| 2417 |
$revert = $next = "\\".$1; |
| 2418 |
} elsif ($next =~ /\W/) { |
| 2419 |
$revert = &revert_to_raw_tex($next); |
| 2420 |
} else { $revert = $next }; |
| 2421 |
$next; |
| 2422 |
} |
| 2423 |
|
| 2424 |
1; |
| 2425 |
% \end{macrocode} |
| 2426 |
%\fi |
| 2427 |
%\iffalse |
| 2428 |
% \begin{macrocode} |
| 2429 |
%</mfirstuc.l2h> |
| 2430 |
% \end{macrocode} |
| 2431 |
%\fi |
| 2432 |
%\Finale |
| 2433 |
\endinput |