From 525ac53a88fd99baae49fee0cafb38d995aaaace Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 30 Jul 2016 23:07:44 +0000 Subject: mfirstuc (30jul16) git-svn-id: svn://tug.org/texlive/trunk@41766 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/mfirstuc/CHANGES | 12 + Master/texmf-dist/doc/latex/mfirstuc/README | 4 +- .../doc/latex/mfirstuc/mfirstuc-code.pdf | Bin 222559 -> 253433 bytes .../doc/latex/mfirstuc/mfirstuc-manual.html | 1147 ++++++++++++++------ .../doc/latex/mfirstuc/mfirstuc-manual.pdf | Bin 223902 -> 301194 bytes .../doc/latex/mfirstuc/mfirstuc-manual.tex | 294 ++++- .../doc/latex/mfirstuc/sample-mfirstuc.pdf | Bin 52326 -> 81539 bytes .../doc/latex/mfirstuc/sample-mfirstuc.tex | 178 ++- .../texmf-dist/source/latex/mfirstuc/mfirstuc.dtx | 521 ++++++++- .../texmf-dist/source/latex/mfirstuc/mfirstuc.ins | 4 +- .../tex/latex/mfirstuc/mfirstuc-english.sty | 4 +- Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty | 190 +++- 12 files changed, 1910 insertions(+), 444 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/mfirstuc/CHANGES b/Master/texmf-dist/doc/latex/mfirstuc/CHANGES index 18eef0ad0d5..a26a2081d53 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/CHANGES +++ b/Master/texmf-dist/doc/latex/mfirstuc/CHANGES @@ -1,5 +1,17 @@ mfirstuc change log: +v2.03: + + * Fixed test for \protect at the start of \makefirstuc + + * Add new conditional \ifMFUhyphen and new command + \MFUcapword + + * New commands \capitalisefmtwords, \xcapitalisefmtwords + and \ecapitalisefmtwords (like \capitalisewords etc + but allows for text-block formatting commands within + the argument). + v2.02: * Fixed bug in \capitalisewords diff --git a/Master/texmf-dist/doc/latex/mfirstuc/README b/Master/texmf-dist/doc/latex/mfirstuc/README index bfbdf87e3d7..d226cadfcf5 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/README +++ b/Master/texmf-dist/doc/latex/mfirstuc/README @@ -1,6 +1,6 @@ -LaTeX Package : mfirstuc v2.02 +LaTeX Package : mfirstuc v2.03 -Last Modified : 2015-12-17 +Last Modified : 2016-07-29 Author : Nicola Talbot diff --git a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-code.pdf b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-code.pdf index 81c58cae4d5..bb88c50955c 100644 Binary files a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-code.pdf and b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-code.pdf differ diff --git a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html index 8087203ae76..5b60f1e19c9 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html +++ b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html @@ -4,13 +4,12 @@ -mfirstuc.sty v2.02: uppercasing first letter + - -

- +

+ - - + +

+ - - -

mfirstuc.sty v2.02: uppercasing first letter

-
Nicola L.C. Talbot -
Dickimaw Books -
+
+

+

mfirstuc.sty v2.03: uppercasing first letter +

+
+ +
Nicola L.C. Talbot
 
Dickimaw Books
http://www.dickimaw-books.com/
-
2015-12-17
- +class="cmtt-12">http://www.dickimaw-books.com/
+
+

2016-07-29

Contents

1 Introduction
2 Capitalising a Word +href="#sec:makefirstuc" id="QQ2-1-3">Capitalising the First Letter of a Word
3 Capitalise Each Word in a Phrase or Sentence (Title Case) +href="#sec:capitalisewords" id="QQ2-1-4">Capitalise the First Letter of Each Word in a Phrase or Sentence (Title Case) +
 3.1 PDF Bookmarks +
 3.2 Excluding Words From Case-Changing
4 UTF-8 +href="#sec:utf8" id="QQ2-1-7">UTF-8
-

+

-

Top

1 Introduction

-

The

The mfirstuc package was originally part of the glossaries bundle for use with commands -like glossaries bundle for use with commands like +\Gls, but as the commands provided by mfirstuc may be used without glossaries, -the two have been split into separately maintained packages. -

+class="cmss-10">glossaries, the two have +been split into separately maintained packages. +

The commands described here all have limitations. To minimise problems, use text-block +style semantic commands with one argument (the text that requires case-changing), and avoid +scoped declarations.
+

+

