summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries/mfirstuc-manual.tex
blob: 989d7d8dcb33aac9406cb4de78905d9e403b61db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
\documentclass{nlctdoc}

\usepackage{alltt}
\usepackage{mfirstuc}
\usepackage{pifont}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\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 v1.05: uppercasing first letter}
 \author{Nicola L.C. Talbot\\[10pt]
Dickimaw Books\\
\url{http://www.dickimaw-books.com/}}

 \date{2012-05-21}
 \maketitle

The \styfmt{glossaries} bundle is supplied with the package 
\sty{mfirstuc} which provides the command:
\begin{definition}[\DescribeMacro{\makefirstuc}]
\cs{makefirstuc}\marg{stuff}
\end{definition}
This makes the first object of
\meta{stuff} uppercase 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 uppercase. 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
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| so 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) due to expansion issues.

\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 first
object in its argument. It does not fully expand the entire
argument.
\end{important}

If you want to use an alternative command to convert to uppercase,
for example \cs{MakeTextUppercase},\footnote{defined in the 
\styfmt{textcase} package} you can redefine \cs{glsmakefirstuc}. 
For example:
\begin{verbatim}
\renewcommand{\glsmakefirstuc}[1]{\MakeTextUppercase #1}
\end{verbatim}

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

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}, so \meta{text}
consists of just one ``word''.) Compare with next example:

\item
\begin{verbatim}
\newcommand{\mytitle}{a book\space of rhyme.}
\xcapitalisewords{\mytitle}
\end{verbatim}
produces:
\xcapitalisewords{\mytitle}

\end{enumerate}

\end{document}