mfirstuc package FAQ
This is the FAQ for the mfirstuc package. See also the mfirstuc user guide and the bug tracker (mfirstuc category).
General Queries
The difference can be demonstrated with an example document:
\documentclass{article} \usepackage{mfirstuc-english} \begin{document} \capitalisewords{an overly-specific book of rhymes.} \MFUhyphentrue \capitalisewords{an overly-specific book of rhymes.} \ExplSyntaxOn \text_titlecase_all:n {an ~ overly-specific ~ book ~ of ~ rhymes.} \ExplSyntaxOff \end{document}The result is:
An Overly-specific Book of Rhymes.The mfirstuc-english package loads mfirstuc and sets up the words (such as “of”) that shouldn't have their case changed unless they occur at the start. Note that this exception isn’t recognised byAn Overly-Specific Book of Rhymes.
An Overly-specific Book Of Rhymes.
\text_titlecase_all:n
, which capitalises “of”.
Here’s another example:
\documentclass{article} \usepackage{mfirstuc-english} \usepackage{glossaries} \newglossaryentry{book}{name={book},description={}} \begin{document} \capitalisewords{a \gls{book} of rhymes.} \ExplSyntaxOn \text_titlecase_all:n {a ~ \gls{book} ~ of ~ rhymes.} \ExplSyntaxOff \end{document}The result is:
A Book of Rhymes.The glossaries package sets up the mfirstuc mapping that convertsA book Of Rhymes.
\gls
to \Gls
. There is support for mappings with \text_declare_case_equivalent:Nn
but not if the command is identified as an exclusion (which both \gls
and \Gls
are, since their arguments are labels).
However, there are situations where \text_titlecase_all:n
works better. For example:
\documentclass{article} \usepackage{mfirstuc-english} \begin{document} \newcommand{\phrase}{ a book of rhymes.} \capitalisewords{\ignorespaces \phrase} \ecapitalisewords{\ignorespaces \phrase} \ExplSyntaxOn \text_titlecase_all:n {\ignorespaces \phrase} \ExplSyntaxOff \end{document}Remember that
\capitalisewords
doesn’t expand its argument initially. (The identified words may later be expanded if \makefirstuc
passes the word to \text_titlecase_first:n
via \MFUsentencecase
.) If protected expansion is required, \ecapitalisewords
can be used, but \ignorespaces
is a primitive and doesn’t expand. The primitive and leading space remain.
The result is now:
a book of rhymes.a Book of Rhymes.
A Book Of Rhymes.
2024-11-27 14:34:46