Here are some examples of semantic commands: +

    +
  1. Quoted material: + + + +
    + \newcommand{\qt}[1]{‘‘#1’’} +
    +

    (or use the csquotes package). With this, the following works: + + + +

    +
    + \makefirstuc{\qt{word}} +
    +

    This produces: +
    “Word” +
    + Whereas + + + +

    +
    + \makefirstuc{‘‘word’’} +
    +

    fails (no case-change and double open quote becomes two single open quotes): + +
    ‘‘word” +
    +

  2. +
  3. Font styles or colours: + + + +
    + \newcommand*{\alert}[1]{\textcolor{red}{#1}} +
    +

    Now the following is possible: + + + +

    +
    + \makefirstuc{\alert{word}} +
    +

    This produces +
    Word +
    + Note that \makefirstuc{\textcolor{red}{word}} fails (with an error) because the + case-changing interferes with the label.

+

Define these semantic commands robustly if you intend using any of the commands +that fully expand their argument (\emakefirstuc, \ecapitalisewords and +\ecapitalisefmtwords). +

-

Top

2 Capitalising a Word

-

A simple word can be capitalised just using the standard LATEX upper casing -command. For example, - + id="sec:makefirstuc">Capitalising the First Letter of a Word +

A simple word can be capitalised just using the standard LATEX upper casing command. For +example, + - +

-
+
\MakeUppercase word
-

but for commands like \Gls the word may be embedded within the argument of -another command, such as a font changing command. This makes things more -complicated for a general purpose solution, so the

but for commands like \Gls the word may be embedded within the argument of another +command, such as a font changing command. This makes things more complicated for +a general purpose solution, so the mfirstuc package provides: -



\makefirstuc  \makefirstuc{stuff}

-

+

This makes the first object of ⟨stuff ⟩ upper case unless ⟨stuff ⟩ starts with a control -sequence followed by a non-empty group, in which case the first object in -the group is converted to upper case. No expansion is performed on the -argument. -

If ⟨stuff ⟩ starts with a control sequence +followed by a non-empty group, in which case the first object in the group is converted to +upper case. No expansion is performed on the argument. +

If ⟨stuff ⟩ starts with a control sequence that takes more than one argument, the case-changing will always be applied to the first argument. If the text that requires the -case change is in one of the other arguments, you must hide the earlier arguments in a -wrapper command. For example, instead of \color{red}{text} you need to define, -say, \red as first argument. If the text that requires the case +change is in one of the other arguments, you must hide the earlier arguments in a wrapper +command. For example, instead of \textcolor{red}{text} you need to define, say, \red as +\color{red} and use \red{text}.
-

-

Examples:

+

+

Examples:

  • \makefirstuc{abc} produces Abc. @@ -258,33 +346,33 @@ class="cmtt-10">\makefirstuc{abc} produces Abc. class="cmtt-10">\makefirstuc{\emph{abc}} produces Abc (\MakeUppercase has been applied to - the letter “a” rather than has been applied to the + letter “a” rather than \emph). Note however that - + - -
    + +
    \makefirstuc{{\em abc}}
    -

    produces

    produces ABC (first object is {\em abc} so this is equivalent to -  abc} so this is equivalent to \MakeUppercase{\em abc}), and - +class="cmtt-10"> abc}), + and + - +

    -
    +
    {\makefirstuc{\em abc}}
    -

    produces abc (

    produces abc (\em doesn’t have an argument therefore first object is \em and so - is equivalent to \em and so is + equivalent to {\MakeUppercase{\em}abc}).

  • \makefirstuc{{ä}bc} produces Äbc.
-

Note that non-Latin or accented characters appearing at the start of the text must be -placed in a group (even if you are using the

Note that non-Latin or accented characters appearing at the start of the text must be placed in a +group (even if you are using the inputenc package). The reason for this -restriction is detailed in package). The reason for this restriction is detailed in +§4 UTF-8. -

In version 1.02 of mfirstuc, a bug fix resulted in a change in output if the first -object is a control sequence followed by an empty group. Prior to version 1.02, -\makefirstuc{\ae{}bc} produced æBc. However as from version 1.02, it now produces -Æbc.
-

-

Note also that - +

In version 1.02 of mfirstuc, a bug fix resulted in a change in output if the first object is a +control sequence followed by an empty group. Prior to version 1.02, \makefirstuc{\ae{}bc} +produced æBc. However as from version 1.02, it now produces Æbc.
+

+

Note also that + - +

-
+
\newcommand{\abc}{abc}  
\makefirstuc{\abc}
-

produces: ABC. This is because the first object in the argument of \makefirstuc is -\abc, so it does

produces: ABC. This is because the first object in the argument of \makefirstuc is \abc, so +it does \MakeUppercase{\abc}. Whereas: - + - +

-
+
\newcommand{\abc}{abc}  
\expandafter\makefirstuc\expandafter{\abc}
-

produces: Abc. There is a short cut command which will do this: -


produces: Abc. There is a short cut command which will do this: +


\xmakefirstuc  \xmakefirstuc{stuff}

-

+

This is equivalent to \expandafter\makefirstuc\expandafter{stuff }. So - + - +

-
+
\newcommand{\abc}{abc}  
\xmakefirstuc{\abc}
-

produces: Abc. -

produces: Abc. +

\xmakefirstuc only performs one level expansion on the first object in its -argument. It does not fully expand the entire argument.
-

-

As from version 1.10, there is now a command that fully expands the entire -argument before applying first object in its argument. It +does not fully expand the entire argument.

+

+

As from version 1.10, there is now a command that fully expands the entire argument +before applying \makefirstuc: -



\emakefirstuc  \emakefirstuc{text}

-

-

Examples: - +

+

Examples: + - +

-
+
\newcommand{\abc}{\xyz a}  
\newcommand{\xyz}{xyz}  
No expansion: \makefirstuc{\abc}.  
First object one-level expansion: \xmakefirstuc{\abc}.  
Fully expanded: \emakefirstuc{\abc}.
-

produces: No expansion: XYZA. First object one-level expansion: XYZa. Fully -expanded: Xyza. -

If you use

produces: No expansion: XYZA. First object one-level expansion: XYZa. Fully expanded: +Xyza. +

If you use mfirstuc without the glossaries package, the standard \MakeUppercase -command is used. If used with \MakeUppercase command +is used. If used with glossaries, \MakeTextUppercase (defined by the textcase -package) is used instead. If you are using package) is used +instead. If you are using mfirstuc without the glossaries package and -want to use glossaries package and want to use +\MakeTextUppercase instead, you can redefine -



\glsmakefirstuc  \glsmakefirstuc{text}

-

+

For example: - + - +

