From a680fbdd019a24e851538a6dfde26ef301a0a286 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 1 Aug 2016 21:47:34 +0000 Subject: mfirstuc (1aug16) git-svn-id: svn://tug.org/texlive/trunk@41785 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/mfirstuc/CHANGES | 6 + Master/texmf-dist/doc/latex/mfirstuc/README | 4 +- .../doc/latex/mfirstuc/mfirstuc-code.pdf | Bin 253433 -> 258742 bytes .../doc/latex/mfirstuc/mfirstuc-manual.html | 704 +++++++++++++-------- .../doc/latex/mfirstuc/mfirstuc-manual.pdf | Bin 301194 -> 294036 bytes .../doc/latex/mfirstuc/mfirstuc-manual.tex | 175 ++++- .../doc/latex/mfirstuc/sample-mfirstuc.pdf | Bin 81539 -> 114525 bytes .../doc/latex/mfirstuc/sample-mfirstuc.tex | 160 +++-- 8 files changed, 736 insertions(+), 313 deletions(-) (limited to 'Master/texmf-dist/doc/latex') diff --git a/Master/texmf-dist/doc/latex/mfirstuc/CHANGES b/Master/texmf-dist/doc/latex/mfirstuc/CHANGES index a26a2081d53..30af7cc0c23 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/CHANGES +++ b/Master/texmf-dist/doc/latex/mfirstuc/CHANGES @@ -1,5 +1,11 @@ mfirstuc change log: +v2.04: + + * bug fixes in \capitalisefmtwords and \@gls@split + + * added starred form of \capitalisefmtwords + v2.03: * Fixed test for \protect at the start of \makefirstuc diff --git a/Master/texmf-dist/doc/latex/mfirstuc/README b/Master/texmf-dist/doc/latex/mfirstuc/README index d226cadfcf5..34fe2c97502 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.03 +LaTeX Package : mfirstuc v2.04 -Last Modified : 2016-07-29 +Last Modified : 2016-07-31 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 bb88c50955c..c6b9d28275c 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 5b60f1e19c9..70ac173482c 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html +++ b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html @@ -127,6 +127,7 @@ table.pmatrix {width:100%;} span.bar-css {text-decoration:overline;} img.cdots{vertical-align:middle;} .partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;} +.chapterToc a, .chapterToc, .likechapterToc a, .likechapterToc, .appendixToc a, .appendixToc {line-height: 200%; font-weight:bold;} .index-item, .index-subitem, .index-subsubitem {display:block} div.caption {text-indent:-2em; margin-left:3em; margin-right:1em; text-align:left;} div.caption span.id{font-weight: bold; white-space: nowrap; } @@ -143,6 +144,7 @@ div.maketitle{ margin-bottom: 2em; } div.author, div.date {text-align:center;} div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; } .quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; } +h1.partHead{text-align: center} .abstract p {margin-left:5%; margin-right:5%;} div.abstract {width:100%;} .alltt P { margin-bottom : 0em; margin-top : 0em; } @@ -172,7 +174,7 @@ span#textcolor1{color:#FF0000} >

mfirstuc.sty v2.03: uppercasing first letter +class="cmr-17">mfirstuc.sty v2.04: uppercasing first letter

http://www.dickimaw-books.com/

2016-07-29

-

Contents

-
- 1 2016-07-31

+ + + +

Contents

+ 1 Introduction -
2 2 Capitalising the First Letter of a Word -
3 3 Capitalise the First Letter of Each Word in a Phrase or Sentence (Title Case) -
 3.1  3.1 PDF Bookmarks -
 3.2  3.2 Excluding Words From Case-Changing -
4 4 UTF-8
-

-

-

Top

1 Introduction

-

The

1. Introduction

+

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.
@@ -291,14 +295,17 @@ class="cmtt-10">\emakefirstuc, \ecapitalisewords and \ecapitalisefmtwords). -

+ + +

-

Top

2 Capitalising the First Letter of a Word

-

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

+

Top

2. Capitalising the First Letter of a Word

+

A simple word can be capitalised just using the standard LATEX upper casing command. +For example, @@ -390,30 +397,67 @@ class="cmtt-10">\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 should 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

New to version 2.04: There is now limited support for UTF-8 characters with the +inputenc package, provided that you load datatool-base (at least v2.24) before mfirstuc +(datatool-base is loaded automatically with newer versions of glossaries). If available mfirstuc +will now use datatool-base’s \dtl@getfirst@UTFviii command which is still experimental. +See the datatool manual for further details. + + + +

