Debian Codegraph @

texmf-dist/doc/latex/mfirstuc/sample-mfirstuc.tex

raw
1 % This file is public domain
2 % If you want to use arara, you need the following directive:
3 % arara: pdflatex: { synctex: on }
4 % arara: pdflatex: { synctex: on }
5 \documentclass{article}
6
7 \usepackage[a4paper]{geometry}
8 \usepackage{color}
9 \usepackage{mfirstuc-english}% also loads mfirstuc.sty
10 \usepackage[hidelinks]{hyperref}
11
12 \title{Sample Document Illustrating the mfirstuc Package}
13 \author{Nicola Talbot}
14
15 \begin{document}
16 \maketitle
17
18 \tableofcontents
19
20 \section{Sentence Case (First Letter Upper Case)}
21 \label{sec:sentencecase}
22
23 \verb|\MFUsentencecase{abc}.|
24 \MFUsentencecase{abc}.
25
26 \verb|\MFUsentencecase{{\em abc}}.|
27 \MFUsentencecase{{\em abc}}.
28
29 \verb|\MFUsentencecase{\emph{abc}}.|
30 \MFUsentencecase{\emph{abc}}.
31
32 \verb|\MFUsentencecase{\ae bc}.|
33 \MFUsentencecase{\ae bc}.
34
35 \verb|\MFUsentencecase{{\ae}bc}.|
36 \MFUsentencecase{{\ae}bc}.
37
38 \verb|\newcommand{\abc}{abc}\MFUsentencecase{\abc}.|
39 \newcommand{\abc}{abc}%
40 \MFUsentencecase{\abc}.
41
42 \verb|\MFUsentencecase{\ref{sec:sentencecase}bc}.|
43 \MFUsentencecase{\ref{sec:sentencecase}bc}.
44
45 \verb|\makefirstuc| doesn't expand its argument and skips exclusions.
46
47 \verb|\makefirstuc{abc}.|
48 \makefirstuc{abc}.
49
50 \verb|\makefirstuc{{\em abc}}.|
51 \makefirstuc{{\em abc}}.
52
53 \verb|\makefirstuc{\emph{abc}}.|
54 \makefirstuc{\emph{abc}}.
55
56 \verb|\makefirstuc{\ref{sec:sentencecase}bc}.|
57 \makefirstuc{\ref{sec:sentencecase}bc}.
58
59 \newcommand{\strong}[1]{\textcolor{red}{#1}}
60 \verb|\makefirstuc{\strong{abc}d}|
61 \makefirstuc{\strong{abc}d}
62
63 \verb|\makefirstuc{\protect\strong{abc}d}|
64 \makefirstuc{\protect\strong{abc}d}
65
66 Exclusions vs blockers:
67
68 \verb|\MFUsentencecase{\NoCaseChange{abc} xyz}|
69 \MFUsentencecase{\NoCaseChange{abc} xyz}
70
71 \verb|\makefirstuc{\NoCaseChange{abc} xyz}|
72 \makefirstuc{\NoCaseChange{abc} xyz}
73
74 \begingroup
75 \verb|\MFUblocker{\NoCaseChange}\makefirstuc{\NoCaseChange{abc} xyz}|
76 \MFUblocker{\NoCaseChange}\makefirstuc{\NoCaseChange{abc} xyz}
77
78 \endgroup
79
80 \section{Title Case (No Formatting Commands)}
81
82 \bgroup
83
84 \verb|\capitalisewords{the wind in the willows}|
85 \capitalisewords{the wind in the willows}
86
87 \verb|\capitalisewords{a small book of rhyme.}|
88 \capitalisewords{a small book of rhyme.}
89
90 \medskip
91
92 \verb|\space| isn't considered a word boundary for
93 \verb|\capitalisewords| as shown below:
94
95 \begin{verbatim}
96 \capitalisewords{a small\space book of rhyme.}
97 \end{verbatim}
98 \capitalisewords{a small\space book of rhyme.}
99
100 \medskip
101 No expansion is performed on the argument of
102 \verb|\capitalisewords|:
103
104 \verb|\newcommand{\mytitle}{a small book of rhyme.}|
105 \newcommand{\mytitle}{a small book of rhyme.}
106
107 \verb|\capitalisewords{\mytitle}|
108 \capitalisewords{\mytitle}
109
110 \verb|\xcapitalisewords{\mytitle}|
111 \xcapitalisewords{\mytitle}
112
113 \egroup
114
115 Formatting for the entire phrase must go outside
116 \verb|\capitalisewords| (unlike \verb|\makefirstuc|). Compare:
117
118 \begin{verbatim}
119 \capitalisewords{\textbf{a small book of rhyme.}}
120 \end{verbatim}
121 \capitalisewords{\textbf{a small book of rhyme.}}
122
123 \begin{verbatim}
124 \textbf{\capitalisewords{a small book of rhyme.}}
125 \end{verbatim}
126 \textbf{\capitalisewords{a small book of rhyme.}}
127
128 \medskip
129
130 Use \verb|\capitalisefmtwords| instead. The starred form
131 is limited to one text-block command at the start of the argument.
132
133 \begin{verbatim}
134 \capitalisefmtwords*{\emph{a small book of rhyme}}
135 \end{verbatim}
136 \capitalisefmtwords*{\emph{a small book of rhyme}}
137
138 Additional text-block commands can cause unexpected results.
139
140 \begin{verbatim}
141 \capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}}
142 \end{verbatim}
143 \capitalisefmtwords*{\emph{a small} book \textbf{of rhyme}}
144
145 \section{Title Case (Contains Text-Block Formatting Commands)}
146
147 The unstarred form of \verb|\capitalisefmtwords| is still a bit
148 experimental and is only designed
149 for phrases that contain text-block commands with a single
150 argument, which should be a word or sub-phrase.
151
152 \verb|\capitalisefmtwords{\textbf{a small book of rhyme}}.|
153 \capitalisefmtwords{\textbf{a small book of rhyme}}.
154
155 \verb|\capitalisefmtwords{\textbf{a small book} of rhyme}.|
156 \capitalisefmtwords{\textbf{a small book} of rhyme}.
157
158 \verb|\capitalisefmtwords{a \textbf{small book} of rhyme}.|
159 \capitalisefmtwords{a \textbf{small book} of rhyme}.
160
161 \verb|\capitalisefmtwords{\textbf{a} small book of rhyme}.|
162 \capitalisefmtwords{\textbf{a} small book of rhyme}.
163
164 \verb|\capitalisefmtwords{a small book \textbf{of rhyme}}.|
165 \capitalisefmtwords{a small book \textbf{of rhyme}}.
166
167 \medskip
168
169 Be careful of trailing spaces at the end a group. They can confuse
170 things.
171
172 \verb|\capitalisefmtwords{\textbf{a small }book of rhyme}.|
173 \capitalisefmtwords{\textbf{a small }book of rhyme}.
174
175 \verb|\capitalisefmtwords{\textbf{a small book }of rhyme}.|
176 \capitalisefmtwords{\textbf{a small book }of rhyme}.
177
178 \verb|\capitalisefmtwords{\textbf{a small book of }rhyme}.|
179 \capitalisefmtwords{\textbf{a small book of }rhyme}.
180
181 \medskip
182
183 Use semantic commands for things like quotations:
184
185 \begin{verbatim}
186 \newcommand*{\qt}[1]{``#1''}
187 \capitalisefmtwords{\qt{a small book of rhyme.}}
188 \end{verbatim}
189 \newcommand*{\qt}[1]{``#1''}
190 \capitalisefmtwords{\qt{a small book of rhyme.}}
191
192 \smallskip
193
194 (But make them robust if you intend using commands like
195 \verb|\ecapitalisefmtwords|.)
196 Similarly for other types of punctuation:
197 \begin{verbatim}
198 \newcommand*{\esq}[1]{'?#1?}
199 \capitalisefmtwords{\esq{D\'onde est\'a libro}}
200 \end{verbatim}
201 \newcommand*{\esq}[1]{?`#1?}
202 \capitalisefmtwords{\esq{D\'onde est\'a libro}}
203
204 \medskip
205
206 Anything more complicated than a simple one-argument text-block
207 command requires the starred version.
208
209 \begin{verbatim}
210 \newcommand*{\swap}[2]{{#2}{#1}}
211 \capitalisefmtwords*{\textbf{an \swap{un}{usually} small book of} rhyme}.
212 \end{verbatim}
213 \newcommand*{\swap}[2]{{#2}{#1}}
214 \capitalisefmtwords*{\textbf{an \swap{un}{usually} small book of} rhyme}.
215
216 \medskip
217
218 Nested text-block commands:
219
220 \begin{verbatim}
221 \capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}.
222 \end{verbatim}
223 \capitalisefmtwords{\textbf{a \emph{small book} of} rhyme}.
224
225 \begin{verbatim}
226 \capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}.
227 \end{verbatim}
228 \capitalisefmtwords{\textbf{a \emph{small book}} of rhyme}.
229
230 \begin{verbatim}
231 \capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}.
232 \end{verbatim}
233 \capitalisefmtwords{\textbf{\emph{a small} book of} rhyme}.
234
235 \medskip
236
237 An empty brace at the start of a word will suppress the
238 case-changing.
239
240 \begin{verbatim}
241 \capitalisefmtwords{\textbf{a small {}book of} rhyme}.
242 \end{verbatim}
243 \capitalisefmtwords{\textbf{a small {}book of} rhyme}.
244
245 \medskip
246
247 Suppress case-changing for problematic commands by inserting
248 an empty group in front:
249
250 \begin{verbatim}
251 \capitalisefmtwords{{}\textcolor{red}{a} small book of
252 {}\textcolor{red}{rhyme}}.
253 \end{verbatim}
254 \capitalisefmtwords{{}\textcolor{red}{a} small book of
255 {}\textcolor{red}{rhyme}}.
256
257 \medskip
258
259 If possible provide semantic command instead.
260
261 \begin{verbatim}
262 \newcommand*{\alert}[1]{\textcolor{red}{#1}}
263 \capitalisefmtwords{\alert{a} small book of \alert{rhyme}}.
264 \end{verbatim}
265 \newcommand*{\alert}[1]{\textcolor{red}{#1}}
266 \capitalisefmtwords{\alert{a} small book of \alert{rhyme}}.
267
268 \medskip
269
270 No formatting commands in the following example:
271
272 \verb|\capitalisefmtwords{a small book of rhyme}.|
273 \capitalisefmtwords{a small book of rhyme}.
274
275 \medskip
276
277 Avoid scoped declarations. The next example doesn't work.
278
279 \begin{verbatim}
280 \capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.}
281 \end{verbatim}
282 \capitalisefmtwords{{\bfseries a \emph{small book} of} rhyme.}
283
284 \medskip
285
286 If a command isn't followed by a grouped argument, the
287 case-change is applied to the command (on the assumption
288 that it's a character command, such as \verb|\ae|). This can
289 have an odd effect if case-changing has no meaning for that command.
290 As illustrated next:
291
292 \verb|\capitalisefmtwords{\relax a book of rhyme.}|
293 \capitalisefmtwords{\relax a book of rhyme.}
294
295 \section{Compound Words}
296
297 Use \verb|\MFUhyphentrue| to title case each part of
298 a compound word.
299
300 Default:
301 \begin{verbatim}
302 \capitalisewords{a fast-paced book of rhyme}.
303 \capitalisefmtwords{a \textbf{fast-paced} book of rhyme}.
304 \end{verbatim}
305 \capitalisewords{a fast-paced book of rhyme}.
306 \capitalisefmtwords{a \textbf{fast-paced} book of rhyme}.
307
308 Compare with
309 \begin{verbatim}
310 \MFUhyphentrue
311 \capitalisewords{a fast-paced book of rhyme}.
312 \capitalisefmtwords{a \textbf{fast-paced} book of rhyme}.
313 \end{verbatim}
314 \MFUhyphentrue
315 \capitalisewords{a fast-paced book of rhyme}.
316 \capitalisefmtwords{a \textbf{fast-paced} book of rhyme}.
317
318 \end{document}