-
+
\renewcommand{\glsmakefirstuc}[1]{\MakeTextUppercase #1}
-

Remember to also load

Remember to also load textcase (glossaries loads this automatically). -

+

-

Top

3 Capitalise Each Word in a Phrase or Sentence (Title Case)

-

New to mfirstuc v1.06: -


Capitalise the First Letter of Each Word in a Phrase or Sentence (Title +Case) +

New to mfirstuc v1.06: +


\capitalisewords  \capitalisewords{text}

-

+

This command applies \makefirstuc to each word in ⟨text⟩ where the space character is -used as the word separator. Note that it has to be a plain space character, not another -form of space, such as text⟩ where the space character is used +as the word separator. Note that it has to be a plain space character, not another form of +space, such as ~ or \space. Note that no expansion is performed on -⟨text⟩. -

Formatting for the entire phrase must go outside \space. Note that no expansion is performed on ⟨text⟩. See §3.2 +Excluding Words From Case-Changing for excluding words (such as “of”) from the +case-changing. +

The actual capitalisation of each word is done using (new to version 2.03): +


\MFUcapword  \MFUcapword{word}

+

+This just does \makefirstuc{word} by default, but its behaviour is determined by the +conditional: +


\ifMFUhyphen  \ifMFUhyphen

+

+

If you want to title case each part of a compound word containing hyphens, you can enable +this using +


\MFUhyphentrue  \MFUhyphentrue

+

+or switch it back off again using: +


\MFUhyphenfalse  \MFUhyphenfalse

+

+Compare + + + +

+
+\capitalisewords{server-side includes} +
+

which produces: +
Server-side Includes +
+with + + + +

+
+\MFUhyphentrue + 
\capitalisewords{server-side includes} +
+

which produces: +
Server-Side Includes +
+

Formatting for the entire phrase must go outside \capitalisewords (unlike \makefirstuc). Compare: - + - +

-
+
\capitalisewords{\textbf{a sample phrase}}
-

which produces: +

which produces:
A sample phrase
with: - + - +

-
+
\textbf{\capitalisewords{a sample phrase}}
-

which produces: +

which produces:
A Sample Phrase
-


As from version 2.03, there is now a command for phrases that may include a formatting +command: +


\capitalisefmtwords{phrase}

+

+where ⟨phrase⟩ may be just words (as with \capitalisewords) or may be entirely enclosed in a +formatting command in the form

+
+\capitalisefmtwords{cs{phrase}} +
+
or contain formatted sub-phrases
+
+\capitalisefmtwords{words cs{sub-phrase} words} +
+
Avoid scoped declarations. +

Examples: +

    +
  1. Phrase entirely enclosed in a formatting command: + + + +
    + \capitalisefmtwords{\textbf{a small book of rhyme}} +
    +

    produces: +
    A Small Book Of Rhyme +
    +

  2. +
  3. Sub-phrase enclosed in a formatting command: + + + +
    + \capitalisefmtwords{a \textbf{small book} of rhyme} +
    +

    produces: +
    A Small Book Of Rhyme +
    +

  4. +
  5. Nested text-block commands: + + + +
    + \capitalisefmtwords{\textbf{a \emph{small book}} of rhyme} +
    +

    produces: +
    A Small Book Of Rhyme +
    +

  6. +
  7. Indicating words that shouldn’t have the case changed (see §3.2 Excluding Words From + Case-Changing): + + + +
    + \MFUnocap{of} +  
    \capitalisefmtwords{\textbf{a \emph{small book}} of rhyme} +
    +

    produces: +
    A Small Book of Rhyme +
    +

+

Grouping causes interference: + + + +

+
+\capitalisefmtwords{{a \emph{small book}} of rhyme} +
+

produces: +
A Small book Of Rhyme +
+As with all the commands described here, avoid declarations. For example, the following +fails: + + + +

+
+\capitalisefmtwords{{\bfseries a \emph{small book}} of rhyme} +
+

produces: +
a Small book Of Rhyme +
+


\xcapitalisewords  \xcapitalisewords{text}

-

+

This is a short cut for \expandafter\capitalisewords\expandafter{text}. -

As from version 1.10, there is now a command that fully expands the entire -argument before applying

As from version 1.10, there is now a command that fully expands the entire argument +before applying \capitalisewords: -



\ecapitalisewords  \ecapitalisewords{text}

-

-

Examples: - +

+

There are also similar shortcut commands for the version that allows formatting +commands: +


\xcapitalisefmtwords  \xcapitalisefmtwords{text}

+

+This is a short cut for \expandafter\capitalisefmtwords\expandafter{text}. +

For full expansion: +


\ecapitalisefmtwords  \ecapitalisefmtwords{text}

+

+Take care with this as it may expand non-robust semantic commands to replacement text that +breaks the functioning of \capitalisefmtwords. Use robust semantic commands where +possible. +

Examples: + - +

-
+
\newcommand{\abc}{\xyz\space four five}  
\newcommand{\xyz}{one two three}  
No expansion: \capitalisewords{\abc}.  
First object one-level expansion: \xcapitalisewords{\abc}.  
Fully expanded: \ecapitalisewords{\abc}.
-

produces: No expansion: ONE TWO THREE FOUR FIVE. First object one-level -expansion: ONE TWO THREE four Five. Fully expanded: One Two Three Four -Five. -

(Remember that the spaces need to be explicit. In the second case above, using +

produces: +
No expansion: ONE TWO THREE FOUR FIVE. +
First object one-level expansion: ONE TWO THREE four Five. +
Fully expanded: One Two Three Four Five. +
+

(Remember that the spaces need to be explicit. In the second case above, using \xcapitalisewords, the space before “four” has been hidden within \space so it’s not recognised as a word boundary, but in the third case, \space has been expanded to an -actual space character.) -

If you are using hyperref and want to use \capitalisewords or \makefirstuc (or -the expanded variants) in a section heading, the PDF bookmarks won’t be able to use -the command as it’s not expandable, so you will get a warning that looks -like: - - - -

-
-Package hyperref Warning: Token not allowed in a PDF string - 
(PDFDocEncoding): - 
(hyperref)                removing ‘\capitalisewords’ -
-

If you want to provide an alternative for the PDF bookmark, you can use -hyperref’s \texorpdfstring command. See the hyperref manual for further details. -

-

-

Examples: +class="cmtt-10">\space has been expanded to an actual +space character.) +

Examples:

  1. - + class="enumerate" id="x1-4020x1"> + - -
    + +
    \capitalisewords{a book of rhyme.}
    -

    produces: A Book Of Rhyme. +

    produces: A Book Of Rhyme.

  2. - + class="enumerate" id="x1-4022x2"> + - -
    + +
    \capitalisewords{a book\space of rhyme.}
    -

    produces: A Book of Rhyme. +

    produces: A Book of Rhyme.

  3. - + class="enumerate" id="x1-4024x3"> + - -
    + +
    \newcommand{\mytitle}{a book\space of rhyme.}  
    \capitalisewords{\mytitle}
    -

    produces: A BOOK OF RHYME. (No expansion is performed on \mytitle.) - Compare with next example: +

    produces: A BOOK OF RHYME. (No expansion is performed on \mytitle.) Compare + with next example:

  4. - + class="enumerate" id="x1-4026x4"> + - -
    + +
    \newcommand{\mytitle}{a book\space of rhyme.}  
    \xcapitalisewords{\mytitle}
    -

    produces: A Book of Rhyme. -

    However - +

    produces: A Book of Rhyme. +

    However + - +

    -
    +
    \ecapitalisewords{\mytitle}
    -

    produces: A Book Of Rhyme. +

    produces: A Book Of Rhyme.

-

As from v1.09, you can specify words which shouldn’t be capitalised unless they -occur at the start of ⟨

+

+

Top

3.1 PDF Bookmarks

+

If you are using hyperref and want to use \capitalisewords, \capitalisefmtwords or +\makefirstuc (or the expanded variants) in a section heading, the PDF bookmarks won’t be +able to use the command as it’s not expandable, so you will get a warning that looks +like: + + + +

+
+Package hyperref Warning: Token not allowed in a PDF string + 
(PDFDocEncoding): + 
(hyperref)                removing ‘\capitalisewords’ +
+

+

+

If you want to provide an alternative for the PDF bookmark, you can use hyperref’s +\texorpdfstring command. For example: + + + +

+
+\chapter{\texorpdfstring + 
  {\capitalisewords{a book of rhyme}}% TeX + 
  {A Book of Rhyme}% PDF + 
} +
+

Alternatively, you can use hyperref’s mechanism for disabling commands within the +bookmarks. For example: + + + +

+
+\pdfstringdefDisableCommands{% + 
 \let\capitalisewords\@firstofone + 
} +
+

+

See the hyperref manual for further details. +

+

+

Top

3.2 Excluding Words From Case-Changing

+

As from v1.09, you can specify words which shouldn’t be capitalised unless they occur at the +start of ⟨text⟩ using: -



\MFUnocap  \MFUnocap{word}

-

+

This only has a local effect. The global version is: -



\gMFUnocap  \gMFUnocap{word}

-

-

For example: - +

+

For example: + - +

-
+
\capitalisewords{the wind in the willows}  
\MFUnocap{in}%  
\MFUnocap{the}%  
\capitalisewords{the wind in the willows}
-

produces: +

produces:
The Wind In The Willows
The Wind in the Willows
The list of words that shouldn’t be capitalised can be cleared using -



\MFUclear  \MFUclear

-

-

The package

+

You can also simply place an empty group in front of a word if you don’t want that specific +instance to be capitalised. For example: + + + +

+
+\MFUclear + 
\capitalisewords{the {}wind in the willows} +
+

produces: +
The wind In The Willows +
+This is also a useful way of protecting commands that shouldn’t be parsed. For +example: + + + +

+
+\capitalisewords{this is section {}\nameref{sec:nocap}.} +
+

produces +
This Is Section Excluding Words From Case-Changing. +
+(No case-changing is applied to \nameref{sec:nocap}.) +

The package mfirstuc-english loads mfirstuc and uses loads mfirstuc and uses \MFUnocap to add common -English articles and conjunctions, such as “a”, “an”, “and”, “but”. You may want to -add other words to this list, such as prepositions, but as there’s some dispute over -whether prepositions should be capitalised, I don’t intend to add them to this +English articles and conjunctions, such as “a”, “an”, “and”, “but”. You may want +to add other words to this list, such as prepositions but, as there’s some dispute +over whether prepositions should be capitalised, I don’t intend to add them to this package. -

If you want to write a similar package for another language, all you need to do is -create a file with the extension

If you want to write a similar package for another language, all you need to do is create a +file with the extension .sty that starts with - + - +

-
+
\NeedsTeXFormat{LaTeX2e}
-

The next line should identify the package. For example, if you have called the file +

The next line should identify the package. For example, if you have called the file mfirstuc-french.sty then you need: - + - +

-
+
\ProvidesPackage{mfirstuc-french}
-

It’s a good idea to also add a version in the final optional argument, for example: - +

It’s a good idea to also add a version in the final optional argument, for example: + - +

-
+
\ProvidesPackage{mfirstuc-french}[2014/07/30 v1.0]
-

Next load mfirstuc: - +

Next load mfirstuc: + - +

-
+
\RequirePackage{mfirstuc}
-

Now add all your

Now add all your \MFUnocap commands. For example: - + - +

-
+
\MFUnocap{de}
-

At the end of the file add: - +

At the end of the file add: + - +

-
+
\endinput
-

-

Put the file somewhere on T

+

Put the file somewhere on TEX’s path, and now you can use this package in your -document. You might also consider uploading it to CTAN in case other users find it +document. You might also consider uploading it to CTAN in case other users find it useful. -

+

-

Top

4 UTF-8

-

The \makefirstuc command works by utilizing the fact that, in most cases, -TEX doesn’t require a regular argument to be enclosed in braces if it only consists of a -single token. (This is why you can do, say,

The \makefirstuc command works by utilizing the fact that, in most cases, TEX doesn’t +require a regular argument to be enclosed in braces if it only consists of a single token. (This is +why you can do, say, \frac12 instead of \frac{1}{2} or x^2 -instead of x^{2}, although some users frown on this practice.) -

A simplistic version of the x^2 instead of x^{2}, although some +users frown on this practice.) +

A simplistic version of the \makefirstuc command is: - + - +

-
+
\newcommand*{\FirstUC}[1]{\MakeUppercase #1}
-

Here - +

Here + - +

-
+
\FirstUC{abc}
-

is equivalent to - +

is equivalent to + - +

-
+
\MakeUppercase abc
-

and since \MakeUppercase requires an argument, it grabs the first token (the -character “a” in this case) and uses that as the argument so that the result is: -Abc. -

The

and since \MakeUppercase requires an argument, it grabs the first token (the character “a” in +this case) and uses that as the argument so that the result is: Abc. +

The glossaries package needs to take into account the fact that the text may be -contained in the argument of a formatting command, such as \acronymfont, so -\makefirstuc has to be more complicated than the trivial \FirstUC shown above, but -at its basic level, \makefirstuc uses this same method and is the reason why, -in most cases, you don’t need to enclose the first character in braces. So if -

+ id="dx1-7001"> package needs to take into account the fact that the text may be contained +in the argument of a formatting command, such as \acronymfont, so \makefirstuc has to be +more complicated than the trivial \FirstUC shown above, but at its basic level, \makefirstuc +uses this same method and is the reason why, in most cases, you don’t need to enclose the first +character in braces. So if

\MakeUppercasestuff⟩ class="cmtt-10">\makefirstuc{⟨stuff} - - -
nor
@@ -826,9 +1186,12 @@ class="cmtt-10">\foo{⟨stuff}} + + +
-

Try the following document:

+

Try the following document:

\documentclassdocument}
-

