summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-07-30 23:07:44 +0000
committerKarl Berry <karl@freefriends.org>2016-07-30 23:07:44 +0000
commit525ac53a88fd99baae49fee0cafb38d995aaaace (patch)
tree498c03403c316dca4ec2ae3498130c8522ac8e98 /Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx
parent87de64a55b20671a3b63f28699b68a97c0f0d02c (diff)
mfirstuc (30jul16)
git-svn-id: svn://tug.org/texlive/trunk@41766 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx')
-rw-r--r--Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx521
1 files changed, 485 insertions, 36 deletions
diff --git a/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx
index 5191f0d5787..3f3887401ad 100644
--- a/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx
+++ b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx
@@ -1,21 +1,21 @@
%\iffalse
% mfirstuc.dtx generated using makedtx version 1.1 (c) Nicola Talbot
% Command line args:
+% -codetitle "Main Package Code"
+% -author "Nicola Talbot"
+% -doc "mfirstuc-codedoc.tex"
% -src "mfirstuc.sty\Z=>mfirstuc.sty"
% -src "mfirstuc-english.sty\Z=>mfirstuc-english.sty"
% -src "(sample.*\.tex)\Z=>\1"
% -src "(.*\.perl)\Z=>\1"
-% -doc "mfirstuc-codedoc.tex"
% -comment ".*\.perl"
% -comment ".*\.tex"
-% -author "Nicola Talbot"
-% -setambles ".*\.perl=>\nopreamble\nopostamble"
-% -setambles ".*\.tex=>\nopreamble\nopostamble"
-% -codetitle "Main Package Code"
% -macrocode ".*\.perl"
% -macrocode ".*\.tex"
+% -setambles ".*\.perl=>\nopreamble\nopostamble"
+% -setambles ".*\.tex=>\nopreamble\nopostamble"
% mfirstuc
-% Created on 2015/12/17 12:46
+% Created on 2016/7/29 22:54
%\fi
%\iffalse
%<*package>
@@ -38,7 +38,7 @@
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
-% Copyright (C) 2015 Nicola Talbot, all rights reserved.
+% Copyright (C) 2016 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
@@ -62,8 +62,9 @@ mfirstuc.dtx
\renewcommand*{\main}[1]{\hyperpage{#1}}
\setcounter{IndexColumns}{2}
+\setlength\IndexMin{100pt}
-\CheckSum{268}
+\CheckSum{519}
\begin{document}
\DocInput{mfirstuc.dtx}
@@ -73,12 +74,12 @@ mfirstuc.dtx
%\MakeShortVerb{"}
%\DeleteShortVerb{\|}
%
-% \title{Documented Code For mfirstuc v2.02}
+% \title{Documented Code For mfirstuc v2.03}
% \author{Nicola L.C. Talbot\\[10pt]
%Dickimaw Books\\
%\url{http://www.dickimaw-books.com/}}
%
-% \date{2015-12-17}
+% \date{2016-07-29}
% \maketitle
%
%\tableofcontents
@@ -110,7 +111,7 @@ mfirstuc.dtx
%\changes{2.0}{2015/09/09}{package split from glossaries}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{mfirstuc}[2015/12/17 v2.02 (NLCT)]
+\ProvidesPackage{mfirstuc}[2016/07/29 v2.03 (NLCT)]
% \end{macrocode}
% Requires \sty{etoolbox}:\changes{1.06}{2012/05/21}{now requires
% etoolbox}
@@ -146,11 +147,23 @@ mfirstuc.dtx
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@MFU@protect}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\newcommand*{\@MFU@protect}{\protect}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\@MFU@p@makefirstuc}
% Internal command to do the required action.
% \begin{macrocode}
\def\@MFU@p@makefirstuc#1#2#3\@end@MFU@protected#4{%
- \ifx\protect#1\relax
+% \end{macrocode}
+%\changes{2.03}{2016-07-29}{changed test}
+%Test if the first argument is \cs{protect}.
+% \begin{macrocode}
+ \def\gls@argi{#1}%
+ \ifx\gls@argi\@MFU@protect
\@makefirstuc{#2#3}%
\else
\@makefirstuc{#4}%
@@ -210,13 +223,35 @@ mfirstuc.dtx
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@gls@split}
% Put first argument in \cs{@gls@first} and second argument in
% \cs{@gls@rest}:
+%\changes{??}{??}{added check for datatool-base UTF-8 support}
% \begin{macrocode}
-\def\@gls@split#1#2\@nil{%
- \def\@gls@first{#1}\def\@gls@rest{#2}%
+\ifdef\dtl@getfirst@UTFviii
+{%
+ \def\@gls@split#1#2\@nil{%
+ \ifbool{@dtl@utf8}
+ {%
+ \expandafter\dtl@if@two@octets#1#2\relax\dtl@end@if@two@octets
+ {%
+ \dtl@getfirst@UTFviii#1#2\@nil\end@dtl@getfirst@UTFviii
+ \let\@gls@first\dtl@first
+ \let\@gls@rest\dtl@rest
+ }%
+ {%
+ \def\@gls@first{#1}\def\@gls@rest{#2}%
+ }%
+ }%
+ }
+}%
+{%
+ \def\@gls@split#1#2\@nil{%
+ \def\@gls@first{#1}\def\@gls@rest{#2}%
+ }
}
% \end{macrocode}
+%\end{macro}
% \begin{macrocode}
\def\@gls@checkcs#1 #2#3\relax{%
\def\@gls@argi{#1}\def\@gls@argii{#2}%
@@ -227,10 +262,69 @@ mfirstuc.dtx
\fi
}
% \end{macrocode}
+% Has \sty{datatool-base} v2.24 (or above) been loaded? If so and we
+% have UTF-8 enabled, we can grab the first octet.
+%\begin{macro}{\@mfu@applytofirst}
+%\changes{??}{??}{new}
+% \begin{macrocode}
+\ifdef\dtl@getfirst@UTFviii
+{%
+ \def\@mfu@applytofirst#1#2\@mfu@end@applytofirst#3{%
+ \expandafter\dtl@if@two@octets#1#2\relax\dtl@end@if@two@octets
+ {%
+ \dtl@getfirst@UTFviii#1#2\@nil\end@dtl@getfirst@UTFviii
+ \expandafter#3\expandafter{\dtl@first}\dtl@rest
+ }%
+ {%
+ #3#1#2%
+ }%
+ }%
+}%
+{%
+ \def\@mfu@applytofirst#1#2\@mfu@end@applytofirst#3{#3#1#2}
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\MFUapplytofirst}
+%\changes{??}{??}{new}
+%\begin{definition}
+%\cs{MFUapplytofirst}\marg{cs}\marg{text}
+%\end{definition}
+% Apply \meta{cs} to first token of text, or first UTF-8 character
+% if \sty{datatool-base} v2.24 above has been loaded with the utf8
+% support enabled.
+% \begin{macrocode}
+\ifdef\dtl@getfirst@UTFviii
+{%
+ \newcommand*{\MFUapplytofirst}[2]{%
+ \ifbool{@dtl@utf8}
+ {%
+ \ifblank{#2}%
+ {#1{#2}}%
+ {%
+ \ifblank{#1}%
+ {#1#2}%
+ {%
+ \@mfu@applytofirst#2\@mfu@end@applytofirst#1\relax
+ }%
+ }%
+ }%
+ {%
+ #1#2%
+ }%
+ }
+}%
+{%
+ \newcommand*{\MFUapplytofirst}[2]{#1#2}
+}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\@gls@makefirstuc}
% Make first thing upper case:
% \begin{macrocode}
-\def\@gls@makefirstuc#1{\mfirstucMakeUppercase #1}
+\def\@gls@makefirstuc#1{\MFUapplytofirst\mfirstucMakeUppercase{#1}}
% \end{macrocode}
%\end{macro}
%
@@ -263,7 +357,8 @@ mfirstuc.dtx
% (added v1.01).
% \begin{macrocode}
\newcommand*{\xmakefirstuc}[1]{%
-\expandafter\makefirstuc\expandafter{#1}}
+ \expandafter\makefirstuc\expandafter{#1}%
+}
% \end{macrocode}
%\end{macro}
%
@@ -271,7 +366,7 @@ mfirstuc.dtx
%\changes{1.10}{2015/05/03}{new}
% Fully expand argument before applying \cs{makefirstuc}
% \begin{macrocode}
-\DeclareRobustCommand*{\emakefirstuc}[1]{%
+\newrobustcmd*{\emakefirstuc}[1]{%
\protected@edef\@MFU@caparg{#1}%
\expandafter\makefirstuc\expandafter{\@MFU@caparg}%
}
@@ -288,9 +383,21 @@ mfirstuc.dtx
%capitalised}
% \begin{macrocode}
\newrobustcmd*{\capitalisewords}[1]{%
- \def\gls@add@space{}%
- \let\@mfu@domakefirstuc\makefirstuc
\let\@mfu@checkword\@gobble
+ \def\gls@add@space{}%
+ \let\@mfu@domakefirstuc\MFUcapword
+ \mfu@capitalisewords#1 \@nil\mfu@endcap
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@mfu@mid@capitalisewords}
+%\changes{2.03}{2016-07-29}{new}
+%\cs{@mfu@checkword} needs to be set before use.
+% \begin{macrocode}
+\newcommand*{\@mfu@mid@capitalisewords}[1]{%
+ \def\gls@add@space{}%
+ \let\@mfu@domakefirstuc\MFUcapword
\mfu@capitalisewords#1 \@nil\mfu@endcap
}
% \end{macrocode}
@@ -315,6 +422,42 @@ mfirstuc.dtx
\def\mfu@noop#1\mfu@endcap{}
% \end{macrocode}
%
+%\begin{macro}{\ifMFUhyphen}
+%\changes{2.03}{2016-07-29}{new}
+%Split on hyphens.
+% \begin{macrocode}
+\newif\ifMFUhyphen
+\MFUhyphenfalse
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\MFUcapword}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\newcommand*{\MFUcapword}[1]{%
+ \ifMFUhyphen
+ \@MFUcapword#1-\@nil\@endMFUcapword
+ \else
+ \makefirstuc{#1}%
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@MFUcapword}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\def\@MFUcapword#1-#2\@endMFUcapword{%
+ \makefirstuc{#1}%
+ \def\@mfu@argii{#2}%
+ \ifx\@mfu@argii\@nnil
+ \else
+ -\@MFUcapword#2\@endMFUcapword
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\mfu@checkword}
% Check if word should be capitalised.
% This originally used \sty{etoolbox}'s \ics{ifinlist} command
@@ -324,7 +467,7 @@ mfirstuc.dtx
% \begin{macrocode}
\newcommand*\mfu@checkword[1]{%
\def\mfu@checkword@arg{#1}%
- \let\@mfu@domakefirstuc\makefirstuc
+ \let\@mfu@domakefirstuc\MFUcapword
\forlistloop\mfu@checkword@do\@mfu@nocaplist
}
% \end{macrocode}
@@ -389,12 +532,165 @@ mfirstuc.dtx
%\changes{1.10}{2015/05/03}{new}
% Fully expand argument before applying \cs{capitalisewords}
% \begin{macrocode}
-\DeclareRobustCommand*{\ecapitalisewords}[1]{%
+\newrobustcmd*{\ecapitalisewords}[1]{%
\protected@edef\@MFU@caparg{#1}%
\expandafter\capitalisewords\expandafter{\@MFU@caparg}%
}
% \end{macrocode}
%\end{macro}
+%
+%\begin{macro}{\capitalisefmtwords}
+%\changes{2.03}{2016-07-29}{new}
+%Like \cs{capitalisewords} but assumes that the phrase contains
+%formatting text-block commands.
+% \begin{macrocode}
+\newcommand*{\capitalisefmtwords}[1]{%
+ \let\@mfu@checkword\@gobble
+ \def\gls@add@space{}%
+ \@capitalisefmtwords#1 \@nil\relax
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@capitalisefmtwords}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\def\@capitalisefmtwords#1 #2{%
+ \def\gls@argi{#2}%
+ \ifx\gls@argi\@nnil
+ \def\@mfu@capfmtwordsnext{\@capitalise@fmtwords#1\@nil}%
+ \else
+ \def\@mfu@capfmtwordsnext{\@capitalise@fmtwords#1\@nil
+ \def\gls@add@space{ }%
+ \let\@mfu@checkword\mfu@checkword
+ \@@cap@nofmtphrase#2}%
+ \fi
+ \@mfu@capfmtwordsnext
+}%
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@capitalise@fmtwords}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\def\@capitalise@fmtwords#1{%
+ \def\gls@argi{#1}%
+ \ifx\gls@argi\@nnil
+% \end{macrocode}
+%Do nothing.
+% \begin{macrocode}
+ \let\@mfu@capfmtwordsnext\relax
+ \else
+ \ifx\gls@argi\@MFU@protect
+% \end{macrocode}
+%Skip \cs{protect}
+% \begin{macrocode}
+ \def\@mfu@capfmtwordsnext{\@capitalise@fmtwords}%
+ \else
+ \def\@gls@tmp{\ #1}%
+ \@onelevel@sanitize\@gls@tmp
+ \expandafter\@gls@checkcs\@gls@tmp\relax\relax
+ \if@glscs
+ \def\@mfu@capfmtwordsnext{\@@capitalisefmtwords#1}%
+ \else
+ \ifx\gls@argi\@empty
+ \def\@mfu@capfmtwordsnext{\@@capnofmtphrase{}}%
+ \else
+ \def\@mfu@capfmtwordsnext{\@@capnofmtphrase#1}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \@mfu@capfmtwordsnext
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@capitalisefmtwords}
+%\changes{2.03}{2016-07-29}{new}
+%Check for a group following argument.
+% \begin{macrocode}
+\def\@@capitalisefmtwords#1{%
+ \@ifnextchar\bgroup{\@@capfmtphrase#1}{\@@capnofmtphrase#1}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@@capfmtphrase}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\def\@@capfmtphrase#1#2#3{%
+ \def\@gls@tmp{#3}%
+ \ifx\@gls@tmp\@nnil
+ \def\@mfu@capfmtwordsnext{#1{\@capitalisefmtwords#2 \@nil}}%
+ \else
+ \def\@mfu@capfmtwordsnext{\@@capfmtsubphrase#1{#2}#3}%
+ \fi
+ \@mfu@capfmtwordsnext
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@@capnofmtphrase}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\def\@@capnofmtphrase#1\@nil{%
+ \gls@add@space
+ \@mfu@mid@capitalisewords{#1}%
+ \def\gls@add@space{ }%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@@capfmtsubphrase}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\def\@@capfmtsubphrase#1#2#3\@nil{%
+ \gls@add@space
+ #1{\@mfu@mid@capitalisewords{#2}}%
+ \def\gls@add@space{ }%
+ \let\@mfu@checkword\mfu@checkword
+ #3%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\@@cap@nofmtphrase}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\def\@@cap@nofmtphrase#1 #2\@nil{%
+ \def\gls@arg{#2}%
+ \ifx\gls@arg\@empty
+ \@capitalisefmtwords#1 \@nil
+ \else
+ \@capitalisefmtwords#1 \@nil
+ \def\gls@add@space{ }%
+ \let\@mfu@checkword\mfu@checkword
+ \@capitalisefmtwords#2 \@nil
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\xcapitalisefmtwords}
+%\changes{2.03}{2016-07-29}{new}
+% Short-cut command:
+% \begin{macrocode}
+\newcommand*{\xcapitalisefmtwords}[1]{%
+ \expandafter\capitalisefmtwords\expandafter{#1}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\ecapitalisefmtwords}
+%\changes{2.03}{2016-07-29}{new}
+% \begin{macrocode}
+\newrobustcmd*{\ecapitalisefmtwords}[1]{%
+ \protected@edef\@MFU@caparg{#1}%
+ \expandafter\capitalisefmtwords\expandafter{\@MFU@caparg}%
+}
+% \end{macrocode}
+%\end{macro}
+%
%\iffalse
% \begin{macrocode}
%</mfirstuc.sty>
@@ -409,7 +705,7 @@ mfirstuc.dtx
%\label{sec:code:mfirstuc-english}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{mfirstuc-english}[2015/09/09 v2.0 (NLCT)]
+\ProvidesPackage{mfirstuc-english}[2016/07/29 v2.03 (NLCT)]
% \end{macrocode}
% Load \sty{mfirstuc} if not already loaded:
% \begin{macrocode}
@@ -452,20 +748,31 @@ mfirstuc.dtx
% arara: pdflatex: { synctex: on }
\documentclass{article}
-\usepackage{mfirstuc-english}
+\usepackage[a4paper]{geometry}
+\usepackage{color}
+\usepackage{mfirstuc-english}% also loads mfirstuc.sty
\begin{document}
+This is a sample document illustrating the mfirstuc package.
+
+\section{First Letter Upper Case}
+\verb|\makefirstuc{abc}.|
\makefirstuc{abc}.
+\verb|\makefirstuc{{\em abc}}.|
\makefirstuc{{\em abc}}.
+\verb|\makefirstuc{\emph{abc}}.|
\makefirstuc{\emph{abc}}.
+\verb|\makefirstuc{\ae bc}.|
\makefirstuc{\ae bc}.
+\verb|\makefirstuc{{\ae}bc}.|
\makefirstuc{{\ae}bc}.
+\verb|\newcommand{\abc}{abc}\xmakefirstuc{\abc}.|
\newcommand{\abc}{abc}%
\xmakefirstuc{\abc}.
@@ -478,32 +785,174 @@ Protected formatting: \xmakefirstuc{\mytext}.
\renewcommand*{\mytext}{\ae\oe{some text}}
Sequential commands: \xmakefirstuc{\mytext}.
-\capitalisewords{the wind in the willows}
+\section{Title Case (Formatting)}
+
+Formatting for the entire phrase must go outside
+\verb|\capitalisewords| (unlike \verb|\makefirstuc|). Compare:
+
+\verb|\capitalisewords{\textbf{a small book of rhyme.}}|
+\capitalisewords{\textbf{a small book of rhyme.}}
-\capitalisewords{a book of rhyme.}
+with:
+
+\verb|\textbf{\capitalisewords{a small book of rhyme.}}|
+\textbf{\capitalisewords{a small book of rhyme.}}
+
+\medskip
+
+Use \verb|\capitalisefmtwords| instead (full stop outside
+argument to check for spurious spaces):
+
+\verb|\capitalisefmtwords{\textbf{a small book of rhyme}}.|
+\capitalisefmtwords{\textbf{a small book of rhyme}}.
+
+\verb|\capitalisefmtwords{\textbf{a small book} of rhyme}.|
+\capitalisefmtwords{\textbf{a small book} of rhyme}.
+
+\verb|\capitalisefmtwords{a \textbf{small book} of rhyme}.|
+\capitalisefmtwords{a \textbf{small book} of rhyme}.
+
+\verb|\capitalisefmtwords{\textbf{a} book of rhyme}.|
+\capitalisefmtwords{\textbf{a} small book of rhyme}.
+
+\verb|\capitalisefmtwords{\textbf{a book }of rhyme}.|
+\capitalisefmtwords{\textbf{a small book }of rhyme}.
+
+\verb|\capitalisefmtwords{a small book \textbf{of rhyme}}.|
+\capitalisefmtwords{a small book \textbf{of rhyme}}.
+
+\medskip
+
+Use semantic commands for things like quotations:
+
+\begin{verbatim}
+\newcommand*{\qt}[1]{``#1''}
+\capitalisefmtwords{\qt{a small book of rhyme.}}
+\end{verbatim}
+\newcommand*{\qt}[1]{``#1''}
+\capitalisefmtwords{\qt{a small book of rhyme.}}
+
+\smallskip
+
+(But make them robust if you intend using commands like
+\verb|\ecapitalisefmtwords|.)
+
+\medskip
+
+Nested text-block commands:
+
+\begin{verbatim}
+\capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}.
+\end{verbatim}
+\capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}.
+
+\begin{verbatim}
+\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}.
+\end{verbatim}
+\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}.
+
+\begin{verbatim}
+\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}.
+\end{verbatim}
+\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}.
+
+\medskip
+
+An empty brace at the start of a word will suppress the
+case-changing.
+
+\begin{verbatim}
+\capitalisefmtwords{\textbf{a small {}book of} rhyme}.
+\end{verbatim}
+\capitalisefmtwords{\textbf{a small {}book of} rhyme}.
-\MFUclear
+\medskip
+Suppress case-changing for problematic commands by inserting
+an empty group in front:
+
+\begin{verbatim}
+\capitalisefmtwords{{}\textcolor{red}{a} small book of
+{}\textcolor{red}{rhyme}}.
+\end{verbatim}
+\capitalisefmtwords{{}\textcolor{red}{a} small book of
+{}\textcolor{red}{rhyme}}.
+
+\medskip
+
+If possible provide semantic command instead.
+
+\begin{verbatim}
+\newcommand*{\alert}[1]{\textcolor{red}{#1}}
+\capitalisefmtwords{\alert{a} small book of \alert{rhyme}}.
+\end{verbatim}
+\newcommand*{\alert}[1]{\textcolor{red}{#1}}
+\capitalisefmtwords{\alert{a} small book of \alert{rhyme}}.
+
+\medskip
+
+No formatting commands in the following example:
+
+\verb|\capitalisefmtwords{a small book of rhyme}.|
+\capitalisefmtwords{a small book of rhyme}.
+
+\medskip
+
+Avoid scoped declarations. The next example doesn't work.
+
+\begin{verbatim}
+\capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.}
+\end{verbatim}
+\capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.}
+
+\medskip
+
+If a command isn't followed by a grouped argument, the
+case-change is applied to the command (on the assumption
+that it's a character command, such as \verb|\ae|). This can
+have an odd effect if case-changing has no meaning for that command.
+As illustrated next:
+
+\verb|\capitalisefmtwords{\relax a book of rhyme.}|
+\capitalisefmtwords{\relax a book of rhyme.}
+
+\section{Title Case (No Formatting)}
+
+\bgroup
+%Clearing ``nocap'' words.
+%\verb|\MFUclear|
+%\MFUclear
+
+\verb|\capitalisewords{the wind in the willows}|
\capitalisewords{the wind in the willows}
-\capitalisewords{a book of rhyme.}
+\verb|\capitalisewords{a small book of rhyme.}|
+\capitalisewords{a small book of rhyme.}
-\capitalisewords{a book\space of rhyme.}
+\medskip
-\newcommand{\mytitle}{a book\space of rhyme.}
-\capitalisewords{\mytitle}
+\verb|\space| isn't considered a word boundary for
+\verb|\capitalisewords| as shown below:
-\xcapitalisewords{\mytitle}
+\begin{verbatim}
+\capitalisewords{a small\space book of rhyme.}
+\end{verbatim}
+\capitalisewords{a small\space book of rhyme.}
-Formatting for the entire phrase must go outside
-\verb|\capitalisewords| (unlike \verb|\makefirstuc|). Compare:
+\medskip
+No expansion is performed on the argument of
+\verb|\capitalisewords|:
-\capitalisewords{\textbf{a book of rhyme.}}
+\verb|\newcommand{\mytitle}{a small\space book of rhyme.}|
+\newcommand{\mytitle}{a small\space book of rhyme.}
-with:
+\verb|\capitalisewords{\mytitle}|
+\capitalisewords{\mytitle}
-\textbf{\capitalisewords{a book of rhyme.}}
+\verb|\xcapitalisewords{\mytitle}|
+\xcapitalisewords{\mytitle}
+\egroup
\end{document}
% \end{macrocode}
%\fi