+
+\documentclass{article} + 
\usepackage[T1]{fontenc} + 
\usepackage[utf8]{inputenc} + 
\usepackage{datatool-base}[2016/01/12]% v2.24+ + 
\usepackage{mfirstuc} + 
\begin{document} + 
\makefirstuc{élite} + 
\end{document} +
+

(Package ordering is important.) +

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 +

+

Note also that

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

produces: ABC. This is because the first object in the argument of

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 +

+

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: +

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

If you use

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


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 the First Letter of Each Word in a Phrase or Sentence (Title -Case)

-

New to mfirstuc v1.06: -


+

Top

3. 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 ⟨§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): -


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 +

+

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: +

which produces:
Server-side Includes
with @@ -596,14 +642,14 @@ with

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

which produces: +

which produces:
Server-Side Includes
-

Formatting for the entire phrase must go outside

Formatting for the entire phrase must go outside \capitalisewords (unlike \makefirstuc). Compare: @@ -611,10 +657,10 @@ class="cmtt-10">\makefirstuc). Compare:

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

which produces: +

which produces:
A sample phrase
@@ -623,20 +669,20 @@ 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 +

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 @@ -667,17 +713,24 @@ class="cmitt-10">words⟩}

Avoid scoped declarations. -

Examples: +

\capitalisefmtwords is only designed for phrases that contain text-block commands +with a single argument, which should be a word or sub-phrase. Anything more complicated is +likely to break. Instead, use the starred form or \capitalisewords.
+

+

The starred form only permits a text-block command at the start of the phrase. +

Examples:

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

    produces: +

    produces:
    A Small Book Of Rhyme
    @@ -687,10 +740,10 @@ class="cmbx-10">A Small Book Of Rhyme -

    +
    \capitalisefmtwords{a \textbf{small book} of rhyme}
    -

    produces: +

    produces:
    A Small Book Of Rhyme
    @@ -700,10 +753,10 @@ class="cmbx-10">Small Book Of Rhyme -

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

    produces: +

    produces:
    A Small Book Of Rhyme @@ -718,25 +771,88 @@ href="#sec:nocap">Excluding Words From -

    +
    \MFUnocap{of}  
    \capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}
    -

    produces: +

    produces:
    A Small Book of Rhyme
    -

-

Grouping causes interference: +