This will result in the error: - +

This will result in the error: + - +

-
+
! Argument of \UTFviii@two@octets has an extra }.
-

This is why

This is why \makefirstuc{ãbc} won’t work. It will only work if the character ã is -placed inside a group. -

The reason for this error message is due to TEX having been written before -Unicode was invented. Although ã may look like a single character in your text editor, -from TEX’s point of view it’s ã is placed +inside a group. +

The reason for this error message is due to TEX having been written before Unicode was +invented. Although ã may look like a single character in your text editor, from TEX’s point +of view it’s two tokens. So

ãbc
tries to apply \MakeUppercase to just the first octet of ã. This means that the second -octet has been separated from the first octet, which is the cause of the error. In this -case the argument isn’t a single token, so the two tokens (the first and second octet of -ã) must be grouped:
+class="cmtt-10">\MakeUppercase to just the first octet of ã. This means that the second octet +has been separated from the first octet, which is the cause of the error. In this case the +argument isn’t a single token, so the two tokens (the first and second octet of ã) must be +grouped:
\MakeUppercase}bc
-

Note that XeTeX (and therefore XeLaTeX) is a modern implementation of -TEX designed to work with Unicode and therefore doesn’t suffer from this -drawback. Now let’s look at the XeLaTeX equivalent of the above example: -

