blob: eb1104be59a8c404c4d7fac09b078f95f87f93d9 (
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
% This file is public domain
% If you want to use arara, you need the following directive:
% arara: pdflatex: { synctex: on }
\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage{color}
\usepackage{mfirstuc-english}% also loads mfirstuc.sty
\begin{document}
This is a sample document illustrating the mfirstuc package.
\section{First Letter Upper Case}
\verb|\makefirstuc{abc}.|
\makefirstuc{abc}.
\verb|\makefirstuc{{\em abc}}.|
\makefirstuc{{\em abc}}.
\verb|\makefirstuc{\emph{abc}}.|
\makefirstuc{\emph{abc}}.
\verb|\makefirstuc{\ae bc}.|
\makefirstuc{\ae bc}.
\verb|\makefirstuc{{\ae}bc}.|
\makefirstuc{{\ae}bc}.
\verb|\newcommand{\abc}{abc}\xmakefirstuc{\abc}.|
\newcommand{\abc}{abc}%
\xmakefirstuc{\abc}.
\newcommand*{\mytext}{\protect\textbf{some text}}
Protected formatting: \xmakefirstuc{\mytext}.
\renewcommand*{\mytext}{\ae\oe{some text}}
Sequential commands: \xmakefirstuc{\mytext}.
\section{Title Case (Formatting)}
Formatting for the entire phrase must go outside
\verb|\capitalisewords| (unlike \verb|\makefirstuc|). Compare:
\verb|\capitalisewords{\textbf{a small book of rhyme.}}|
\capitalisewords{\textbf{a small book of rhyme.}}
with:
\verb|\textbf{\capitalisewords{a small book of rhyme.}}|
\textbf{\capitalisewords{a small book of rhyme.}}
\medskip
Use \verb|\capitalisefmtwords| instead (full stop outside
argument to check for spurious spaces):
\verb|\capitalisefmtwords{\textbf{a small book of rhyme}}.|
\capitalisefmtwords{\textbf{a small book of rhyme}}.
\verb|\capitalisefmtwords{\textbf{a small book} of rhyme}.|
\capitalisefmtwords{\textbf{a small book} of rhyme}.
\verb|\capitalisefmtwords{a \textbf{small book} of rhyme}.|
\capitalisefmtwords{a \textbf{small book} of rhyme}.
\verb|\capitalisefmtwords{\textbf{a} book of rhyme}.|
\capitalisefmtwords{\textbf{a} small book of rhyme}.
\verb|\capitalisefmtwords{\textbf{a book }of rhyme}.|
\capitalisefmtwords{\textbf{a small book }of rhyme}.
\verb|\capitalisefmtwords{a small book \textbf{of rhyme}}.|
\capitalisefmtwords{a small book \textbf{of rhyme}}.
\medskip
Use semantic commands for things like quotations:
\begin{verbatim}
\newcommand*{\qt}[1]{``#1''}
\capitalisefmtwords{\qt{a small book of rhyme.}}
\end{verbatim}
\newcommand*{\qt}[1]{``#1''}
\capitalisefmtwords{\qt{a small book of rhyme.}}
\smallskip
(But make them robust if you intend using commands like
\verb|\ecapitalisefmtwords|.)
\medskip
Nested text-block commands:
\begin{verbatim}
\capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}.
\end{verbatim}
\capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}.
\begin{verbatim}
\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}.
\end{verbatim}
\capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}.
\begin{verbatim}
\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}.
\end{verbatim}
\capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}.
\medskip
An empty brace at the start of a word will suppress the
case-changing.
\begin{verbatim}
\capitalisefmtwords{\textbf{a small {}book of} rhyme}.
\end{verbatim}
\capitalisefmtwords{\textbf{a small {}book of} rhyme}.
\medskip
Suppress case-changing for problematic commands by inserting
an empty group in front:
\begin{verbatim}
\capitalisefmtwords{{}\textcolor{red}{a} small book of
{}\textcolor{red}{rhyme}}.
\end{verbatim}
\capitalisefmtwords{{}\textcolor{red}{a} small book of
{}\textcolor{red}{rhyme}}.
\medskip
If possible provide semantic command instead.
\begin{verbatim}
\newcommand*{\alert}[1]{\textcolor{red}{#1}}
\capitalisefmtwords{\alert{a} small book of \alert{rhyme}}.
\end{verbatim}
\newcommand*{\alert}[1]{\textcolor{red}{#1}}
\capitalisefmtwords{\alert{a} small book of \alert{rhyme}}.
\medskip
No formatting commands in the following example:
\verb|\capitalisefmtwords{a small book of rhyme}.|
\capitalisefmtwords{a small book of rhyme}.
\medskip
Avoid scoped declarations. The next example doesn't work.
\begin{verbatim}
\capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.}
\end{verbatim}
\capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.}
\medskip
If a command isn't followed by a grouped argument, the
case-change is applied to the command (on the assumption
that it's a character command, such as \verb|\ae|). This can
have an odd effect if case-changing has no meaning for that command.
As illustrated next:
\verb|\capitalisefmtwords{\relax a book of rhyme.}|
\capitalisefmtwords{\relax a book of rhyme.}
\section{Title Case (No Formatting)}
\bgroup
\verb|\capitalisewords{the wind in the willows}|
\capitalisewords{the wind in the willows}
\verb|\capitalisewords{a small book of rhyme.}|
\capitalisewords{a small book of rhyme.}
\medskip
\verb|\space| isn't considered a word boundary for
\verb|\capitalisewords| as shown below:
\begin{verbatim}
\capitalisewords{a small\space book of rhyme.}
\end{verbatim}
\capitalisewords{a small\space book of rhyme.}
\medskip
No expansion is performed on the argument of
\verb|\capitalisewords|:
\verb|\newcommand{\mytitle}{a small\space book of rhyme.}|
\newcommand{\mytitle}{a small\space book of rhyme.}
\verb|\capitalisewords{\mytitle}|
\capitalisewords{\mytitle}
\verb|\xcapitalisewords{\mytitle}|
\xcapitalisewords{\mytitle}
\egroup
\end{document}
|