+
  • Starred form: + + + +
    + \MFUnocap{of} +  
    \capitalisefmtwords*{\emph{a small book of rhyme}} +
    +

    produces: +
    A Small Book of Rhyme +
    +

  • +
  • The starred form also works with just text (no text-block command): + + + +
    + \MFUnocap{of} +  
    \capitalisefmtwords*{a small book of rhyme} +
    +

    produces: +
    A Small Book of Rhyme +
    +

    +
  • +

    If there is a text-block command within the argument of the starred form, it’s assumed to +be at the start of the argument. Unexpected results can occur if there are other commands. +For example + + + +

    +
    +\MFUnocap{of} + 
    \capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}} +
    +

    produces: +
    A Small Book Of rhyme +
    +(In this case \textbf{of rhyme} is considered a single word.) Similarly if the text-block +command occurs in the middle of the argument:

    -
    +
    +\MFUnocap{of} + 
    \capitalisefmtwords*{a \emph{very small} book of rhyme} +
    +

    produces: +
    A Very small Book of Rhyme +
    +(In this case \emph{very small} is considered a single word.) +

    Grouping causes interference: + + + +

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

    produces: +

    produces:
    A Small book Of Rhyme
    @@ -746,149 +862,207 @@ fails:

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

    produces: +

    produces:
    a Small book Of Rhyme
    -


    Avoid complicated commands in the unstarred version. For example, the following +breaks: + + + +

    +
    +\newcommand*{\swap}[2]{{#2}{#1}} + 
    \capitalisefmtwords{a \swap{bo}{ok} of rhyme} +
    +

    However it works okay with the starred form and the simpler \capitalisewords: + + + +

    +
    +\newcommand*{\swap}[2]{{#2}{#1}} + 
    \capitalisefmtwords*{a \swap{bo}{ok} of rhyme} + 
    \capitalisewords{a \swap{bo}{ok} of rhyme} +
    +

    Produces: +
    A okBo Of Rhyme +
    A okBo Of Rhyme +
    +Note that the case change is applied to the first argument. +


    \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 +

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



    \ecapitalisewords  \ecapitalisewords{text}

    -

    -

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

    +

    There are also similar shortcut commands for the version that allows text-block commands: -



    \xcapitalisefmtwords  \xcapitalisefmtwords{text}

    -

    -This is a short cut for \expandafter\capitalisefmtwords\expandafter{

    +The unstarred version is a short cut for \expandafter\capitalisefmtwords\expandafter +{text}. -

    For full expansion: -


    }. Similarly the starred version of \xcapitalisefmtwords uses the starred version of +\capitalisefmtwords. +

    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: +

    +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. Again this has a starred version that uses the starred form of +\capitalisefmtwords. +

    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: +

    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 +

    (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.) -

    Examples: +

    Examples:

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

      produces: A Book Of Rhyme. +

      produces: A Book Of Rhyme.

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

      produces: A Book of Rhyme. +

      produces: A Book of Rhyme.

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

      produces: A BOOK OF RHYME. (No expansion is performed on

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

    4. + class="enumerate" id="x1-4030x4"> -
      +
      \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. (\space has been expanded to an actual space + character.) +

    +
  • + + + +
    + \newcommand*{\swap}[2]{{#2}{#1}} +  
    \capitalisewords{a \swap{bo}{ok} of rhyme} +  
    \ecapitalisewords{a \swap{bo}{ok} of rhyme} +
    +

    produces: +
    A okBo Of Rhyme +
    A OKbo Of Rhyme +
    + This is because the argument of \ecapitalisewords is fully expanded before being + passed to \capitalisewords so that last example is equivalent to: + + +

    -

    Top

    3.1 PDF Bookmarks

    -

    If you are using + \capitalisewords{a {ok}{bo} of rhyme} +
    +

  • +

    Top

    3.1 PDF Bookmarks

    +

    If you are using hyperref and want to use \capitalisewords, -
    +
    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

    +

    +

    If you want to provide an alternative for the PDF bookmark, you can use hyperref’s \texorpdfstring -

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

    Alternatively, you can use

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

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

    -

    See the

    +

    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 +

    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

    -

    -

    You can also simply place an empty group in front of a word if you don’t want that specific +

    +

    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: +

    produces:
    The wind In The Willows
    This is also a useful way of protecting commands that shouldn’t be parsed. For @@ -1008,16 +1182,17 @@ example:

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

    produces +

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

    The package \nameref{sec:nocap}. It just happens to already be in title +case.) +

    The package mfirstuc-english loads mfirstuc and uses

    If you want to write a similar package for another language, all you need to do is create a +

    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

    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 useful. -

    + + +

    -

    Top

    4 UTF-8

    -

    The

    +

    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 @@ -1101,35 +1279,35 @@ class="cmtt-10">\frac{1}{2} or x^2 instead of x^{2}, although some users frown on this practice.) -

    A simplistic version of the

    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

    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

    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 \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 T

    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 T}bc

    -

    Note that XeTeX (and therefore XeLaTeX) is a modern implementation of T

    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:

    @@ -1308,7 +1486,7 @@ class="cmtt-10">document}
    -

    This works correctly when compiled with XeLaTeX. This means that

    This works correctly when compiled with XeLaTeX. This means that \makefirstuc{ã and the fontspec package. +

    Version 2.24 of datatool-base added the command \dtl@getfirst@UTFviii which +attempts to grab both octets. If this command has been defined, mfirstuc will use it when it +tries to split the first character from the rest of the word. See the datatool documented code +for further details. -

    -

    Index

    -

    +

    Top

    Index

    C -

    \capitalisewords  5
    +class="cmti-10">8

    D +datatool-base package  6, 19
    +

    E \ecapitalisefmtwords  8
    +class="cmti-10">12
    \ecapitalisewords  8
    +class="cmti-10">12
    \emakefirstuc  4
    +class="cmti-10">7

    F fontspec package  13
    +class="cmss-10">fontspec package  19

    G glossaries package  4, 12
    +class="cmss-10">glossaries package  6, 7, 17
    \glsmakefirstuc  4
    +class="cmti-10">7
    \gMFUnocap  10
    +class="cmti-10">15

    H hyperref package  9
    +class="cmss-10">hyperref package  14

    I \ifMFUhyphen  5
    +class="cmti-10">8
    inputenc package  3
    +class="cmss-10">inputenc package  6

    M \makefirstuc  2
    +class="cmti-10">5
    mfirstuc-english package  10
    +class="cmss-10">mfirstuc package  6, 19
    +mfirstuc-english package  15
    + + + \MFUcapword  5
    +class="cmti-10">8
    \MFUclear  10
    +class="cmti-10">15
    \MFUhyphenfalse  5
    +class="cmti-10">8
    \MFUhyphentrue  5
    +class="cmti-10">8
    \MFUnocap  9
    +class="cmti-10">15

    T textcase package  4
    +class="cmss-10">textcase package  7

    X \xcapitalisefmtwords  8
    - - - +class="cmti-10">12
    \xcapitalisewords  7
    +class="cmti-10">12
    \xmakefirstuc  4
    +class="cmti-10">7

    diff --git a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf index 96f70aad756..02bb0409344 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 26c3ce9149d..caaceb756ce 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex +++ b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex @@ -1,4 +1,4 @@ -\documentclass{nlctdoc} +\documentclass[report]{nlctdoc} \usepackage[a4paper,left=1.75in]{geometry} \usepackage{alltt} @@ -21,22 +21,22 @@ pdfkeywords={LaTeX,package,uppercase}]{hyperref} \IndexPrologue{% -\section*{\indexname}\markright{\indexname} -\addcontentsline{toc}{section}{\indexname}} +\chapter*{\indexname}\markright{\indexname} +\addcontentsline{toc}{chapter}{\indexname}} \begin{document} \MakeShortVerb{|} - \title{mfirstuc.sty v2.03: + \title{mfirstuc.sty v2.04: uppercasing first letter} \author{Nicola L.C. Talbot\\[10pt] Dickimaw Books\\ \url{http://www.dickimaw-books.com/}} - \date{2016-07-29} + \date{2016-07-31} \maketitle \tableofcontents - \section{Introduction} + \chapter{Introduction} \label{sec:intro} The \styfmt{mfirstuc} package was originally part of the @@ -99,7 +99,7 @@ any of the commands that fully expand their argument (\cs{emakefirstuc}, \cs{ecapitalisewords} and \cs{ecapitalisefmtwords}). -\section{Capitalising the First Letter of a Word} +\chapter{Capitalising the First Letter of a Word} \label{sec:makefirstuc} A simple word can be capitalised just using the standard \LaTeX\ @@ -158,11 +158,36 @@ therefore first object is |\em| and so is equivalent to \item |\makefirstuc{{ä}bc}| produces \makefirstuc{{ä}bc}. \end{itemize} + Note that non-Latin or accented characters appearing at the -start of the text must be placed in a group (even if you are +start of the text should be placed in a group (even if you are using the \sty{inputenc} package). The reason for this restriction is detailed in \sectionref{sec:utf8}. +\textbf{New to version 2.04:} There is now limited support for +UTF-8 characters with the \sty{inputenc} package, provided that +you load \sty{datatool-base} (at least v2.24) before +\styfmt{mfirstuc} (\sty{datatool-base} is loaded automatically with newer versions +of \sty{glossaries}). If available +\sty{mfirstuc} will now use \sty{datatool-base}'s +\ics{dtl@getfirst@UTFviii} command which is still experimental. +See the \styfmt{datatool} manual for further details. + +\begin{verbatim} +\documentclass{article} + +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} + +\usepackage{datatool-base}[2016/01/12]% v2.24+ +\usepackage{mfirstuc} + +\begin{document} +\makefirstuc{élite} +\end{document} +\end{verbatim} +(Package ordering is important.) + \begin{important} In version 1.02 of \styfmt{mfirstuc}, a bug fix resulted in a change in output if the first object is a control sequence followed by @@ -239,7 +264,7 @@ For example: Remember to also load \sty{textcase} (\styfmt{glossaries} loads this automatically). -\section{Capitalise the First Letter of Each Word in a Phrase or Sentence (Title Case)} +\chapter{Capitalise the First Letter of Each Word in a Phrase or Sentence (Title Case)} \label{sec:capitalisewords} New to mfirstuc v1.06: @@ -326,6 +351,17 @@ or contain formatted sub-phrases \end{alltt} Avoid scoped declarations. +\begin{important} +\cs{capitalisefmtwords} is only designed for phrases that contain +text-block commands with a single +argument, which should be a word or sub-phrase. Anything +more complicated is likely to break. Instead, use the +starred form or \cs{capitalisewords}. +\end{important} + +The starred form only permits a text-block command at the +start of the phrase. + Examples: \begin{enumerate} \item Phrase entirely enclosed in a formatting command: @@ -366,8 +402,60 @@ produces: \MFUnocap{of} \capitalisefmtwords{\textbf{a \emph{small book}} of rhyme} \end{display} + +\item Starred form: +\begin{verbatim} +\MFUnocap{of} +\capitalisefmtwords*{\emph{a small book of rhyme}} +\end{verbatim} +produces: +\begin{display} +\MFUnocap{of} +\capitalisefmtwords*{\emph{a small book of rhyme}} +\end{display} + +\item The starred form also works with just text (no text-block +command): +\begin{verbatim} +\MFUnocap{of} +\capitalisefmtwords*{a small book of rhyme} +\end{verbatim} +produces: +\begin{display} +\MFUnocap{of} +\capitalisefmtwords*{a small book of rhyme} +\end{display} + \end{enumerate} +If there is a text-block command within the argument of the +starred form, it's assumed to be at the start of the argument. +Unexpected results can occur if there are other commands. +For example +\begin{verbatim} +\MFUnocap{of} +\capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}} +\end{verbatim} +produces: +\begin{display} +\MFUnocap{of} +\capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}} +\end{display} +(In this case \verb|\textbf{of rhyme}| is considered a +single word.) Similarly if the text-block command occurs +in the middle of the argument: +\begin{verbatim} +\MFUnocap{of} +\capitalisefmtwords*{a \emph{very small} book of rhyme} +\end{verbatim} +produces: +\begin{display} +\MFUnocap{of} +\capitalisefmtwords*{a \emph{very small} book of rhyme} +\end{display} +(In this case \verb|\emph{very small}| is considered a +single word.) + Grouping causes interference: \begin{verbatim} \capitalisefmtwords{{a \emph{small book}} of rhyme} @@ -386,6 +474,29 @@ produces: \capitalisefmtwords{{\bfseries a \emph{small book}} of rhyme} \end{display} +Avoid complicated commands in the unstarred version. For example, +the following breaks: +\begin{verbatim} +\newcommand*{\swap}[2]{{#2}{#1}} +\capitalisefmtwords{a \swap{bo}{ok} of rhyme} +\end{verbatim} +However it works okay with the starred form and the simpler +\cs{capitalisewords}: +\begin{verbatim} +\newcommand*{\swap}[2]{{#2}{#1}} +\capitalisefmtwords*{a \swap{bo}{ok} of rhyme} + +\capitalisewords{a \swap{bo}{ok} of rhyme} +\end{verbatim} +Produces: +\begin{display} +\newcommand*{\swap}[2]{{#2}{#1}} +\capitalisefmtwords*{a \swap{bo}{ok} of rhyme} + +\capitalisewords{a \swap{bo}{ok} of rhyme} +\end{display} +Note that the case change is applied to the first argument. + \begin{definition}[\DescribeMacro{\xcapitalisewords}] \cs{xcapitalisewords}\marg{text} \end{definition} @@ -399,12 +510,14 @@ entire argument before applying \cs{capitalisewords}: \end{definition} There are also similar shortcut commands for the version that allows -formatting commands: +text-block commands: \begin{definition}[\DescribeMacro{\xcapitalisefmtwords}] \cs{xcapitalisefmtwords}\marg{text} \end{definition} -This is a short cut for +The unstarred version is a short cut for \cs{expandafter}\cs{capitalisefmtwords}\cs{expandafter}\marg{text}. +Similarly the starred version of \cs{xcapitalisefmtwords} +uses the starred version of \cs{capitalisefmtwords}. For full expansion: \begin{definition}[\DescribeMacro\ecapitalisefmtwords] @@ -413,7 +526,8 @@ For full expansion: 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. +where possible. Again this has a starred version that uses +the starred form of \cs{capitalisefmtwords}. Examples: \begin{verbatim} @@ -478,10 +592,31 @@ However \end{verbatim} produces: \ecapitalisewords{\mytitle} +(\cs{space} has been expanded to an actual space character.) + +\item +\begin{verbatim} +\newcommand*{\swap}[2]{{#2}{#1}} +\capitalisewords{a \swap{bo}{ok} of rhyme} +\ecapitalisewords{a \swap{bo}{ok} of rhyme} +\end{verbatim} +produces: +\begin{display} +\newcommand*{\swap}[2]{{#2}{#1}} +\capitalisewords{a \swap{bo}{ok} of rhyme} + +\ecapitalisewords{a \swap{bo}{ok} of rhyme} +\end{display} +This is because the argument of \cs{ecapitalisewords} is +fully expanded before being passed to \cs{capitalisewords} so +that last example is equivalent to: +\begin{verbatim} +\capitalisewords{a {ok}{bo} of rhyme} +\end{verbatim} \end{enumerate} -\subsection{PDF Bookmarks} +\section{PDF Bookmarks} \label{sec:pdfbookmarks} \begin{important} @@ -515,7 +650,7 @@ disabling commands within the bookmarks. For example: See the \sty{hyperref} manual for further details. -\subsection{Excluding Words From Case-Changing} +\section{Excluding Words From Case-Changing} \label{sec:nocap} As from v1.09, you can specify words which shouldn't be capitalised unless they @@ -572,7 +707,8 @@ produces \begin{display} \capitalisewords{this is section {}\nameref{sec:nocap}.} \end{display} -(No case-changing is applied to \verb|\nameref{sec:nocap}|.) +(No case-changing is applied to \verb|\nameref{sec:nocap}|. +It just happens to already be in title case.) The package \sty{mfirstuc-english} loads \styfmt{mfirstuc} and uses \cs{MFUnocap} to add common English articles and conjunctions, such @@ -615,7 +751,7 @@ 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} +\chapter{UTF-8} \label{sec:utf8} The \cs{makefirstuc} command works by utilizing the fact that, in @@ -731,5 +867,12 @@ 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}. +Version 2.24 of \sty{datatool-base} added the +command \cs{dtl@getfirst@UTFviii} which attempts to grab both octets. If this command +has been defined, \sty{mfirstuc} will use it when it tries to split +the first character from the rest of the word. See the +\href{http://mirrors.ctan.org/macros/latex/contrib/datatool/datatool-code.pdf}{\styfmt{datatool} +documented code} for further details. + \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 0468a09a98b..e39ab58cc34 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 eb1104be59a..718515cb8f6 100644 --- a/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex +++ b/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex @@ -1,14 +1,21 @@ % This file is public domain % If you want to use arara, you need the following directive: % arara: pdflatex: { synctex: on } + % arara: pdflatex: { synctex: on } \documentclass{article} \usepackage[a4paper]{geometry} \usepackage{color} \usepackage{mfirstuc-english}% also loads mfirstuc.sty +\usepackage[hidelinks]{hyperref} + +\title{Sample Document Illustrating the mfirstuc Package} +\author{Nicola Talbot} \begin{document} -This is a sample document illustrating the mfirstuc package. +\maketitle + +\tableofcontents \section{First Letter Upper Case} @@ -37,23 +44,77 @@ Protected formatting: \xmakefirstuc{\mytext}. \renewcommand*{\mytext}{\ae\oe{some text}} Sequential commands: \xmakefirstuc{\mytext}. -\section{Title Case (Formatting)} +\section{Title Case (No Formatting Commands)} + +\bgroup + +\verb|\capitalisewords{the wind in the willows}| +\capitalisewords{the wind in the willows} + +\verb|\capitalisewords{a small book of rhyme.}| +\capitalisewords{a small book of rhyme.} + +\medskip + +\verb|\space| isn't considered a word boundary for +\verb|\capitalisewords| as shown below: + +\begin{verbatim} +\capitalisewords{a small\space book of rhyme.} +\end{verbatim} +\capitalisewords{a small\space book of rhyme.} + +\medskip +No expansion is performed on the argument of +\verb|\capitalisewords|: + +\verb|\newcommand{\mytitle}{a small book of rhyme.}| +\newcommand{\mytitle}{a small book of rhyme.} + +\verb|\capitalisewords{\mytitle}| +\capitalisewords{\mytitle} + +\verb|\xcapitalisewords{\mytitle}| +\xcapitalisewords{\mytitle} + +\egroup Formatting for the entire phrase must go outside \verb|\capitalisewords| (unlike \verb|\makefirstuc|). Compare: -\verb|\capitalisewords{\textbf{a small book of rhyme.}}| +\begin{verbatim} +\capitalisewords{\textbf{a small book of rhyme.}} +\end{verbatim} \capitalisewords{\textbf{a small book of rhyme.}} -with: - -\verb|\textbf{\capitalisewords{a small book of rhyme.}}| +\begin{verbatim} +\textbf{\capitalisewords{a small book of rhyme.}} +\end{verbatim} \textbf{\capitalisewords{a small book of rhyme.}} \medskip -Use \verb|\capitalisefmtwords| instead (full stop outside -argument to check for spurious spaces): +Use \verb|\capitalisefmtwords| instead. The starred form +is limited to one text-block command at the start of the argument. + +\begin{verbatim} +\capitalisefmtwords*{\emph{a small book of rhyme}} +\end{verbatim} +\capitalisefmtwords*{\emph{a small book of rhyme}} + +Additional text-block commands can cause unexpected results. + +\begin{verbatim} +\capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}} +\end{verbatim} +\capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}} + +\section{Title Case (Contains Text-Block Formatting Commands)} + +The unstarred form of \verb|\capitalisefmtwords| is still a bit +experimental and is only designed +for phrases that contain text-block commands with a single +argument, which should be a word or sub-phrase. \verb|\capitalisefmtwords{\textbf{a small book of rhyme}}.| \capitalisefmtwords{\textbf{a small book of rhyme}}. @@ -64,17 +125,28 @@ argument to check for spurious spaces): \verb|\capitalisefmtwords{a \textbf{small book} of rhyme}.| \capitalisefmtwords{a \textbf{small book} of rhyme}. -\verb|\capitalisefmtwords{\textbf{a} book of rhyme}.| +\verb|\capitalisefmtwords{\textbf{a} small 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 +Be careful of trailing spaces at the end a group. They can confuse +things. + +\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{\textbf{a small book of }rhyme}.| +\capitalisefmtwords{\textbf{a small book of }rhyme}. + +\medskip + Use semantic commands for things like quotations: \begin{verbatim} @@ -88,6 +160,25 @@ Use semantic commands for things like quotations: (But make them robust if you intend using commands like \verb|\ecapitalisefmtwords|.) +Similarly for other types of punctuation: +\begin{verbatim} +\newcommand*{\esq}[1]{'?#1?} +\capitalisefmtwords{\esq{D\'onde est\'a libro}} +\end{verbatim} +\newcommand*{\esq}[1]{?`#1?} +\capitalisefmtwords{\esq{D\'onde est\'a libro}} + +\medskip + +Anything more complicated than a simple one-argument text-block +command requires the starred version. + +\begin{verbatim} +\newcommand*{\swap}[2]{{#2}{#1}} +\capitalisefmtwords*{\textbf{an \swap{un}{usually} small book of} rhyme}. +\end{verbatim} +\newcommand*{\swap}[2]{{#2}{#1}} +\capitalisefmtwords*{\textbf{an \swap{un}{usually} small book of} rhyme}. \medskip @@ -168,38 +259,27 @@ As illustrated next: \verb|\capitalisefmtwords{\relax a book of rhyme.}| \capitalisefmtwords{\relax a book of rhyme.} -\section{Title Case (No Formatting)} - -\bgroup +\section{Compound Words} -\verb|\capitalisewords{the wind in the willows}| -\capitalisewords{the wind in the willows} - -\verb|\capitalisewords{a small book of rhyme.}| -\capitalisewords{a small book of rhyme.} - -\medskip - -\verb|\space| isn't considered a word boundary for -\verb|\capitalisewords| as shown below: +Use \verb|\MFUhyphentrue| to title case each part of +a compound word. +Default: \begin{verbatim} -\capitalisewords{a small\space book of rhyme.} +\capitalisewords{a fast-paced book of rhyme}. +\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. \end{verbatim} -\capitalisewords{a small\space book of rhyme.} +\capitalisewords{a fast-paced book of rhyme}. +\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. -\medskip -No expansion is performed on the argument of -\verb|\capitalisewords|: - -\verb|\newcommand{\mytitle}{a small\space book of rhyme.}| -\newcommand{\mytitle}{a small\space book of rhyme.} - -\verb|\capitalisewords{\mytitle}| -\capitalisewords{\mytitle} - -\verb|\xcapitalisewords{\mytitle}| -\xcapitalisewords{\mytitle} +Compare with +\begin{verbatim} +\MFUhyphentrue +\capitalisewords{a fast-paced book of rhyme}. +\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. +\end{verbatim} +\MFUhyphentrue +\capitalisewords{a fast-paced book of rhyme}. +\capitalisefmtwords{a \textbf{fast-paced} book of rhyme}. -\egroup \end{document} -- cgit v1.2.3