From 33a4150d1da52eedaebb96c4693913b8b024c8de Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 10 Sep 2015 20:59:49 +0000 Subject: mfirstuc (9sep15) git-svn-id: svn://tug.org/texlive/trunk@38343 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/mfirstuc/CHANGES | 60 ++ Master/texmf-dist/doc/latex/mfirstuc/README | 41 + .../doc/latex/mfirstuc/mfirstuc-code.pdf | Bin 0 -> 220571 bytes .../doc/latex/mfirstuc/mfirstuc-manual.html | 944 +++++++++++++++++++++ .../doc/latex/mfirstuc/mfirstuc-manual.pdf | Bin 0 -> 223024 bytes .../doc/latex/mfirstuc/mfirstuc-manual.tex | 475 +++++++++++ .../doc/latex/mfirstuc/sample-mfirstuc.pdf | Bin 0 -> 25848 bytes .../doc/latex/mfirstuc/sample-mfirstuc.tex | 40 + Master/texmf-dist/scripts/mfirstuc/mfirstuc.perl | 129 +++ .../texmf-dist/source/latex/mfirstuc/mfirstuc.dtx | 601 +++++++++++++ .../texmf-dist/source/latex/mfirstuc/mfirstuc.ins | 35 + .../tex/latex/mfirstuc/mfirstuc-english.sty | 61 ++ Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty | 149 ++++ 13 files changed, 2535 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/CHANGES create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/README create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-code.pdf create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.pdf create mode 100644 Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex create mode 100644 Master/texmf-dist/scripts/mfirstuc/mfirstuc.perl create mode 100644 Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx create mode 100644 Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins create mode 100644 Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty create mode 100644 Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/mfirstuc/CHANGES b/Master/texmf-dist/doc/latex/mfirstuc/CHANGES new file mode 100644 index 00000000000..277d9033b7d --- /dev/null +++ b/Master/texmf-dist/doc/latex/mfirstuc/CHANGES @@ -0,0 +1,60 @@ +mfirstuc change log: + +v1.11 + + * Split from glossaries bundle. + + * Fixed bug the occurred when the first two tokens of + \makefirstuc are both control sequences. + +v1.10: + + * added \ecapitalisewords, \emakefirstuc + +v1.09: + + * Added \MFUnocap + + * New package: mfirstuc-english.sty + +v1.08: + + * Made \makefirstuc and \capitalisewords robust + +v1.07: + + * Added \mfirstucMakeUppercase to allow the user to switch from + \MakeUppercase to another case changing command. + +v1.06: + + * added \capitalisewords, \xcapitalisewords + +v1.05: + + * added \glsmakefirstuc (replaces \@gls@makefirstuc) to make + it easier to customise. + +v1.04: + + * fixed bug occurring when initial control sequence + in the argument of \makefirstuc has more than one + argument. + +v1.02: + + * Fixed bug that transfered grouping, (e.g + \makefirstuc{\emph{abc}xyz} moved the xyz into the \emph) + + * If group following initial command is empty, \MakeUppercase + is applied to the command, e.g. \makefirstuc{\ae{}bc} now + produces \MakeUppercase\ae{}bc. + +v1.01: + + * Added \xmakefirstuc (expands argument before applying \makefirstuc) + +v1.0: + + * Initial version + diff --git a/Master/texmf-dist/doc/latex/mfirstuc/README b/Master/texmf-dist/doc/latex/mfirstuc/README new file mode 100644 index 00000000000..eee6e3d6343 --- /dev/null +++ b/Master/texmf-dist/doc/latex/mfirstuc/README @@ -0,0 +1,41 @@ +LaTeX Package : mfirstuc v2.0 + +Last Modified : 2015-09-09 + +Author : Nicola Talbot + +This package provides \makefirstuc{} which makes the first object of + upper case unless 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. Examples: + + \makefirstuc{abc} -> Abc + \makefirstuc{\emph{abc}} -> \emph{Abc} + \makefirstuc{{\'a}bc} -> \'Abc + \makefirstuc{\ae bc} -> \AE bc + \makefirstuc{{\ae}bc} -> \AE bc + \makefirstuc{\ae{}bc} -> \AE{}bc + +The package also provides \capitalisewords{} which applies +\makefirstuc to each word in the , where the words are +separated by regular spaces. (Exceptions can be made for words that +shouldn't be converted.) + +The mfirstuc package was originally bundled with the glossaries +package. + +LaTeX2HTML + +This package comes with a LaTeX2HTML style file mfirstuc.perl which +should be placed in the relevant LaTeX2HTML styles directory, but +note that some commands may not be implemented or may be implemented +in a different way. + +LICENCE + +This material is subject to the LaTeX Project Public License. +See http://www.ctan.org/license/lppl1.3 +for the details of that license. + +Author's home page: http://www.dickimaw-books.com/ + diff --git a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-code.pdf b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-code.pdf new file mode 100644 index 00000000000..3bf567fe659 Binary files /dev/null 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 new file mode 100644 index 00000000000..8d30a8f8844 --- /dev/null +++ b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.html @@ -0,0 +1,944 @@ + + + + +mfirstuc.sty v2.0: uppercasing first letter + + + + + + + + + +
+ + + + + + + +

mfirstuc.sty v2.0: uppercasing first letter

+
Nicola L.C. Talbot +
Dickimaw Books +
http://www.dickimaw-books.com/

+
2015-09-09
+
+

Contents

+ +

+

+

Top

1 Introduction

+

The mfirstuc package was originally part of the 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. +

+

+

Top

2 Capitalising 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 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 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 \color{red} and use \red{text}.
+

+

Examples:

+
    +
  • \makefirstuc{abc} produces Abc. +
  • +
  • \makefirstuc{\emph{abc}} produces Abc (\MakeUppercase has been applied to + the letter “a” rather than \emph). Note however that + + + +
    + \makefirstuc{{\em abc}} +
    +

    produces ABC (first object is {\em abc} so this is equivalent to + \MakeUppercase{\em abc}), and + + + +

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

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

  • +
  • \makefirstuc{{\’a}bc} produces Ábc. +
  • +
  • \makefirstuc{\ae bc} produces Æbc. +
  • +
  • \makefirstuc{{\ae}bc} produces Æbc. +
  • +
  • \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 inputenc 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 + + + +

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

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