+

Note that XeTeX (and therefore XeLaTeX) is a modern implementation of TEX designed +to work with Unicode and therefore doesn’t suffer from this drawback. Now let’s look at the +XeLaTeX equivalent of the above example:

\documentclassdocument}
- - - -

This works correctly when compiled with XeLaTeX. This means that -

This works correctly when compiled with XeLaTeX. This means that \makefirstuc{ãbc} will work } +will work provided you use XeLaTeX and the fontspec - package. + + + +

+

+

Index

+

C

- +
\capitalisewords  5
+

E +\ecapitalisefmtwords  8
+\ecapitalisewords  8
+\emakefirstuc  4
+

F +fontspec package  13
+

G +glossaries package  4, 12
+\glsmakefirstuc  4
+\gMFUnocap  10
+

H +hyperref package  9
+

I +\ifMFUhyphen  5
+inputenc package  3
+

M +\makefirstuc  2
+mfirstuc-english package  10
+\MFUcapword  5
+\MFUclear  10
+\MFUhyphenfalse  5
+\MFUhyphentrue  5
+\MFUnocap  9
+

T +textcase package  4
+

X +\xcapitalisefmtwords  8
+ + + +\xcapitalisewords  7
+\xmakefirstuc  4
+

+ - + diff --git a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf index 871632e2875..96f70aad756 100644 Binary files a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf and b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf differ diff --git a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex index 8dc9701bfa9..26c3ce9149d 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex +++ b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex @@ -1,5 +1,6 @@ \documentclass{nlctdoc} +\usepackage[a4paper,left=1.75in]{geometry} \usepackage{alltt} \usepackage{mfirstuc} \usepackage{pifont} @@ -19,14 +20,19 @@ pdftitle={mfirstuc.sty: uppercasing first letter}, pdfkeywords={LaTeX,package,uppercase}]{hyperref} +\IndexPrologue{% +\section*{\indexname}\markright{\indexname} +\addcontentsline{toc}{section}{\indexname}} + \begin{document} - \title{mfirstuc.sty v2.02: +\MakeShortVerb{|} + \title{mfirstuc.sty v2.03: uppercasing first letter} \author{Nicola L.C. Talbot\\[10pt] Dickimaw Books\\ \url{http://www.dickimaw-books.com/}} - \date{2015-12-17} + \date{2016-07-29} \maketitle \tableofcontents @@ -39,7 +45,61 @@ as the commands provided by \styfmt{mfirstuc} may be used without \styfmt{glossaries}, the two have been split into separately maintained packages. -\section{Capitalising a Word} +\begin{important} +The commands described here all have limitations. To minimise +problems, use text-block style semantic commands with one argument +(the text that requires case-changing), and avoid scoped +declarations. +\end{important} + +Here are some examples of semantic commands: +\begin{enumerate} +\item Quoted material: +\begin{verbatim} +\newcommand{\qt}[1]{``#1''} +\end{verbatim} +(or use the \styfmt{csquotes} package). With this, the following +works: +\begin{verbatim} +\makefirstuc{\qt{word}} +\end{verbatim} +This produces: +\begin{display} +\makefirstuc{\qt{word}} +\end{display} +Whereas +\begin{verbatim} +\makefirstuc{``word''} +\end{verbatim} +fails (no case-change and double open quote becomes two single open +quotes): +\begin{display} +\makefirstuc{``word''} +\end{display} + +\item Font styles or colours: +\begin{verbatim} +\newcommand*{\alert}[1]{\textcolor{red}{#1}} +\end{verbatim} +Now the following is possible: +\begin{verbatim} +\makefirstuc{\alert{word}} +\end{verbatim} +This produces +\begin{display} +\newcommand*{\alert}[1]{\textcolor{red}{#1}}% +\makefirstuc{\alert{word}} +\end{display} +Note that \verb|\makefirstuc{\textcolor{red}{word}}| fails +(with an error) because the case-changing interferes with the label. +\end{enumerate} + +Define these semantic commands robustly if you intend using +any of the commands that fully expand their argument +(\cs{emakefirstuc}, \cs{ecapitalisewords} and +\cs{ecapitalisefmtwords}). + +\section{Capitalising the First Letter of a Word} \label{sec:makefirstuc} A simple word can be capitalised just using the standard \LaTeX\ @@ -65,7 +125,7 @@ If \meta{stuff} starts with a control sequence that takes more than one argument, the case-changing will always be applied to the \emph{first} argument. If the text that requires the case change is in one of the other arguments, you must hide the earlier arguments -in a wrapper command. For example, instead of \verb|\color{red}{text}| +in a wrapper command. For example, instead of \verb|\textcolor{red}{text}| you need to define, say, \verb|\red| as \verb|\color{red}| and use \verb|\red{text}|. \end{important} @@ -179,7 +239,7 @@ For example: Remember to also load \sty{textcase} (\styfmt{glossaries} loads this automatically). -\section{Capitalise Each Word in a Phrase or Sentence (Title Case)} +\section{Capitalise the First Letter of Each Word in a Phrase or Sentence (Title Case)} \label{sec:capitalisewords} New to mfirstuc v1.06: @@ -190,7 +250,47 @@ This command applies \ics{makefirstuc} to each word in \meta{text} where the space character is used as the word separator. Note that it has to be a plain space character, not another form of space, such as \verb|~| or \cs{space}. Note that no expansion is performed -on \meta{text}. +on \meta{text}. See \sectionref{sec:nocap} for excluding +words (such as \qt{of}) from the case-changing. + +The actual capitalisation of each word is done using +(new to version 2.03): +\begin{definition}[\DescribeMacro\MFUcapword] +\cs{MFUcapword}\marg{word} +\end{definition} +This just does \cs{makefirstuc}\marg{word} by default, but +its behaviour is determined by the conditional: +\begin{definition}[\DescribeMacro\ifMFUhyphen] +\cs{ifMFUhyphen} +\end{definition} + +If you want to title case each part of +a compound word containing hyphens, you can enable this using +\begin{definition}[\DescribeMacro\MFUhyphentrue] +\cs{MFUhyphentrue} +\end{definition} +or switch it back off again using: +\begin{definition}[\DescribeMacro\MFUhyphenfalse] +\cs{MFUhyphenfalse} +\end{definition} +Compare +\begin{verbatim} +\capitalisewords{server-side includes} +\end{verbatim} +which produces: +\begin{display} +\capitalisewords{server-side includes} +\end{display} +with +\begin{verbatim} +\MFUhyphentrue +\capitalisewords{server-side includes} +\end{verbatim} +which produces: +\begin{display} +\MFUhyphentrue +\capitalisewords{server-side includes} +\end{display} Formatting for the entire phrase must go outside \cs{capitalisewords} (unlike \cs{makefirstuc}). Compare: @@ -210,6 +310,82 @@ which produces: \textbf{\capitalisewords{a sample phrase}} \end{display} +As from version 2.03, there is now a command for phrases that may +include a formatting command: +\begin{definition} +\cs{capitalisefmtwords}\marg{phrase} +\end{definition} +where \meta{phrase} may be just words (as with \cs{capitalisewords}) +or may be entirely enclosed in a formatting command in the form +\begin{alltt} +\cs{capitalisefmtwords}\{\meta{cs}\marg{phrase}\} +\end{alltt} +or contain formatted sub-phrases +\begin{alltt} +\cs{capitalisefmtwords}\{\meta{words} \meta{cs}\marg{sub-phrase} \meta{words}\} +\end{alltt} +Avoid scoped declarations. + +Examples: +\begin{enumerate} +\item Phrase entirely enclosed in a formatting command: +\begin{verbatim} +\capitalisefmtwords{\textbf{a small book of rhyme}} +\end{verbatim} +produces: +\begin{display} +\capitalisefmtwords{\textbf{a small book of rhyme}} +\end{display} + +\item Sub-phrase enclosed in a formatting command: +\begin{verbatim} +\capitalisefmtwords{a \textbf{small book} of rhyme} +\end{verbatim} +produces: +\begin{display} +\capitalisefmtwords{a \textbf{small book} of rhyme} +\end{display} + +\item Nested text-block commands: +\begin{verbatim} +\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme} +\end{verbatim} +produces: +\begin{display} +\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme} +\end{display} + +\item Indicating words that shouldn't have the case changed +(see \sectionref{sec:nocap}): +\begin{verbatim} +\MFUnocap{of} +\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme} +\end{verbatim} +produces: +\begin{display} +\MFUnocap{of} +\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme} +\end{display} +\end{enumerate} + +Grouping causes interference: +\begin{verbatim} +\capitalisefmtwords{{a \emph{small book}} of rhyme} +\end{verbatim} +produces: +\begin{display} +\capitalisefmtwords{{a \emph{small book}} of rhyme} +\end{display} +As with all the commands described here, avoid declarations. +For example, the following fails: +\begin{verbatim} +\capitalisefmtwords{{\bfseries a \emph{small book}} of rhyme} +\end{verbatim} +produces: +\begin{display} +\capitalisefmtwords{{\bfseries a \emph{small book}} of rhyme} +\end{display} + \begin{definition}[\DescribeMacro{\xcapitalisewords}] \cs{xcapitalisewords}\marg{text} \end{definition} @@ -222,6 +398,23 @@ entire argument before applying \cs{capitalisewords}: \cs{ecapitalisewords}\marg{text} \end{definition} +There are also similar shortcut commands for the version that allows +formatting commands: +\begin{definition}[\DescribeMacro{\xcapitalisefmtwords}] +\cs{xcapitalisefmtwords}\marg{text} +\end{definition} +This is a short cut for +\cs{expandafter}\cs{capitalisefmtwords}\cs{expandafter}\marg{text}. + +For full expansion: +\begin{definition}[\DescribeMacro\ecapitalisefmtwords] +\cs{ecapitalisefmtwords}\marg{text} +\end{definition} +Take care with this as it may expand non-robust semantic commands +to replacement text that breaks the functioning of +\cs{capitalisefmtwords}. Use robust semantic commands +where possible. + Examples: \begin{verbatim} \newcommand{\abc}{\xyz\space four five} @@ -231,11 +424,13 @@ First object one-level expansion: \xcapitalisewords{\abc}. Fully expanded: \ecapitalisewords{\abc}. \end{verbatim} produces: +\begin{display} \renewcommand{\abc}{\xyz\space four five}% \renewcommand{\xyz}{one two three} No expansion: \capitalisewords{\abc}. First object one-level expansion: \xcapitalisewords{\abc}. Fully expanded: \ecapitalisewords{\abc}. +\end{display} (Remember that the spaces need to be explicit. In the second case above, using \cs{xcapitalisewords}, the space before \qt{four} has @@ -243,21 +438,6 @@ been hidden within \cs{space} so it's not recognised as a word boundary, but in the third case, \cs{space} has been expanded to an actual space character.) -\begin{important} -If you are using \sty{hyperref} and want to use \cs{capitalisewords} -or \ics{makefirstuc} (or the expanded variants) -in a section heading, the PDF bookmarks won't be able to use the command -as it's not expandable, so you will get a warning that looks like: -\begin{verbatim} -Package hyperref Warning: Token not allowed in a PDF string -(PDFDocEncoding): -(hyperref) removing `\capitalisewords' -\end{verbatim} -If you want to provide an alternative for the PDF bookmark, you can -use \sty{hyperref}'s \ics{texorpdfstring} command. See the -\sty{hyperref} manual for further details. -\end{important} - Examples: \begin{enumerate} \item @@ -301,6 +481,43 @@ produces: \end{enumerate} +\subsection{PDF Bookmarks} +\label{sec:pdfbookmarks} + +\begin{important} +If you are using \sty{hyperref} and want to use +\cs{capitalisewords}, \cs{capitalisefmtwords} +or \ics{makefirstuc} (or the expanded variants) +in a section heading, the PDF bookmarks won't be able to use the command +as it's not expandable, so you will get a warning that looks like: +\begin{verbatim} +Package hyperref Warning: Token not allowed in a PDF string +(PDFDocEncoding): +(hyperref) removing `\capitalisewords' +\end{verbatim} +\end{important} + +If you want to provide an alternative for the PDF bookmark, you can +use \sty{hyperref}'s \ics{texorpdfstring} command. For example: +\begin{verbatim} +\chapter{\texorpdfstring + {\capitalisewords{a book of rhyme}}% TeX + {A Book of Rhyme}% PDF +} +\end{verbatim} +Alternatively, you can use \sty{hyperref}'s mechanism for +disabling commands within the bookmarks. For example: +\begin{verbatim} +\pdfstringdefDisableCommands{% + \let\capitalisewords\@firstofone +} +\end{verbatim} + +See the \sty{hyperref} manual for further details. + +\subsection{Excluding Words From Case-Changing} +\label{sec:nocap} + As from v1.09, you can specify words which shouldn't be capitalised unless they occur at the start of \meta{text} using: \begin{definition}[\DescribeMacro\MFUnocap] @@ -334,10 +551,33 @@ The list of words that shouldn't be capitalised can be cleared using \cs{MFUclear} \end{definition} -The package \sty{mfirstuc-english} loads \sty{mfirstuc} and uses +You can also simply place an empty group in front of a word +if you don't want that specific instance to be capitalised. +For example: +\begin{verbatim} +\MFUclear +\capitalisewords{the {}wind in the willows} +\end{verbatim} +produces: +\begin{display} +\MFUclear +\capitalisewords{the {}wind in the willows} +\end{display} +This is also a useful way of protecting commands that +shouldn't be parsed. For example: +\begin{verbatim} +\capitalisewords{this is section {}\nameref{sec:nocap}.} +\end{verbatim} +produces +\begin{display} +\capitalisewords{this is section {}\nameref{sec:nocap}.} +\end{display} +(No case-changing is applied to \verb|\nameref{sec:nocap}|.) + +The package \sty{mfirstuc-english} loads \styfmt{mfirstuc} and uses \cs{MFUnocap} to add common English articles and conjunctions, such as ``a'', ``an'', ``and'', ``but''. You may want to add other -words to this list, such as prepositions, but as there's some +words to this list, such as prepositions but, as there's some dispute over whether prepositions should be capitalised, I~don't intend to add them to this package. @@ -357,7 +597,7 @@ argument, for example: \begin{verbatim} \ProvidesPackage{mfirstuc-french}[2014/07/30 v1.0] \end{verbatim} -Next load \sty{mfirstuc}: +Next load \styfmt{mfirstuc}: \begin{verbatim} \RequirePackage{mfirstuc} \end{verbatim} @@ -371,8 +611,9 @@ At the end of the file add: \end{verbatim} Put the file somewhere on \TeX's path, and now you can use this -package in your document. You might also consider uploading it -to CTAN in case other users find it useful. +package in your document. You might also consider +\href{http://ctan.org/upload}{uploading it to CTAN} in case +other users find it useful. \section{UTF-8} \label{sec:utf8} @@ -490,4 +731,5 @@ This works correctly when compiled with \XeLaTeX. This means that \cs{makefirstuc}\verb|{|\texttt{\~abc}\verb|}| will work \emph{provided you use \XeLaTeX\ and the \sty{fontspec} package}. +\PrintIndex \end{document} diff --git a/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.pdf b/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.pdf index b625ae9f476..0468a09a98b 100644 Binary files a/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.pdf and b/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.pdf differ diff --git a/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex b/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex index 5fe9d92b48c..eb1104be59a 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex +++ b/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex @@ -3,20 +3,31 @@ % 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}. @@ -26,30 +37,169 @@ 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.}} + +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}. -\capitalisewords{a book of rhyme.} +\begin{verbatim} +\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}. +\end{verbatim} +\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}. -\MFUclear +\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}. + +\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 + +\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} 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} % @@ -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 diff --git a/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins index 4cc683f7cc2..b90e4ce4cf5 100644 --- a/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins +++ b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins @@ -1,10 +1,10 @@ -% mfirstuc.ins generated using makedtx version 1.1 2015/12/17 12:46 +% mfirstuc.ins generated using makedtx version 1.1 2016/7/29 22:54 \input docstrip \preamble mfirstuc.dtx - Copyright 2015 Nicola Talbot + Copyright 2016 Nicola Talbot This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 diff --git a/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty index f8a111daaf6..ad28d61a6c0 100644 --- a/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty +++ b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty @@ -7,7 +7,7 @@ %% mfirstuc.dtx (with options: `mfirstuc-english.sty,package') %% %% mfirstuc.dtx -%% Copyright 2015 Nicola Talbot +%% Copyright 2016 Nicola Talbot %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -39,7 +39,7 @@ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{mfirstuc-english}[2015/09/09 v2.0 (NLCT)] +\ProvidesPackage{mfirstuc-english}[2016/07/29 v2.03 (NLCT)] \RequirePackage{mfirstuc} \MFUnocap{a} \MFUnocap{an} diff --git a/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty index 472c831cc3d..08b0f1f3aea 100644 --- a/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty +++ b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty @@ -7,7 +7,7 @@ %% mfirstuc.dtx (with options: `mfirstuc.sty,package') %% %% mfirstuc.dtx -%% Copyright 2015 Nicola Talbot +%% Copyright 2016 Nicola Talbot %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -39,7 +39,7 @@ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{mfirstuc}[2015/12/17 v2.02 (NLCT)] +\ProvidesPackage{mfirstuc}[2016/07/29 v2.03 (NLCT)] \RequirePackage{etoolbox} \newif\if@glscs \newtoks\@glsmfirst @@ -47,8 +47,10 @@ \newrobustcmd*{\makefirstuc}[1]{% \@MFU@p@makefirstuc#1\relax\relax\relax\@end@MFU@protected{#1}% } +\newcommand*{\@MFU@protect}{\protect} \def\@MFU@p@makefirstuc#1#2#3\@end@MFU@protected#4{% - \ifx\protect#1\relax + \def\gls@argi{#1}% + \ifx\gls@argi\@MFU@protect \@makefirstuc{#2#3}% \else \@makefirstuc{#4}% @@ -90,8 +92,27 @@ \fi \fi } -\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}% + } } \def\@gls@checkcs#1 #2#3\relax{% \def\@gls@argi{#1}\def\@gls@argii{#2}% @@ -101,21 +122,66 @@ \@glscsfalse \fi } -\def\@gls@makefirstuc#1{\mfirstucMakeUppercase #1} +\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} +} +\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} +} +\def\@gls@makefirstuc#1{\MFUapplytofirst\mfirstucMakeUppercase{#1}} \newcommand*{\mfirstucMakeUppercase}{\MakeUppercase} \newcommand*{\glsmakefirstuc}[1]{\@gls@makefirstuc{#1}} \def\@gls@getbody#1#{\def\@gls@body{#1}\@gls@gobbletonil} \def\@gls@gobbletonil#1\@nil{\def\@gls@rest{#1}} \newcommand*{\xmakefirstuc}[1]{% -\expandafter\makefirstuc\expandafter{#1}} -\DeclareRobustCommand*{\emakefirstuc}[1]{% + \expandafter\makefirstuc\expandafter{#1}% +} +\newrobustcmd*{\emakefirstuc}[1]{% \protected@edef\@MFU@caparg{#1}% \expandafter\makefirstuc\expandafter{\@MFU@caparg}% } \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 +} +\newcommand*{\@mfu@mid@capitalisewords}[1]{% + \def\gls@add@space{}% + \let\@mfu@domakefirstuc\MFUcapword \mfu@capitalisewords#1 \@nil\mfu@endcap } \def\mfu@capitalisewords#1 #2\mfu@endcap{% @@ -134,9 +200,26 @@ \next@mfu@cap#2\mfu@endcap } \def\mfu@noop#1\mfu@endcap{} +\newif\ifMFUhyphen +\MFUhyphenfalse +\newcommand*{\MFUcapword}[1]{% + \ifMFUhyphen + \@MFUcapword#1-\@nil\@endMFUcapword + \else + \makefirstuc{#1}% + \fi +} +\def\@MFUcapword#1-#2\@endMFUcapword{% + \makefirstuc{#1}% + \def\@mfu@argii{#2}% + \ifx\@mfu@argii\@nnil + \else + -\@MFUcapword#2\@endMFUcapword + \fi +} \newcommand*\mfu@checkword[1]{% \def\mfu@checkword@arg{#1}% - \let\@mfu@domakefirstuc\makefirstuc + \let\@mfu@domakefirstuc\MFUcapword \forlistloop\mfu@checkword@do\@mfu@nocaplist } \newcommand*{\mfu@checkword@do}[1]{% @@ -154,10 +237,93 @@ \newcommand*{\xcapitalisewords}[1]{% \expandafter\capitalisewords\expandafter{#1}% } -\DeclareRobustCommand*{\ecapitalisewords}[1]{% +\newrobustcmd*{\ecapitalisewords}[1]{% \protected@edef\@MFU@caparg{#1}% \expandafter\capitalisewords\expandafter{\@MFU@caparg}% } +\newcommand*{\capitalisefmtwords}[1]{% + \let\@mfu@checkword\@gobble + \def\gls@add@space{}% + \@capitalisefmtwords#1 \@nil\relax +} +\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 +}% +\def\@capitalise@fmtwords#1{% + \def\gls@argi{#1}% + \ifx\gls@argi\@nnil + \let\@mfu@capfmtwordsnext\relax + \else + \ifx\gls@argi\@MFU@protect + \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 +} +\def\@@capitalisefmtwords#1{% + \@ifnextchar\bgroup{\@@capfmtphrase#1}{\@@capnofmtphrase#1}% +} +\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 +} +\def\@@capnofmtphrase#1\@nil{% + \gls@add@space + \@mfu@mid@capitalisewords{#1}% + \def\gls@add@space{ }% +} +\def\@@capfmtsubphrase#1#2#3\@nil{% + \gls@add@space + #1{\@mfu@mid@capitalisewords{#2}}% + \def\gls@add@space{ }% + \let\@mfu@checkword\mfu@checkword + #3% +} +\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 +} +\newcommand*{\xcapitalisefmtwords}[1]{% + \expandafter\capitalisefmtwords\expandafter{#1}% +} +\newrobustcmd*{\ecapitalisefmtwords}[1]{% + \protected@edef\@MFU@caparg{#1}% + \expandafter\capitalisefmtwords\expandafter{\@MFU@caparg}% +} \endinput %% %% End of file `mfirstuc.sty'. -- cgit v1.2.3