# Title Case containing math

I have ben using the \xcapitalisefmtwords from the mfirstuc package (mentioned in the questions in the References section). However, that fails if the content contain any math content.

Is there any easy way to disable the parsing of any math?

## Code:

\documentclass{article}
\usepackage{amsfonts}

\usepackage{mfirstuc}
\newcommand{\TitleCase}[1]{\xcapitalisefmtwords{#1}}%

\begin{document}
\TitleCase{hello world}

%\MFUnocap{$\mathbb{C}$}%
\TitleCase{hello $\mathbb{C}$ world}%  <-- How do I get this to work

Desired Output: Hello $\mathbb{C}$ World
\end{document}

• \TitleCase{hello\ \ensuremath{\mathbb{C}} world} works for me. – ferahfeza Jul 22 '19 at 20:16
• @ferahfeza: Thanks. I have tried to forget about \ensuremath since someone very knowledgable on this site scolded :-) me for it many years ago!! – Peter Grill Jul 22 '19 at 20:20
• Your welcome :-). Did he/she say we shouldn't use the ensuremath command? – ferahfeza Jul 22 '19 at 20:24
• @ferahfeza: See When not to use \ensuremath for math macro?. You should consider posting an answer. Not sure if there are any other lurking issues with your solution, but seems to work fine. I came up with a more of hack solution, but will hold of posting that until later. – Peter Grill Jul 22 '19 at 20:26
• Thank you. I am not a TeXpert, so I cannot explain the validity of the solution and investigate conflicts, if there is. – ferahfeza Jul 22 '19 at 20:33

\documentclass{article}
\usepackage{amsfonts}

\usepackage{mfirstuc}
\newcommand{\TitleCase}[1]{\xcapitalisefmtwords{#1}}%

\protected\def\Cb{$\mathbb{C}$}
\begin{document}
\TitleCase{hello world}

%\MFUnocap{$\mathbb{C}$}%
\TitleCase{hello {\Cb} world}%  <-- How do I get this to work

Desired Output: Hello $\mathbb{C}$ World
\end{document}


• Two questions on this solution - is \protected necessary and is there a reason to use {\Cb} rather than, say \Cb\  ? – John Jul 22 '19 at 22:19
• @John I know nothing about the package I just guessed, but \Cb\ world does not result in a capital W, whether by design or bug I can not say, {\Cb} world does result in W – David Carlisle Jul 22 '19 at 22:21
• Ah ... I overlooked the w ! Thanks. – John Jul 22 '19 at 22:22
• Why is the \mathbb{C} smaller than the surrounding uppercase letters? – barbara beeton Jul 23 '19 at 15:54