General ⇒ Capitalizing the first letter of each word
Capitalizing the first letter of each word
Hi everyone,
Does anyone know if there is a package that allows you the capitalize the first letter of each word in a sentence?
For example:
\Capitalize{hello world} would yield: "Hello World"
I've searched CTAN and the rest of the web but I couldn't find anything.
Maybe someone could write a macro that does this?
Thanks in advance!
Regards,
-Gorecki
Does anyone know if there is a package that allows you the capitalize the first letter of each word in a sentence?
For example:
\Capitalize{hello world} would yield: "Hello World"
I've searched CTAN and the rest of the web but I couldn't find anything.
Maybe someone could write a macro that does this?
Thanks in advance!
Regards,
-Gorecki
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Capitalizing the first letter of each word
Where is the sense behind this? Are the text passages so long that you can't do that by hand? I know you expected answers, but i'm afraid there is no such automatism.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Capitalizing the first letter of each word
The idea was to combine this with hyperref's \autoref.
I want to define something like:
\newcommand{\Autoref}[1]{\Capitalize{\autoref{#1}}}}
And then I could use \Autoref at the beginning of sentences and \autoref elsewhere.
Is there really no way to do this?
Possibly using some kind of subspring functions?
eg:
\Uppercase{\left{1}{string}} ---> "String"
Any ideas?
I want to define something like:
\newcommand{\Autoref}[1]{\Capitalize{\autoref{#1}}}}
And then I could use \Autoref at the beginning of sentences and \autoref elsewhere.
Is there really no way to do this?
Possibly using some kind of subspring functions?
eg:
\Uppercase{\left{1}{string}} ---> "String"
Any ideas?
-
- Posts: 2
- Joined: Fri May 07, 2010 12:15 pm
Capitalizing the first letter of each word
Although this thread is pretty old, a solution would be to use the mfirstuc package.
Capitalizing the first letter of each word
Thanks sschuberth! It was worth posting an answer even 3 years later since there could always be people asking themselves the same question 3 years later, like me 
Unfortunately I didn't manage to get it working in connection with \autoref. Here is a minimal example:
mfirstuc provides xmakefirstuc which is equivalent to \expandafter\makefirstuc\expandafter{...}. In the "Hello World" example sentence you can see that this doesn't work anymore if the expanded command is again a command. That's why I defined further commands xxmakefirstuc and xxxmakefirstuc.
I assumed that the reason why it doesn't work with \autoref is the same. But apparently it doesn't work with xmakefirstuc nor with xxmakefirstuc nor with xxxmakefirstuc
Does someone have any idea what could be the problem with autoref? Why does it work with the \wa etc. commands but not with \autoref?

Unfortunately I didn't manage to get it working in connection with \autoref. Here is a minimal example:
Code: Select all
\documentclass{article}
\usepackage{mfirstuc}
\usepackage{hyperref}
\newcommand{\wa}{world}
\newcommand{\wb}{\wc}
\newcommand{\wc}{\wb}
\newcommand{\xxmakefirstuc}[1]{\expandafter\xmakefirstuc\expandafter{#1}}
\newcommand{\xxxmakefirstuc}[1]{\expandafter\xxmakefirstuc\expandafter{#1}}
\begin{document}
\section{Introduction}\label{sec:intro}
Try to force capitalized autoref.
\section{Example}
An example referring to \autoref{sec:intro}. Hello \xxxmakefirstuc{\wa}.
\xxxmakefirstuc{\autoref{sec:intro}} references should sometimes be capitalized.
\end{document}
I assumed that the reason why it doesn't work with \autoref is the same. But apparently it doesn't work with xmakefirstuc nor with xxmakefirstuc nor with xxxmakefirstuc

Does someone have any idea what could be the problem with autoref? Why does it work with the \wa etc. commands but not with \autoref?