General ⇒ Capitalizing the first letter of each word
Capitalizing the first letter of each word
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.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Capitalizing the first letter of each word
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Capitalizing the first letter of each word
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
Capitalizing the first letter of each word

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?