\Gls
, which need to have the first letter converted to uppercase (sentence-case), but as the commands provided by mfirstuc may be used without glossaries, the two were split into separately maintained packages in 2015 (mfirstuc v2.0 and glossaries v4.18).
Version 2.08 has reimplemented \makefirstuc
using LaTeX3 commands. If there are any compatibility issues, you can rollback to v2.07:
\usepackage
{mfirstuc}[=2.07]
There are two sentence-case commands provided:
Text only (leading UTF-8 now supported):
Leading punctuation is ignored:
However, if the punctuation character is followed by a blocker or mapping command, the punctuation will need to be excluded otherwise the command will be treated as an exclusion. If possible, use semantic markup instead of directly including the punctuation.
Fragile commands need to be protected with
Exclusions are supported by both
Blockers are only supported by
Mappings are only supported by
Argument expansion:
Argument expansion with mappings (and the default unexpanded option):
As from v2.08, the definition of
The rules used when parsing
Note that the above algorithm uses recursion. The termination points are: don’t implement a change, replace a command with another command, or apply the case-change via
For convenience, the following commands are also provided:
The expanded package option will redefine
This applies
For example:
Internally,
Note that
Another way of identifying content that should be excluded with
The command name stems from earlier versions where leading punctuation needed to be skipped. This is no longer necessary, but the command remains as a general purpose robust exclusion command.
For example,
For this situation to work, you need to encapsulate the problematic content with an exclusion command, such as
Punctuation characters are skipped by
However, leading punctuation will result in
For example:
A blocker is a command that prevents any case-change if it occurs at the start of
For example:
In the following, the blocker isn’t detected by
Recent LaTeX kernels provide
Blocker: 𝛼-Particle / 𝛼-particle / 𝛼-Particle / 𝛼-Particle
A mapping indicates that one command should be substituted for another, instead of applying a case-change. The assumption is that the substituted command should perform the case-change instead. Mappings are not supported by
For example (with glossaries):
This option is best avoided and is only provided to emulate the v2.07 behaviour of
The title-case commands are designed to convert the first letter of each word in a phrase to uppercase. These commands are robust.
See §2.1 for excluding words (such as “of”) from the case-changing.
For convenience, there are shortcut commands if expansion is required before parsing the argument:
The parser used by
Each sub-word within the compound word is encapsulated with:
The conditional can be set to true with:
For example:
The actual case-change of each word is performed with:
Formatting for the entire phrase must go outside
If your phrase is likely to contain formatting commands, you can instead use:
If expansion is required, you can use:
Some words typically shouldn’t have their case changed unless they occur at the start. These words can be identified with:
For example:
Since the case-change is ultimately performed by
Examples:
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:
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.
If you are using hyperref and want to use
If you want to provide an alternative for the PDF bookmark, you can use hyperref’s
See the hyperref manual for further details.
A Book of Rhyme.
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
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:
Grouping causes interference. As with all the commands described here, avoid declarations.
Avoid complicated commands in the unstarred version. For example, the following breaks:
A okBo Of Rhyme
If the exclusions, mappings and blockers are required by some external tool, the information can be saved in the aux file.
The associated aux commands are listed below. In each case, a definition is provided in the aux file that does nothing.
The textcase package has been deprecated as from 2022 and it now simply sets
As from v2.08, mfirstuc now defines
This section only applies to rollback or the use of
Prior to version 2.08, the case-change applied by the
A simplistic version of the original
Unfortunately, this will fail if the content starts with a UTF-8 character and you are using pdfLaTeX, where each octet of the UTF-8 character is a separate token. This isn’t a problem with XeLaTeX and LuaLaTeX which both treat the entire multibyte character as a single token.
LaTeX3 now provides
An aux file command that lists all the identified blockers. §3.1; 27
An aux file command that lists all the identified exclusions. §3.1; 26
An aux file command that lists all the identified mappings as a = list. §3.1; 27
Similar to
Applies title-case to . This will apply
Fully expands
Fully expands
Fully expands
Used by
Globally adds exclusion word list for
Conditional that determines whether or not hyphens should be considered word boundaries by the title-case commands. §2; 15
Converts sentence-case internally using
Converts uppercase. Now only used in
Identifies a mapping from the command to command . §1.5; 12
Locally identifies blocker command. §1.4; 11
Uses either
Used by
Locally clears the exclusion word list for
Locally identifies exclusion command. §1.3; 8
Provide to emulate
Used by
Sets
Sets
Locally adds exclusion word list for
Saves the list of exclusions, blockers and mappings to the aux file (if required by some external tool). This command sets itself to
Saves the list of exclusions, blockers and mappings to the aux file (if required by some external tool) at the end of the document. This command sets itself to
Converts sentence-case with expansion. §1.2; 4
Used to markup a character or command that should be treated as a word break by the title-case commands. §2; 15
Shortcut for
Shortcut for
Shortcut for
1. Sentence-Case
\MFUsentencecase
and \makefirstuc
. A summary of the principle features of the two commands is given in Table 1.1.
\MFUsentencecase
and \makefirstuc
Feature
\MFUsentencecase
\makefirstuc
Can expand?
✔
✖
Supports exclusions?
✔
✔
Supports blockers?
✖
✔
Supports mappings?
✖
✔
Semantic commands must be robust?
✔
✖
1.1. Examples
\makefirstuc
{élite} /
\MFUsentencecase
{élite}
\makefirstuc
{`word'} /
\MFUsentencecase
{`word'}
\MFUsentencecase
: \newcommand
{\alert
}[1]{\textcolor
{red}{\textbf
{#1}}}
\makefirstuc
{\alert
{élite}} /
\MFUsentencecase
{\protect
\alert
{élite}}
\makefirstuc
and \MFUsentencecase
: \MFUexcl
{\index
}
\makefirstuc
{\index
{word}example} /
\MFUsentencecase
{\index
{word}example}
\makefirstuc
. They are treated as exclusions with \MFUsentencecase
, which produces a different result: \MFUblocker
{\nameref
}
\makefirstuc
{\nameref
{sec:sentencecase} section} /
\MFUsentencecase
{\nameref
{sec:sentencecase} section}
\makefirstuc
. They are treated as exclusions with \MFUsentencecase
, which produces a different result: \newrobustcmd
{\secref
}[1]{section~\ref
{#1}}
\newrobustcmd
{\Secref
}[1]{Section~\ref
{#1}}
\MFUaddmap
{\secref
}{\Secref
}
\makefirstuc
{\secref
{sec:sentencecase} example} /
\MFUsentencecase
{\secref
{sec:sentencecase} example}
\MFUsentencecase
expands its argument and then skips exclusions whereas \makefirstuc
parses its argument without expansion and then passes the relevant content to \glsmakefirstuc
. Note that different results will occur with the expanded and unexpanded package options. For example: \usepackage
[expanded]{mfirstuc}
\newcommand
{\testa
}{sample}
\newcommand
{\testb
}{\testa
\
test}
\begin{document}
\makefirstuc
{\testb
} / \xmakefirstuc
{\testb
} /
\emakefirstuc
{\testb
} / \MFUsentencecase
{\testb
}
\end{document}
This produces: \usepackage
{mfirstuc}[=v2.07]
\newcommand
{\testa
}{sample}
\newcommand
{\testb
}{\testa
\
test}
\begin{document}
\makefirstuc
{\testb
} / \xmakefirstuc
{\testb
} /
\emakefirstuc
{\testb
}
\end{document}
\newrobustcmd
{\secref
}[1]{section~\ref
{#1}}
\newrobustcmd
{\Secref
}[1]{Section~\ref
{#1}}
\MFUaddmap
{\secref
}{\Secref
}
\newcommand
{\testa
}{\secref
{sec:sentencecase}}
\newcommand
{\testb
}{\testa
\
example}
\makefirstuc
{\testb
} / \xmakefirstuc
{\testb
} /
\emakefirstuc
{\testb
} / \MFUsentencecase
{\testb
}
1.2. Sentence Case Commands
\text_titlecase_first:n
, which is provided by the LaTeX3 kernel. Note that this fully expands the argument. If you use this command, ensure that your semantic commands are robust. For example: \newrobustcmd
{\alert
}[1]{\textcolor
{red}{\textbf
{#1}}}
\MFUsentencecase
{\alert
{sample} text}
This is because the expansion that’s performed before the case-change will result in: \newcommand
{\alert
}[1]{\textcolor
{red}{\textbf
{#1}}}
\MFUsentencecase
{\alert
{sample} text}
This triggers an error since \textcolor
{Red}{\textbf
{sample}} text
Red
isn’t a recognised colour name.\glsmakefirstuc
.\makefirstuc
has been updated to use LaTeX3 code, but the argument is still parsed, which allows for non-robust semantic commands, and now also takes blockers and mappings into account. For example: \newcommand
{\alert
}[1]{\textcolor
{red}{\textbf
{#1}}}
\makefirstuc
{\alert
{sample} text}
are as follows:
\makefirstuc
{ }
;\glsmakefirstuc
{ }
\protect
, skip it and continue to the next step where the command under inspection is now the one that follows \protect
:
;\glsmakefirstuc
{ } (where { } may be empty) and then:
; { }
; { }\makefirstuc
{ }
.
{\makefirstuc
{ }}
.
\glsmakefirstuc
{ }\glsmakefirstuc
.
This ensures the first token in is expanded before being passed to \expandafter
\makefirstuc
\expandafter
{ }
\makefirstuc
.\makefirstuc
. For example: \newcommand
{\test
}[1]{sample #1}
\newcommand
{\tmp
}{\test
{text}}
\makefirstuc
{\tmp
} /
\xmakefirstuc
{\tmp
} /
\emakefirstuc
{\tmp
}
\MFUsentencecase
instead of \emakefirstuc
.\emakefirstuc
, mappings and blockers will only be detected if they are robust or protected, otherwise they will expand too soon to be detected. \makefirstuc
to perform the case-change. The “gls” prefix is for historical reasons as the original code was part of the glossaries package. With the default unexpanded option, this command is defined as:
The use of \MFUsentencecase
{\unexpanded
{ }}
\unexpanded
inhibits the expansion of that would otherwise occur. This allows \makefirstuc
to maintain as much backward-compatibility with version 2.07 as possible. This is particularly important when using the glossaries package with a style that automatically converts the description to sentence-case, as there may well be documents with complex descriptions that contain fragile commands.\glsmakefirstuc
to use \MFUsentencecase
without \unexpanded
. The grabfirst package option will redefine \glsmakefirstuc
to use \mfugrabfirstuc
to emulates the behaviour of \glsmakefirstuc
in v2.07 and below without using rollback.\mfirstucMakeUppercase
to \MakeUppercase
, which you will also need.)\mfirstucMakeUppercase
to the first token in and leaves the remainder unchanged. This won’t work if starts with a UTF-8 character unless you use XeLaTeX or LuaLaTeX, so avoid using this method where possible. For example:
This is equivalent to: \renewcommand
{\mfirstucMakeUppercase
}[1]{%
\MakeUppercase
{#1}%
}
\mfugrabfirstuc
{sample}
Whereas \mfirstucMakeUppercase
{s}ample
only works with XeLaTeX or LuaLaTeX.\renewcommand
{\mfirstucMakeUppercase
}[1]{%
\MakeUppercase
{#1}%
}
\mfugrabfirstuc
{élite}
\makefirstuc
that tried to only apply the case-change to the first token, this won’t produce the desired result if the argument starts with a punctuation character.
This is equivalent to: \mfugrabfirstuc
{`sample'}
so no case-change is applied.\mfirstucMakeUppercase
{`}sample'
1.3. Exclusions
\mfirstucMakeUppercase
, but this is generally desirable. as an { }exclusion. That is, one that should have its argument excluded from a case-change.
\MFUexcl
adds to LaTeX3’s exclusion list \l_text_case_exclude_arg_tl
, which means that \MFUsentencecase
will skip the command and its argument and apply the case-change to the following content. Some common commands (\begin
\cite
\end
\label
and \ref
) are automatically added by the LaTeX3 kernel. The exclusions are also recognised by \makefirstuc
when it parses its argument.\NoCaseChange
is automatically treated as an exclusion by the LaTeX3 case-changing commands with recent LaTeX kernels. You may want to add it as a blocker for \makefirstuc
and keep \MFUskippunc
for exclusions.\ensuremath
is added as an exclusion by mfirstuc otherwise \makefirstuc
will pass its argument to \MFUsentencecase
, which will cause a problem. \makefirstuc
is to encapsulate it with: \glsadd
(provided by glossaries) should have its argument skipped, since its argument is a label, so the following will ensure that
will be skipped, and the case-change will be applied to the following text for both \glsadd
{ }\MFUsentencecase
and \makefirstuc
.
This will be equivalent to: \MFUexcl
{\glsadd
}
\makefirstuc
{\glsadd
{ex}some text}
\MFUsentencecase
{\glsadd
{ex}some text}
However, \glsadd
{ex}Some text
\glsadd
can take an optional argument which, if present, will cause a problem. For example:
Both commands will cause the following error: \MFUexcl
{\glsadd
}
\makefirstuc
{\glsadd
[counter=section]{ex}some text}
\MFUsentencecase
{\glsadd
[counter=section]{ex}some text}
! Package glossaries Error: Glossary entry `[' has not been defined.
This is because the open square bracket is assumed to be the argument of \glsadd
, so this effectively becomes:
which means that now \glsadd
{[}Counter=section] exsome text
\glsadd
{[}Counter=section] exsome text
[
is considered the label and everything that follows is just text.\NoCaseChange
or \MFUskippunc
:
This will also work with \makefirstuc
{\MFUskippunc
{\glsadd
[counter=section]{ex}}some text}
\MFUsentencecase
because mfirstuc automatically adds \MFUskippunc
to the exclusion list.\glsadd
is automatically added as an exclusion, but be aware of the problem with using the optional argument, as described above. \MFUsentencecase
. For example:
\MFUsentencecase
{`word'}
\makefirstuc
passing its entire argument to \MFUsentencecase
(since the argument doesn’t start with ), which means that { }
\makefirstuc
won’t detect any blocker or mapping.
If you are using a package such as csquotes, bear in mind that if the command is followed by an asterisk (a “starred command”) or an optional argument then it won’t fit the expected \MFUblocker
{\nameref
}
\newcommand
*{\qt
}[1]{``#1''}
\makefirstuc
{``\nameref
{sec:sentencecase} section''} /
\makefirstuc
{\MFUskippunc
{``}\nameref
{sec:sentencecase} section''} /
\makefirstuc
{\qt
{\nameref
{sec:sentencecase} section}}
format and unexpected results will occur. { }
1.4. Blockers
\makefirstuc
or after the argument of an exclusion. Blockers are not supported by \MFUsentencecase
but are instead treated as exclusions. \MFUsentencecase
, this automatically implements
to protect its argument from \MFUexcl
{ }\MFUsentencecase
, but it won’t prevent subsequent content from being changed.\MFUblocker
{\nameref
}
\makefirstuc
{\nameref
{sec:sentencecase} section}
\makefirstuc
because the content doesn’t start with or { }
\protect { }
. This means that the entire content is passed to \MFUsentencecase
which treats \nameref
as an exclusion: \MFUblocker
{\nameref
}
\makefirstuc
{\relax
\nameref
{sec:sentencecase} section}
\makefirstuc
unless the other command is expanded before applying \makefirstuc
. For example, by using \xmakefirstuc
or \emakefirstuc
. If it doesn’t get expanded until after it has been passed to \MFUsentencecase
, then it will be treated as an exclusion instead. \NoCaseChange
and automatically add it as an exclusion. You may want to add it as a blocker for \makefirstuc
. For example:
Note that mfirstuc adds \makefirstuc
{\ensuremath
{\alpha
}-particle} /
\makefirstuc
{$
\alpha
$
-particle} /
\MFUsentencecase
{\ensuremath
{\alpha
}-particle} /
\MFUsentencecase
{$
\alpha
$
-particle}
\MFUblocker
{\NoCaseChange
}%
\makefirstuc
{\ensuremath
{\alpha
}-particle} /
\makefirstuc
{\NoCaseChange
{$
\alpha
$
}-particle} /
\MFUsentencecase
{\ensuremath
{\alpha
}-particle} /
\MFUsentencecase
{\NoCaseChange
{$
\alpha
$
}-particle}
\ensuremath
as an exclusion so \makefirstuc
will skip it. Whereas the example above that starts with $
will have the entire argument passed to \MFUsentencecase
, which skips the maths content. In the first paragraph, \NoCaseChange
is only an exclusion, but in the second paragraph it’s also a blocker. 1.5. Mappings
\MFUsentencecase
but are instead treated as exclusions.\makefirstuc
should replace with and not apply a case-change. This automatically implements:
This means that is identified as a blocker (since it’s assumed to already be a sentence-case command) and is identified as an exclusion to protect its argument from \MFUexcl
{ }\MFUblocker
{ }
\MFUsentencecase
, which doesn’t support mappings.
This will be converted to: \MFUaddmap
{\gls
}{\Gls
}
\makefirstuc
{\gls
{ex} some text}
Note that this and similar mappings are automatically added in glossaries v4.50+ and glossaries-extra v1.49+.\Gls
{ex} some text
\makefirstuc
unless the other command is expanded before applying \makefirstuc
. For example, by using \xmakefirstuc
or \emakefirstuc
. If it doesn’t get expanded until after it has been passed to \MFUsentencecase
, then it will be treated as an exclusion instead. 1.6. Package Options
\glsmakefirstuc
to simply use \MFUsentencecase
.\glsmakefirstuc
to use \MFUsentencecase
without expanding its argument.\glsmakefirstuc
to use \mfugrabfirstuc
and also redefines \mfirstucMakeUppercase
to use \MakeUppercase
.\glsmakefirstuc
. However, you may still have different results compared to v2.07, so you may need to use rollback instead.2. Title-Case
~
or \space
. Note that no expansion is performed on . For example:
\capitalisewords
{a sample phrase}
\text_titlecase:n
, which converts the first letter to uppercase and all other letters to lowercase.
This fully expands before passing it to \expandafter
\capitalisewords
\expandafter
{ }
\capitalisewords
.\capitalisewords
first splits up the text on each space character. Each of these space-separated words may actually be a compound, so further parsing is performed on each “word”. The divisions within the compound word should be marked up with:
\capitalisewords
{a
big\MFUwordbreak
{/}small idea}
\MFUcapword
can be enabled to check for hyphens.
This conditional determines whether or not \MFUcapword
should consider a hyphen a word break. If this conditional is true, then \MFUcapword
will encapsulate its argument with:
This will parse for hyphen characters and apply the case change to each hyphen-separated word. Otherwise \MFUcapword
will treat its argument as a single word.\capitalisewords
{server-side includes} /
\MFUhyphentrue
\capitalisewords
{server-side includes}
but may be redefined to use \makefirstuc
{ }\MFUsentencecase
, if preferred.\MFUwordbreak
must be visible to the parser that searches for word breaks. This means they won’t be detected if they are within a group or in the definition of a command. \capitalisewords
(unlike \makefirstuc
). For example: \capitalisewords
{\emph
{a sample phrase}} /
\emph
{\capitalisewords
{a sample phrase}}
\capitalisewords
):
or may be entirely enclosed in a formatting command in the form: \capitalisefmtwords
{ }
or contain formatted sub-phrases: \capitalisefmtwords
{ { }}
The starred form only permits a text-block command at the start of the phrase. See §2.3 for examples.\capitalisefmtwords
{ { } }
(The star modifier will be applied with \expandafter
\capitalisefmtwords
\expandafter
{ }
in an appropriate manner.)\xcapitalisefmtwords
*\capitalisefmtwords
. Again, the star modifier may be used.\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
. 2.1. Excluding Words From Case-Changing
\capitalisewords
{the wind in the willows}
\MFUnocap
{in}%
\MFUnocap
{the}%
\capitalisewords
{the wind in the willows}
\makefirstuc
, you can also use an exclusion to prevent an individual word from being changed. For example: \newcommand
{\NoChange
}[1]{#1}
\MFUexcl
{\NoChange
}
\MFUclear
\capitalisewords
{the \NoChange
{wind} in the willows}
\MFUcapwordfirstuc
to use \MFUsentencecase
provided the exclusion command doesn’t expand (so \NoChange
would need to be protected or made robust in the above example). \MFUwordbreak
but not to parts of a hyphenated word that are split by \MFUhyphencapword
.
\MFUwordbreak
occurs before the first space. \MFUnocap
{a}\MFUnocap
{the}%
\capitalisewords
{a\MFUwordbreak
{/}the something}
\MFUnocap
{and}\MFUnocap
{or}%
\capitalisewords
{one and\MFUwordbreak
{/}or another}
\MFUhyphentrue
\MFUnocap
{and}\MFUnocap
{or}%
\capitalisewords
{one and-or another}
\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. Note that you need to explicitly load mfirstuc-english if you require it. There’s no automatic language detection performed by mfirstuc.
The next line should identify the package. For example, if you have called the file mfirstuc-french.sty then you need: \NeedsTeXFormat
{LaTeX2e}
It’s a good idea to also add a version in the final optional argument, for example: \ProvidesPackage
{mfirstuc-french}
Next load mfirstuc: \ProvidesPackage
{mfirstuc-french}[2014/07/30 v1.0]
Now add all your \RequirePackage
{mfirstuc}
\MFUnocap
commands. For example:
At the end of the file add: \MFUnocap
{de}
\endinput
2.2. PDF Bookmarks
\capitalisewords
or \capitalisefmtwords
(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
'
\texorpdfstring
command. For example:
Alternatively, you can use hyperref’s mechanism for disabling commands within the bookmarks. For example: \chapter
{\texorpdfstring
{\capitalisewords
{a book of rhyme}}% TeX
{A Book of Rhyme}% PDF
}
The same applies to \pdfstringdefDisableCommands
{%
\let
\capitalisewords
\@firstofone
}
\makefirstuc
. You can, however, use the expandable \MFUsentencecase
. So you may prefer: \pdfstringdefDisableCommands
{%
\let
\capitalisewords
\MFUsentencecase
\let
\makefirstuc
\MFUsentencecase
}
2.3. Examples
\capitalisewords
{a little book of rhyme}
\MFUnocap
{of}
\capitalisewords
{a little book of rhyme}
\space
isn’t recognised as a word boundary: \capitalisewords
{a book of rhyme.}
\capitalisewords
{a book\space
of rhyme.}
\capitalisefmtwords
{\emph
{a small book of rhyme}}
\capitalisefmtwords
{a \emph
{small book} of rhyme}
\capitalisefmtwords
{\textbf
{a \emph
{small book}} of rhyme}
\MFUnocap
{of}
\capitalisefmtwords
{\textbf
{a \emph
{small book}} of rhyme}
\MFUnocap
{of}
\capitalisefmtwords
*{\emph
{a small book of rhyme}}
\MFUnocap
{of}
\capitalisefmtwords
*{a small book of rhyme}
\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
}.
\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.
In this case \MFUnocap
{of}
\capitalisefmtwords
*{\emph
{a small} book \textbf
{of rhyme}}
\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}
\emph{very small}
is considered a single word.\capitalisefmtwords
{{\bfseries
a \emph
{small book}} of rhyme}
However it can work with the starred form and the simpler \newcommand
*{\swap
}[2]{{#2}{#1}}
\capitalisefmtwords
{a \swap
{bo}{ok} of rhyme}
\capitalisewords
: \newcommand
*{\swap
}[2]{{#2}{#1}}
\capitalisefmtwords
*{a \swap
{bo}{ok} of rhyme}
\capitalisewords
{a \swap
{bo}{ok} of rhyme}
3. Miscellaneous
3.1. Saving exclusions, blockers and mappings in the aux File
\MFUsaveatend
, regardless of whether or not \MFUsaveatend
comes before or after \MFUsave
.\@mfu@excls
{\begin
\cite
\end
\label
\ref
\cite
\NoCaseChange
\ensuremath
\MFUskippunc
\gls
\glspl
}
\@mfu@blockers
{\Gls
\Glspl
}
\@mfu@mappings
{ {\gls
}= {\Gls
}, {\glspl
}= {\Glspl
}}
3.2. All-Caps
\MakeUppercase
. The glossaries package (before v4.50) formerly loaded the textcase package and redefined \mfirstucMakeUppercase
to use \MakeTextUppercase
, which was better than \MakeUppercase
.\MakeTextUppercase
to \MakeUppercase
because the new kernel now defines \MakeUppercase
to use the newer LaTeX3 command \text_uppercase:n
. Although that command is expandable, \MakeUppercase
is robust.\mfirstucMakeUppercase
so that it uses \text_titlecase_first:n
directly, rather than indirectly through \MakeUppercase
, which means that it’s now expandable. However, \mfirstucMakeUppercase
is no longer used by mfirstuc except in \mfugrabfirstuc
, which is provided to emulate v2.07. Note that the grabfirst option will also redefine \mfirstucMakeUppercase
to use \MakeUppercase
.3.3. UTF-8
\mfugrabfirstuc
(implemented via the grabfirst option).\glsmakefirstuc
command worked 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 this practice is discouraged by some.)\glsmakefirstuc
command is:
Here \newcommand
*{\FirstUC
}[1]{\MakeUppercase
#1}
is equivalent to \FirstUC
{abc}
and since \MakeUppercase
abc
\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”. This behaviour can be achieved with \mfugrabfirstuc
.\text_titlecase_first:n
to convert the first character to uppercase, so now the case-change can be applied with:
This is exactly what \ExplSyntaxOn
\text_titlecase_first:n
{élite}
\ExplSyntaxOff
\MFUsentencecase
does without the need to switch on LaTeX3 syntax. The difference with the default definition of \glsmakefirstuc
is that it prevents its argument from being expanded.Symbols
Glossary
\makefirstuc
, it won’t attempt to apply any case-changing. See §1.4.\makefirstuc
, instead of applying a case-change. See §1.5.
is syntactic markup. Whereas defining a command called, say, \textit
{Clostridium}\bacteria
that displays its argument in italics is a semantic command. The actual styling is hidden and the command relates specifically to a particular concept. Syntactic:
The end result is the same:
The advantage with semantic commands is that it’s much easier to change the style, simply by adjusting the command definition. Note that I’ve used \textit
{Clostridium}
\newrobustcmd
*{\bacteria
}[1]\emph
{#1}%
Semantic: \bacteria
{Clostridium} \newrobustcmd
to make the semantic command robust as the style commands can cause a problem if they expand too soon.Command Summary
@
C
\capitalisewords
but for content that may contain formatting commands. §2; 16\MFUcapword
to each word in (unless the word has been identified as an exclusion word and doesn’t occur at the start of ). §2; 14E
\capitalisefmtwords
including the *
modifier, if provided. §2; 17\capitalisewords
. §2; 14\makefirstuc
. §1.2; 6G
\makefirstuc
to perform the case-change. This uses
but by default will prevent its argument from being expanded. §1.2; 6\MFUsentencecase
{ }\capitalisewords
. §2.1; 18I
M
\glsmakefirstuc
to perform the case-change, but first parses to deal with special cases. §1.2; 4\mfugrabfirstuc
. §3.2; 27\MFUhyphencapword
or \MFUcapwordfirstuc
depending on \ifMFUhyphen
. §2; 15\MFUcapword
and \MFUhyphencapword
to apply the case-change to the given word. This just does
by default. §2; 16\makefirstuc
{ }\capitalisewords
. §2.1; 18\glsmakefirstuc
in v2.07 and below, but can still produce different results to v2.07. This will attempt to grab only the first character of and convert it to uppercase, leaving the rest of unchanged. This won’t work if starts with a UTF-8 character, unless you are using XeLaTeX or LuaLaTeX. §1.2; 7\MFUcapword
to apply \MFUcapwordfirstuc
to each hyphen-separated word in , if hyphens should indicate a word-break. §2; 15\ifMFUhyphen
to false. §2; 15\ifMFUhyphen
to true. §2; 15\capitalisewords
. §2.1; 17\relax
so it doesn’t repeat the action if used multiple times, and counteracts any use of \MFUsaveatend
. §3.1; 26\relax
so it doesn’t repeat the action if used multiple times, but it can be overridden by \MFUsave
. §3.1; 26X
\expandafter
including the \capitalisefmtwords
\expandafter{ }*
modifier, if provided. §2; 17\expandafter
. §2; 14\capitalisewords
\expandafter{ }\expandafter
. §1.2; 5\makefirstuc
\expandafter{ }Index
Symbols
~
14$
12@
B
C
E
F
G
\Glspl
27H
I
\index
2L
\l_text_case_exclude_arg_tl
8M
\MakeTextUppercase
27N
P
\pdfstringdefDisableCommands
21\protect
5R
S
T
\texorpdfstring
20\text_titlecase:n
14\text_uppercase:n
27U
\unexpanded
6X