diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/mfirstuc')
-rw-r--r-- | Master/texmf-dist/source/latex/mfirstuc/mfirstuc.dtx | 601 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/mfirstuc/mfirstuc.ins | 35 |
2 files changed, 636 insertions, 0 deletions
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 \~} +%</package> +%\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} +%</driver> +%\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} +%</mfirstuc.sty> +% \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} +%</mfirstuc-english.sty> +% \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} +%</sample-mfirstuc.tex> +% \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} +%</mfirstuc.perl> +% \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 |