\xmakefirstuc  \xmakefirstuc{stuff}

+

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

+
+\newcommand{\abc}{abc} + 
\xmakefirstuc{\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 \makefirstuc: +


\emakefirstuc  \emakefirstuc{text}

+

+

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 mfirstuc without the glossaries package, the standard \MakeUppercase +command is used. If used with glossaries, \MakeTextUppercase (defined by the textcase +package) is used instead. If you are using mfirstuc without the 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 textcase (glossaries loads this automatically). +

+

+

Top

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

+

New to mfirstuc v1.06: +


\capitalisewords  \capitalisewords{text}

+

+This command apply \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 ~ or \space. Note that no expansion is performed on +⟨text⟩. +


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


\ecapitalisewords  \ecapitalisewords{text}

+

+

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

    +
  1. + + + +
    + \capitalisewords{a book of rhyme.} +
    +

    produces: A Book Of Rhyme. +

  2. +
  3. + + + +
    + \capitalisewords{a book\space of rhyme.} +
    +

    produces: A Book of Rhyme. +

  4. +
  5. + + + +
    + \newcommand{\mytitle}{a book\space of rhyme.} +  
    \capitalisewords{\mytitle} +
    +

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

  6. +
  7. + + + +
    + \newcommand{\mytitle}{a book\space of rhyme.} +  
    \xcapitalisewords{\mytitle} +
    +

    produces: A Book of Rhyme. +

    However + + + +

    +
    + \ecapitalisewords{\mytitle} +
    +

    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 ⟨text⟩ using: +


\MFUnocap  \MFUnocap{word}

+

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


\gMFUnocap  \gMFUnocap{word}

+

+

For example: + + + +

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

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 mfirstuc-english 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 +package. +

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

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

Next load mfirstuc: + + + +

+
+\RequirePackage{mfirstuc} +
+

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

+
+\MFUnocap{de} +
+

At the end of the file add: + + + +

+
+\endinput +
+

+

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 \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 \makefirstuc command is: + + + +

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

Here + + + +

+
+\FirstUC{abc} +
+

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

+
+\MakeUppercase stuff⟩ +
+
works, then
+
+\makefirstuc{stuff} +
+
should also work and so should
+
+\makefirstuc{\foo{stuff}} +
+
but if
+
+\MakeUppercase stuff⟩ +
+
doesn’t work, then neither will
+
+\makefirstuc{stuff} + + + +
+
nor
+
+\makefirstuc{\foo{stuff}} +
+
+

Try the following document:

+
+\documentclass{article} +
+
\usepackage[utf8]{inputenc} +
\usepackage[T1]{fontenc} +
+
\begin{document} +
+
\MakeUppercase ãbc +
+
\end{document} +
+
+

This will result in the error: + + + +

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

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 two tokens. So

+
+\MakeUppercase ã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:
+
+\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: +

+
+\documentclass{article} +
+
\usepackage{fontspec} +
+
\begin{document} +
+
\MakeUppercase ãbc +
+
\end{document} +
+
+ + + +

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

+ + + + + + diff --git a/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.pdf new file mode 100644 index 00000000000..b6413ad4185 Binary files /dev/null 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 new file mode 100644 index 00000000000..60d25f80a0f --- /dev/null +++ b/Master/texmf-dist/doc/latex/mfirstuc/mfirstuc-manual.tex @@ -0,0 +1,475 @@ +\documentclass{nlctdoc} + +\usepackage{alltt} +\usepackage{mfirstuc} +\usepackage{pifont} +\usepackage[utf8]{inputenc} +\ifpdf + \usepackage[T1]{fontenc} + \usepackage{metalogo} +\else + \providecommand{\XeLaTeX}{XeLaTeX} + \providecommand{\XeTeX}{XeTeX} +\fi +\usepackage{cmap} +\usepackage[colorlinks, + bookmarks, + hyperindex=false, + pdfauthor={Nicola L.C. Talbot}, + pdftitle={mfirstuc.sty: uppercasing first letter}, + pdfkeywords={LaTeX,package,uppercase}]{hyperref} + +\begin{document} + \title{mfirstuc.sty v2.0: +uppercasing first letter} + \author{Nicola L.C. Talbot\\[10pt] +Dickimaw Books\\ +\url{http://www.dickimaw-books.com/}} + + \date{2015-09-09} + \maketitle + \tableofcontents + + \section{Introduction} + \label{sec:intro} + +The \styfmt{mfirstuc} package was originally part of the +\styfmt{glossaries} bundle for use with commands like \cs{Gls}, but +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} +\label{sec:makefirstuc} + +A simple word can be capitalised just using the standard \LaTeX\ +upper casing command. For example, +\begin{verbatim} +\MakeUppercase word +\end{verbatim} +but for commands like \cs{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 \styfmt{mfirstuc} package provides: +\begin{definition}[\DescribeMacro{\makefirstuc}] +\cs{makefirstuc}\marg{stuff} +\end{definition} +This makes the first object of +\meta{stuff} upper case unless \meta{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. +\textbf{No expansion is performed on the argument.} + +\begin{important} +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}| +you need to define, say, \verb|\red| as \verb|\color{red}| and use +\verb|\red{text}|. +\end{important} + +Examples: +\begin{itemize} +\item |\makefirstuc{abc}| produces \makefirstuc{abc}. + +\item |\makefirstuc{\emph{abc}}| produces \makefirstuc{\emph{abc}} +(\ics{MakeUppercase} has been applied to the letter \qt{a} rather +than \cs{emph}). Note however that +\begin{verbatim} +\makefirstuc{{\em abc}} +\end{verbatim} +produces \makefirstuc{{\em abc}} (first object is |{\em abc}| so +this is equivalent to |\MakeUppercase{\em abc}|), and +\begin{verbatim} +{\makefirstuc{\em abc}} +\end{verbatim} +produces {\makefirstuc{\em abc}} (|\em| doesn't have an argument +therefore first object is |\em| and so is equivalent to +|{\MakeUppercase{\em}abc}|). + +\item |\makefirstuc{{\'a}bc}| produces \makefirstuc{{\'a}bc}. + +\item |\makefirstuc{\ae bc}| produces \makefirstuc{\ae bc}. + +\item |\makefirstuc{{\ae}bc}| produces \makefirstuc{{\ae}bc}. + +\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 +using the \sty{inputenc} package). The reason for this restriction +is detailed in \sectionref{sec:utf8}. + +\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 +an empty group. Prior to version 1.02, |\makefirstuc{\ae{}bc}| +produced \ae Bc. However as from version 1.02, it now produces +\AE bc. +\end{important} + +Note also that +\begin{verbatim} +\newcommand{\abc}{abc} +\makefirstuc{\abc} +\end{verbatim} +produces: ABC. This is because the first object in the argument of +\cs{makefirstuc} is \cs{abc}, so it does |\MakeUppercase{\abc}|. +Whereas: +\begin{verbatim} +\newcommand{\abc}{abc} +\expandafter\makefirstuc\expandafter{\abc} +\end{verbatim} +produces: Abc. There is a short cut command which will do this: +\begin{definition}[\DescribeMacro{\xmakefirstuc}] +\cs{xmakefirstuc}\marg{stuff} +\end{definition} +This is equivalent to \cs{expandafter}\cs{makefirstuc}\cs{expandafter}\marg{stuff}. So +\begin{verbatim} +\newcommand{\abc}{abc} +\xmakefirstuc{\abc} +\end{verbatim} +produces: +\newcommand{\abc}{abc}% +\xmakefirstuc{\abc}. + +\begin{important} +\cs{xmakefirstuc} only performs one level expansion on the +\emph{first} object in its argument. It does not fully expand the entire +argument. +\end{important} + +As from version 1.10, there is now a command that fully expands the +entire argument before applying \cs{makefirstuc}: +\begin{definition}[\DescribeMacro\emakefirstuc] +\cs{emakefirstuc}\marg{text} +\end{definition} + +Examples: +\begin{verbatim} +\newcommand{\abc}{\xyz a} +\newcommand{\xyz}{xyz} +No expansion: \makefirstuc{\abc}. +First object one-level expansion: \xmakefirstuc{\abc}. +Fully expanded: \emakefirstuc{\abc}. +\end{verbatim} +produces: +\renewcommand{\abc}{\xyz a}% +\newcommand{\xyz}{xyz} +No expansion: \makefirstuc{\abc}. +First object one-level expansion: \xmakefirstuc{\abc}. +Fully expanded: \emakefirstuc{\abc}. + +If you use \styfmt{mfirstuc} without the \sty{glossaries} package, +the standard \cs{MakeUppercase} command is used. If used with +\sty{glossaries}, \ics{MakeTextUppercase} (defined by the \sty{textcase} +package) is used instead. If you are using \styfmt{mfirstuc} +without the \styfmt{glossaries} package and want to use +\ics{MakeTextUppercase} instead, you can redefine +\begin{definition}[\DescribeMacro\glsmakefirstuc] +\cs{glsmakefirstuc}\marg{text} +\end{definition} +For example: +\begin{verbatim} +\renewcommand{\glsmakefirstuc}[1]{\MakeTextUppercase #1} +\end{verbatim} +Remember to also load \sty{textcase} (\styfmt{glossaries} loads this +automatically). + +\section{Capitalise Each Word in a Phrase or Sentence (Title Case)} +\label{sec:capitalisewords} + +New to mfirstuc v1.06: +\begin{definition}[\DescribeMacro{\capitalisewords}] +\cs{capitalisewords}\marg{text} +\end{definition} +This command apply \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}. + +\begin{definition}[\DescribeMacro{\xcapitalisewords}] +\cs{xcapitalisewords}\marg{text} +\end{definition} +This is a short cut for +\cs{expandafter}\cs{capitalisewords}\cs{expandafter}\marg{text}. + +As from version 1.10, there is now a command that fully expands the +entire argument before applying \cs{capitalisewords}: +\begin{definition}[\DescribeMacro\ecapitalisewords] +\cs{ecapitalisewords}\marg{text} +\end{definition} + +Examples: +\begin{verbatim} +\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}. +\end{verbatim} +produces: +\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}. + +(Remember that the spaces need to be explicit. In the second case +above, using \cs{xcapitalisewords}, the space before \qt{four} has +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 +\begin{verbatim} +\capitalisewords{a book of rhyme.} +\end{verbatim} +produces: +\capitalisewords{a book of rhyme.} + +\item +\begin{verbatim} +\capitalisewords{a book\space of rhyme.} +\end{verbatim} +produces: +\capitalisewords{a book\space of rhyme.} + +\item +\begin{verbatim} +\newcommand{\mytitle}{a book\space of rhyme.} +\capitalisewords{\mytitle} +\end{verbatim} +produces: +\newcommand{\mytitle}{a book\space of rhyme.} +\capitalisewords{\mytitle} +(No expansion is performed on \cs{mytitle}.) Compare with next example: + +\item +\begin{verbatim} +\newcommand{\mytitle}{a book\space of rhyme.} +\xcapitalisewords{\mytitle} +\end{verbatim} +produces: +\xcapitalisewords{\mytitle} + +However +\begin{verbatim} +\ecapitalisewords{\mytitle} +\end{verbatim} +produces: +\ecapitalisewords{\mytitle} + +\end{enumerate} + +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] +\cs{MFUnocap}\marg{word} +\end{definition} +This only has a local effect. The global version is: +\begin{definition}[\DescribeMacro\gMFUnocap] +\cs{gMFUnocap}\marg{word} +\end{definition} + +For example: +\begin{verbatim} +\capitalisewords{the wind in the willows} + +\MFUnocap{in}% +\MFUnocap{the}% + +\capitalisewords{the wind in the willows} +\end{verbatim} +produces: +\begin{display} +\capitalisewords{the wind in the willows} + +\MFUnocap{in}% +\MFUnocap{the}% + +\capitalisewords{the wind in the willows} +\end{display} +The list of words that shouldn't be capitalised can be cleared using +\begin{definition}[\DescribeMacro\MFUclear] +\cs{MFUclear} +\end{definition} + +The package \sty{mfirstuc-english} loads \sty{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 +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 \texttt{.sty} +that starts with +\begin{verbatim} +\NeedsTeXFormat{LaTeX2e} +\end{verbatim} +The next line should identify the package. For example, if you have +called the file \texttt{mfirstuc-french.sty} then you need: +\begin{verbatim} +\ProvidesPackage{mfirstuc-french} +\end{verbatim} +It's a good idea to also add a version in the final optional +argument, for example: +\begin{verbatim} +\ProvidesPackage{mfirstuc-french}[2014/07/30 v1.0] +\end{verbatim} +Next load \sty{mfirstuc}: +\begin{verbatim} +\RequirePackage{mfirstuc} +\end{verbatim} +Now add all your \cs{MFUnocap} commands. For example: +\begin{verbatim} +\MFUnocap{de} +\end{verbatim} +At the end of the file add: +\begin{verbatim} +\endinput +\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. + +\section{UTF-8} +\label{sec:utf8} + +The \cs{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, \verb|\frac12| instead of \verb|\frac{1}{2}| or +\verb|x^2| instead of \verb|x^{2}|, although some users +frown on this practice.) + +A~simplistic version of the \cs{makefirstuc} command is: +\begin{verbatim} +\newcommand*{\FirstUC}[1]{\MakeUppercase #1} +\end{verbatim} +Here +\begin{verbatim} +\FirstUC{abc} +\end{verbatim} +is equivalent to +\begin{verbatim} +\MakeUppercase abc +\end{verbatim} +and since \cs{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 \sty{glossaries} package needs to take into account the fact +that the text may be contained in the argument of a formatting +command, such as \cs{acronymfont}, so \cs{makefirstuc} has to be +more complicated than the trivial \cs{FirstUC} shown above, but at +its basic level, \cs{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 +\begin{alltt} +\cs{MakeUppercase} \meta{stuff} +\end{alltt} +works, +then +\begin{alltt} +\cs{makefirstuc}\marg{stuff} +\end{alltt} +should also work and so should +\begin{alltt} +\cs{makefirstuc}\{\cs{foo}\marg{stuff}\} +\end{alltt} +but if +\begin{alltt} +\cs{MakeUppercase} \meta{stuff} +\end{alltt} +doesn't work, then neither will +\begin{alltt} +\cs{makefirstuc}\marg{stuff} +\end{alltt} +nor +\begin{alltt} +\cs{makefirstuc}\{\cs{foo}\marg{stuff}\} +\end{alltt} + +Try the following document: +\begin{alltt} +\cs{documentclass}\{article\} + +\cs{usepackage}[utf8]\{inputenc\} +\cs{usepackage}[T1]\{fontenc\} + +\cs{begin}\{document\} + +\cs{MakeUppercase} \~abc + +\cs{end}\{document\} +\end{alltt} + +This will result in the error: +\begin{verbatim} +! Argument of \UTFviii@two@octets has an extra }. +\end{verbatim} +This is why \verb|\makefirstuc{|\texttt{\~abc}\verb|}| won't work. +It will only work if the character \texttt{\~a} is placed inside a +group. + +The reason for this error message is due to \TeX\ having been written before +Unicode was invented. Although \texttt{\~a} may look like a single +character in your text editor, from \TeX's point of view it's \emph{two} +tokens. So +\begin{alltt} +\cs{MakeUppercase} \~abc +\end{alltt} +tries to apply \cs{MakeUppercase} to just the first octet of \~a. +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 \~a) +must be grouped: +\begin{alltt} +\cs{MakeUppercase}\{\~a\}bc +\end{alltt} + +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: +\begin{alltt} +\cs{documentclass}\{article\} + +\cs{usepackage}\{fontspec\} + +\cs{begin}\{document\} + +\cs{MakeUppercase} \~abc + +\cs{end}\{document\} +\end{alltt} + +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}. + +\end{document} diff --git a/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.pdf b/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.pdf new file mode 100644 index 00000000000..cd01cfbecd4 Binary files /dev/null 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 new file mode 100644 index 00000000000..0cdae525b58 --- /dev/null +++ b/Master/texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex @@ -0,0 +1,40 @@ + % This file is public domain + % If you want to use arara, you need the following directive: + % arara: pdflatex: { synctex: on } +\documentclass{article} + +\usepackage{mfirstuc-english} + +\begin{document} + +\makefirstuc{abc}. + +\makefirstuc{{\em abc}}. + +\makefirstuc{\emph{abc}}. + +\makefirstuc{\ae bc}. + +\makefirstuc{{\ae}bc}. + +\newcommand{\abc}{abc}% +\xmakefirstuc{\abc}. + +\capitalisewords{the wind in the willows} + +\capitalisewords{a book of rhyme.} + +\MFUclear + +\capitalisewords{the wind in the willows} + +\capitalisewords{a book of rhyme.} + +\capitalisewords{a book\space of rhyme.} + +\newcommand{\mytitle}{a book\space of rhyme.} +\capitalisewords{\mytitle} + +\xcapitalisewords{\mytitle} + +\end{document} diff --git a/Master/texmf-dist/scripts/mfirstuc/mfirstuc.perl b/Master/texmf-dist/scripts/mfirstuc/mfirstuc.perl new file mode 100644 index 00000000000..7ab863d06f4 --- /dev/null +++ b/Master/texmf-dist/scripts/mfirstuc/mfirstuc.perl @@ -0,0 +1,129 @@ +# File : mfirstuc.perl +# Author : Nicola L. C. Talbot +# Date : 2012-09-21 +# Version : 1.0 +# Description : LaTeX2HTML (limited!) implementation of mfirstuc package + +# This is a LaTeX2HTML style implementing the mfirstuc package, and +# is distributed as part of the glossaries package. +# Copyright 2007 Nicola L.C. Talbot +# This work may be distributed and/or modified under the +# conditions of the LaTeX Project Public License, either version 1.3 +# of this license of (at your option) any later version. +# The latest version of this license is in +# http://www.latex-project.org/lppl.txt +# and version 1.3 or later is part of all distributions of LaTeX +# version 2005/12/01 or later. +# +# This work has the LPPL maintenance status `maintained'. +# +# The Current Maintainer of this work is Nicola Talbot. + +use warnings; + +package main; + +sub do_cmd_makefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &translate_commands("\\glsmakefirstuc $text") . $_; +} + +sub do_cmd_xmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + unless ($id) + { + $id = ++$global{'max_id'}; + } + + &translate_commands("\\expandafter \\makefirstuc $OP$id$CP$text$OP$id$CP") + . $_; +} + +sub do_cmd_glsmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &get_next_object unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &do_real_makefirstuc($text).$_; +} + +sub do_real_makefirstuc{ + local($text) = @_; + + if ($text=~/^((?:\s*<[^>]+>\s*)+)(.*)/) + { + $text = $1 . ucfirst($2); + } + else + { + $text = ucfirst($text); + } + + $text; +} + +sub do_cmd_capitalisewords{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + local($newtext) = ''; + + foreach my $word (split ' ', $text) + { + $id = ++$global{'max_id'}; + + $word = &translate_commands("\\makefirstuc $OP$id$CP$word$OP$id$CP"); + + if ($newtext) + { + $newtext .= ' ' . $word; + } + else + { + $newtext = $word; + } + } + + $newtext.$_; +} + +sub get_next_object{ + local($next, $revert, $thisline); + local($this_cmd) = $cmd; + $this_cmd =~ s/^\\// unless ($cmd eq "\\"); + if (/^[\s%]*([^\n]*)\n/ ) { + $thisline = &revert_to_raw_tex($1) + } else { + $thisline = &revert_to_raw_tex($_); + } + s/^\s*//; + if ($_ =~ s/$next_token_rx//) { $next = $& }; + $next =~ s/$comment_mark(\d+\n?)?//g; + if ($next =~ /^\\(\W|\d|[a-zA-z]*\b)/) { + $revert = $next = "\\".$1; + } elsif ($next =~ /\W/) { + $revert = &revert_to_raw_tex($next); + } else { $revert = $next }; + $next; +} + +1; diff --git a/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx new file mode 100644 index 00000000000..87bcf8aab48 --- /dev/null +++ b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx @@ -0,0 +1,601 @@ +%\iffalse +% mfirstuc.dtx generated using makedtx version 1.1 (c) Nicola Talbot +% Command line args: +% -comment ".*\.perl" +% -comment ".*\.tex" +% -author "Nicola Talbot" +% -src "mfirstuc.sty\Z=>mfirstuc.sty" +% -src "mfirstuc-english.sty\Z=>mfirstuc-english.sty" +% -src "(sample.*\.tex)\Z=>\1" +% -src "(.*\.perl)\Z=>\1" +% -setambles ".*\.perl=>\nopreamble\nopostamble" +% -setambles ".*\.tex=>\nopreamble\nopostamble" +% -doc "mfirstuc-codedoc.tex" +% -macrocode ".*\.perl" +% -macrocode ".*\.tex" +% -codetitle "Main Package Code" +% mfirstuc +% Created on 2015/9/9 15:55 +%\fi +%\iffalse +%<*package> +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +% +%\fi +% \iffalse +% Doc-Source file to use with LaTeX2e +% Copyright (C) 2015 Nicola Talbot, all rights reserved. +% \fi +% \iffalse +%<*driver> +\documentclass{nlctdoc} + +\iffalse +mfirstuc-codedoc.tex is a stub file used by makedtx to create +mfirstuc.dtx +\fi + +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[colorlinks, + bookmarks, + hyperindex=false, + pdfauthor={Nicola L.C. Talbot}, + pdftitle={mfirstuc.sty: Documented code}]{hyperref} + +\RecordChanges + +\renewcommand*{\main}[1]{\hyperpage{#1}} + +\setcounter{IndexColumns}{2} + +\CheckSum{243} + +\begin{document} +\DocInput{mfirstuc.dtx} +\end{document} +% +%\fi +%\MakeShortVerb{"} +%\DeleteShortVerb{\|} +% +% \title{Documented Code For mfirstuc v2.0} +% \author{Nicola L.C. Talbot\\[10pt] +%Dickimaw Books\\ +%\url{http://www.dickimaw-books.com/}} +% +% \date{2015-09-09} +% \maketitle +% +%\tableofcontents +% +%\section{Introduction} +% +%This is the documented code for the \styfmt{mfirstuc} package. +%See \texttt{mfirstuc-manual.pdf} for the main user guide. +% +% +%\StopEventually{% +% \phantomsection +% \addcontentsline{toc}{section}{Change History}% +% \raggedright +% \PrintChanges +% \PrintIndex +%} +% +% +% +%\section{Main Package Code} +%\iffalse +% \begin{macrocode} +%<*mfirstuc.sty> +% \end{macrocode} +%\fi +%\subsection{Mfirstuc Documented Code} +%\label{sec:code:mfirstuc} +%\changes{2.0}{2015/09/09}{package split from glossaries} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{mfirstuc}[2015/09/09 v2.0 (NLCT)] +% \end{macrocode} +% Requires \sty{etoolbox}:\changes{1.06}{2012/05/21}{now requires +% etoolbox} +% \begin{macrocode} +\RequirePackage{etoolbox} +% \end{macrocode} +%\begin{macro}{\makefirstuc} +% Syntax: +%\begin{definition} +% \cs{makefirstuc}\marg{text} +%\end{definition} +% Makes the first letter uppercase, but will +% skip initial control sequences if they are followed by a group +% and make the first thing in the group uppercase, unless the group +% is empty. +% Thus \verb|\makefirstuc{abc}| will produce: Abc, +% \verb|\makefirstuc{\ae bc}| will produce: \AE bc, but +% \verb|\makefirstuc{\emph{abc}}| will produce \emph{Abc}. +% This is required by \ics{Gls} and \ics{Glspl}. +%\changes{1.08}{2013-11-04}{made robust} +% \begin{macrocode} +\newif\if@glscs +\newtoks\@glsmfirst +\newtoks\@glsmrest +\newrobustcmd*{\makefirstuc}[1]{% + \def\gls@argi{#1}% + \ifx\gls@argi\@empty +% \end{macrocode} +% If the argument is empty, do nothing. +% \begin{macrocode} + \else +% \end{macrocode} +%\changes{1.03}{2008/12/22}{changed \cs{protected@edef} to \cs{def}} +% \begin{macrocode} + \def\@gls@tmp{\ #1}% + \@onelevel@sanitize\@gls@tmp + \expandafter\@gls@checkcs\@gls@tmp\relax\relax + \if@glscs +% \end{macrocode} +% Check if we have two sequential control sequences. +%\changes{2.0}{2015/09/09}{added check for two control sequences} +% \begin{macrocode} + \expandafter\def\expandafter\@gls@tmp\expandafter{\expandafter + \ \@gobble #1}% + \@onelevel@sanitize\@gls@tmp + \expandafter\@gls@checkcs\@gls@tmp\relax\relax + \if@glscs\@glscsfalse\else\@glscstrue\fi + \fi + \if@glscs + \@gls@getbody #1{}\@nil + \ifx\@gls@rest\@empty + \glsmakefirstuc{#1}% + \else + \expandafter\@gls@split\@gls@rest\@nil + \ifx\@gls@first\@empty + \glsmakefirstuc{#1}% + \else + \expandafter\@glsmfirst\expandafter{\@gls@first}% + \expandafter\@glsmrest\expandafter{\@gls@rest}% + \edef\@gls@domfirstuc{\noexpand\@gls@body + {\noexpand\glsmakefirstuc\the\@glsmfirst}% + \the\@glsmrest}% + \@gls@domfirstuc + \fi + \fi + \else + \glsmakefirstuc{#1}% + \fi + \fi +} +% \end{macrocode} +%\end{macro} +% Put first argument in \cs{@gls@first} and second argument in +% \cs{@gls@rest}: +% \begin{macrocode} +\def\@gls@split#1#2\@nil{% + \def\@gls@first{#1}\def\@gls@rest{#2}% +} +% \end{macrocode} +% \begin{macrocode} +\def\@gls@checkcs#1 #2#3\relax{% + \def\@gls@argi{#1}\def\@gls@argii{#2}% + \ifx\@gls@argi\@gls@argii + \@glscstrue + \else + \@glscsfalse + \fi +} +% \end{macrocode} +%\begin{macro}{\@gls@makefirstuc} +% Make first thing upper case: +% \begin{macrocode} +\def\@gls@makefirstuc#1{\mfirstucMakeUppercase #1} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\mfirstucMakeUppercase} +% Allow user to replace \cs{MakeUppercase} with another case +% changing command. +% \begin{macrocode} +\newcommand*{\mfirstucMakeUppercase}{\MakeUppercase} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\glsmakefirstuc} +%\changes{1.05}{2011/04/02}{new} +% Provide a user command to make it easier to customise. +% \begin{macrocode} +\newcommand*{\glsmakefirstuc}[1]{\@gls@makefirstuc{#1}} +% \end{macrocode} +%\end{macro} +% +% Get the first grouped argument and store in \cs{@gls@body}. +% \begin{macrocode} +\def\@gls@getbody#1#{\def\@gls@body{#1}\@gls@gobbletonil} +% \end{macrocode} +% Scoup up everything to \cs{@nil} and store in \cs{@gls@rest}: +% \begin{macrocode} +\def\@gls@gobbletonil#1\@nil{\def\@gls@rest{#1}} +% \end{macrocode} +% +%\begin{macro}{\xmakefirstuc} +% Expand argument once before applying \cs{makefirstuc} +% (added v1.01). +% \begin{macrocode} +\newcommand*{\xmakefirstuc}[1]{% +\expandafter\makefirstuc\expandafter{#1}} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\emakefirstuc} +%\changes{1.10}{2015/05/03}{new} +% Fully expand argument before applying \cs{makefirstuc} +% \begin{macrocode} +\DeclareRobustCommand*{\emakefirstuc}[1]{% + \protected@edef\@MFU@caparg{#1}% + \expandafter\makefirstuc\expandafter{\@MFU@caparg}% +} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\capitalisewords} +%\changes{1.06}{2012/05/21}{new} +% Capitalise each word in the argument. Words are considered to be +% separated by plain spaces (i.e.\ non-breakable spaces won't be +% considered a word break). +%\changes{1.08}{2013-11-04}{made robust} +%\changes{1.09}{2017-07-30}{added check for words that shouldn't be +%capitalised} +% \begin{macrocode} +\newrobustcmd*{\capitalisewords}[1]{% + \def\gls@add@space{}% + \let\@mfu@domakefirstuc\makefirstuc + \let\@mfu@checkword\@gobble + \mfu@capitalisewords#1 \@nil\mfu@endcap +} +% \end{macrocode} +%\end{macro} +% +% \begin{macrocode} +\def\mfu@capitalisewords#1 #2\mfu@endcap{% + \def\mfu@cap@first{#1}% + \def\mfu@cap@second{#2}% + \gls@add@space + \@mfu@checkword{#1}% + \@mfu@domakefirstuc{#1}% + \def\gls@add@space{ }% + \ifx\mfu@cap@second\@nnil + \let\next@mfu@cap\mfu@noop + \else + \let\next@mfu@cap\mfu@capitalisewords + \let\@mfu@checkword\mfu@checkword + \fi + \next@mfu@cap#2\mfu@endcap +} +\def\mfu@noop#1\mfu@endcap{} +% \end{macrocode} +% +%\begin{macro}{\mfu@checkword} +% Check if word should be capitalised. +%\changes{1.09}{2017-07-30}{new} +% \begin{macrocode} +\newcommand*\mfu@checkword[1]{% + \ifinlist{#1}{\@mfu@nocaplist}% + {% + \let\@mfu@domakefirstuc\@firstofone + }% + {% + \let\@mfu@domakefirstuc\makefirstuc + }% +} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\@mfu@nocaplist} +% List of words that shouldn't be capitalised. +%\changes{1.09}{2017-07-30}{new} +% \begin{macrocode} +\newcommand*{\@mfu@nocaplist}{} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\MFUnocap} +% Provide the user with a means to add a word to the list. +% \begin{macrocode} +\newcommand*{\MFUnocap}[1]{\listadd{\@mfu@nocaplist}{#1}} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\gMFUnocap} +% Global version. +%\changes{1.09}{2017-07-30}{new} +% \begin{macrocode} +\newcommand*{\gMFUnocap}[1]{\listgadd{\@mfu@nocaplist}{#1}} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\MFUclear} +% Clear the list +%\changes{1.09}{2017-07-30}{new} +% \begin{macrocode} +\newcommand*{\MFUclear}{\renewcommand*{\@mfu@nocaplist}{}} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\xcapitalisewords} +%\changes{1.06}{2012/05/21}{new} +% Short-cut command: +% \begin{macrocode} +\newcommand*{\xcapitalisewords}[1]{% + \expandafter\capitalisewords\expandafter{#1}% +} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\ecapitalisewords} +%\changes{1.10}{2015/05/03}{new} +% Fully expand argument before applying \cs{capitalisewords} +% \begin{macrocode} +\DeclareRobustCommand*{\ecapitalisewords}[1]{% + \protected@edef\@MFU@caparg{#1}% + \expandafter\capitalisewords\expandafter{\@MFU@caparg}% +} +% \end{macrocode} +%\end{macro} +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*mfirstuc-english.sty> +% \end{macrocode} +%\fi +%\subsection{Mfirstuc-english Documented Code} +%\label{sec:code:mfirstuc-english} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{mfirstuc-english}[2015/09/09 v2.0 (NLCT)] +% \end{macrocode} +% Load \sty{mfirstuc} if not already loaded: +% \begin{macrocode} +\RequirePackage{mfirstuc} +% \end{macrocode} +% Add no-cap words. This list isn't complete. I~don't intend adding +% disputed words. Additional words can be added to the document in +% a~similar manner. +% \begin{macrocode} +\MFUnocap{a} +\MFUnocap{an} +\MFUnocap{and} +\MFUnocap{but} +\MFUnocap{for} +\MFUnocap{in} +\MFUnocap{of} +\MFUnocap{or} +\MFUnocap{no} +\MFUnocap{nor} +\MFUnocap{so} +\MFUnocap{some} +\MFUnocap{the} +\MFUnocap{with} +\MFUnocap{yet} +% \end{macrocode} +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*sample-mfirstuc.tex> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} + % This file is public domain + % If you want to use arara, you need the following directive: + % arara: pdflatex: { synctex: on } +\documentclass{article} + +\usepackage{mfirstuc-english} + +\begin{document} + +\makefirstuc{abc}. + +\makefirstuc{{\em abc}}. + +\makefirstuc{\emph{abc}}. + +\makefirstuc{\ae bc}. + +\makefirstuc{{\ae}bc}. + +\newcommand{\abc}{abc}% +\xmakefirstuc{\abc}. + +\capitalisewords{the wind in the willows} + +\capitalisewords{a book of rhyme.} + +\MFUclear + +\capitalisewords{the wind in the willows} + +\capitalisewords{a book of rhyme.} + +\capitalisewords{a book\space of rhyme.} + +\newcommand{\mytitle}{a book\space of rhyme.} +\capitalisewords{\mytitle} + +\xcapitalisewords{\mytitle} + + +\end{document} +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*mfirstuc.perl> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +# File : mfirstuc.perl +# Author : Nicola L. C. Talbot +# Date : 2012-09-21 +# Version : 1.0 +# Description : LaTeX2HTML (limited!) implementation of mfirstuc package + +# This is a LaTeX2HTML style implementing the mfirstuc package, and +# is distributed as part of the glossaries package. +# Copyright 2007 Nicola L.C. Talbot +# This work may be distributed and/or modified under the +# conditions of the LaTeX Project Public License, either version 1.3 +# of this license of (at your option) any later version. +# The latest version of this license is in +# http://www.latex-project.org/lppl.txt +# and version 1.3 or later is part of all distributions of LaTeX +# version 2005/12/01 or later. +# +# This work has the LPPL maintenance status `maintained'. +# +# The Current Maintainer of this work is Nicola Talbot. + +use warnings; + +package main; + +sub do_cmd_makefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &translate_commands("\\glsmakefirstuc $text") . $_; +} + +sub do_cmd_xmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + unless ($id) + { + $id = ++$global{'max_id'}; + } + + &translate_commands("\\expandafter \\makefirstuc $OP$id$CP$text$OP$id$CP") + . $_; +} + +sub do_cmd_glsmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &get_next_object unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &do_real_makefirstuc($text).$_; +} + +sub do_real_makefirstuc{ + local($text) = @_; + + if ($text=~/^((?:\s*<[^>]+>\s*)+)(.*)/) + { + $text = $1 . ucfirst($2); + } + else + { + $text = ucfirst($text); + } + + $text; +} + +sub do_cmd_capitalisewords{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + local($newtext) = ''; + + foreach my $word (split ' ', $text) + { + $id = ++$global{'max_id'}; + + $word = &translate_commands("\\makefirstuc $OP$id$CP$word$OP$id$CP"); + + if ($newtext) + { + $newtext .= ' ' . $word; + } + else + { + $newtext = $word; + } + } + + $newtext.$_; +} + +sub get_next_object{ + local($next, $revert, $thisline); + local($this_cmd) = $cmd; + $this_cmd =~ s/^\\// unless ($cmd eq "\\"); + if (/^[\s%]*([^\n]*)\n/ ) { + $thisline = &revert_to_raw_tex($1) + } else { + $thisline = &revert_to_raw_tex($_); + } + s/^\s*//; + if ($_ =~ s/$next_token_rx//) { $next = $& }; + $next =~ s/$comment_mark(\d+\n?)?//g; + if ($next =~ /^\\(\W|\d|[a-zA-z]*\b)/) { + $revert = $next = "\\".$1; + } elsif ($next =~ /\W/) { + $revert = &revert_to_raw_tex($next); + } else { $revert = $next }; + $next; +} + +1; +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\Finale +\endinput diff --git a/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins new file mode 100644 index 00000000000..6fff3a624cc --- /dev/null +++ b/Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins @@ -0,0 +1,35 @@ +% mfirstuc.ins generated using makedtx version 1.1 2015/9/9 15:55 +\input docstrip + +\preamble + + mfirstuc.dtx + Copyright 2015 Nicola Talbot + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license of (at your option) any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + The Current Maintainer of this work is Nicola Talbot. + + This work consists of the files mfirstuc.dtx and mfirstuc.ins and the derived files mfirstuc.sty, mfirstuc-english.sty, sample-mfirstuc.tex, mfirstuc.perl. + +\endpreamble + +\askforoverwritefalse + +\generate{\file{mfirstuc.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{mfirstuc.dtx}{mfirstuc.sty,package}} +\file{mfirstuc-english.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{mfirstuc.dtx}{mfirstuc-english.sty,package}} +\file{sample-mfirstuc.tex}{\nopreamble\nopostamble\from{mfirstuc.dtx}{sample-mfirstuc.tex}} +\file{mfirstuc.perl}{\nopreamble\nopostamble\from{mfirstuc.dtx}{mfirstuc.perl}} +} + +\endbatchfile diff --git a/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty new file mode 100644 index 00000000000..f8a111daaf6 --- /dev/null +++ b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc-english.sty @@ -0,0 +1,61 @@ +%% +%% This is file `mfirstuc-english.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% mfirstuc.dtx (with options: `mfirstuc-english.sty,package') +%% +%% mfirstuc.dtx +%% Copyright 2015 Nicola Talbot +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license of (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Nicola Talbot. +%% +%% This work consists of the files mfirstuc.dtx and mfirstuc.ins and the derived files mfirstuc.sty, mfirstuc-english.sty, sample-mfirstuc.tex, mfirstuc.perl. +%% +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{mfirstuc-english}[2015/09/09 v2.0 (NLCT)] +\RequirePackage{mfirstuc} +\MFUnocap{a} +\MFUnocap{an} +\MFUnocap{and} +\MFUnocap{but} +\MFUnocap{for} +\MFUnocap{in} +\MFUnocap{of} +\MFUnocap{or} +\MFUnocap{no} +\MFUnocap{nor} +\MFUnocap{so} +\MFUnocap{some} +\MFUnocap{the} +\MFUnocap{with} +\MFUnocap{yet} +\endinput +%% +%% End of file `mfirstuc-english.sty'. diff --git a/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty new file mode 100644 index 00000000000..ed7992e1d6f --- /dev/null +++ b/Master/texmf-dist/tex/latex/mfirstuc/mfirstuc.sty @@ -0,0 +1,149 @@ +%% +%% This is file `mfirstuc.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% mfirstuc.dtx (with options: `mfirstuc.sty,package') +%% +%% mfirstuc.dtx +%% Copyright 2015 Nicola Talbot +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license of (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Nicola Talbot. +%% +%% This work consists of the files mfirstuc.dtx and mfirstuc.ins and the derived files mfirstuc.sty, mfirstuc-english.sty, sample-mfirstuc.tex, mfirstuc.perl. +%% +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{mfirstuc}[2015/09/09 v2.0 (NLCT)] +\RequirePackage{etoolbox} +\newif\if@glscs +\newtoks\@glsmfirst +\newtoks\@glsmrest +\newrobustcmd*{\makefirstuc}[1]{% + \def\gls@argi{#1}% + \ifx\gls@argi\@empty + \else + \def\@gls@tmp{\ #1}% + \@onelevel@sanitize\@gls@tmp + \expandafter\@gls@checkcs\@gls@tmp\relax\relax + \if@glscs + \expandafter\def\expandafter\@gls@tmp\expandafter{\expandafter + \ \@gobble #1}% + \@onelevel@sanitize\@gls@tmp + \expandafter\@gls@checkcs\@gls@tmp\relax\relax + \if@glscs\@glscsfalse\else\@glscstrue\fi + \fi + \if@glscs + \@gls@getbody #1{}\@nil + \ifx\@gls@rest\@empty + \glsmakefirstuc{#1}% + \else + \expandafter\@gls@split\@gls@rest\@nil + \ifx\@gls@first\@empty + \glsmakefirstuc{#1}% + \else + \expandafter\@glsmfirst\expandafter{\@gls@first}% + \expandafter\@glsmrest\expandafter{\@gls@rest}% + \edef\@gls@domfirstuc{\noexpand\@gls@body + {\noexpand\glsmakefirstuc\the\@glsmfirst}% + \the\@glsmrest}% + \@gls@domfirstuc + \fi + \fi + \else + \glsmakefirstuc{#1}% + \fi + \fi +} +\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}% + \ifx\@gls@argi\@gls@argii + \@glscstrue + \else + \@glscsfalse + \fi +} +\def\@gls@makefirstuc#1{\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]{% + \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 + \mfu@capitalisewords#1 \@nil\mfu@endcap +} +\def\mfu@capitalisewords#1 #2\mfu@endcap{% + \def\mfu@cap@first{#1}% + \def\mfu@cap@second{#2}% + \gls@add@space + \@mfu@checkword{#1}% + \@mfu@domakefirstuc{#1}% + \def\gls@add@space{ }% + \ifx\mfu@cap@second\@nnil + \let\next@mfu@cap\mfu@noop + \else + \let\next@mfu@cap\mfu@capitalisewords + \let\@mfu@checkword\mfu@checkword + \fi + \next@mfu@cap#2\mfu@endcap +} +\def\mfu@noop#1\mfu@endcap{} +\newcommand*\mfu@checkword[1]{% + \ifinlist{#1}{\@mfu@nocaplist}% + {% + \let\@mfu@domakefirstuc\@firstofone + }% + {% + \let\@mfu@domakefirstuc\makefirstuc + }% +} +\newcommand*{\@mfu@nocaplist}{} +\newcommand*{\MFUnocap}[1]{\listadd{\@mfu@nocaplist}{#1}} +\newcommand*{\gMFUnocap}[1]{\listgadd{\@mfu@nocaplist}{#1}} +\newcommand*{\MFUclear}{\renewcommand*{\@mfu@nocaplist}{}} +\newcommand*{\xcapitalisewords}[1]{% + \expandafter\capitalisewords\expandafter{#1}% +} +\DeclareRobustCommand*{\ecapitalisewords}[1]{% + \protected@edef\@MFU@caparg{#1}% + \expandafter\capitalisewords\expandafter{\@MFU@caparg}% +} +\endinput +%% +%% End of file `mfirstuc.sty'. -- cgit v1.2.3