I would like to capitalize the first letter of several words in the chapter and the chapter mark. While text in the chapter itself is capitalized, in the chapter mark it is not.
Here is a MWE of my current code:
\documentclass{book}
\usepackage{mfirstuc,fancyhdr,lipsum}
\fancypagestyle{mainmatter}{%
\fancyhf{}
\fancyhead[LE]{\thepage}
\fancyhead[RO]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}
}
\begin{document}
\pagestyle{mainmatter}
\chapter{\ecapitalisewords{some thing} with Text}
\lipsum[1-5]
\end{document}
How can I make fancyhdr
work with \ecapitalisewords
?
EDIT:
I noticed that \nouppercase
kills \MakeUppercase
\def\nouppercase##1{{\let\uppercase\relax\let\MakeUppercase\relax
\expandafter\let\csname MakeUppercase \endcsname\relax##1}}%
which however is needed by \ecapitalisewords
which uses
\def\@gls@makefirstuc#1{\MFUapplytofirst\mfirstucMakeUppercase{#1}}
\newcommand*{\mfirstucMakeUppercase}{\MakeUppercase}
I further notices, that fancyhdr.sty
defines \chaptermark
with \MakeUppercase
.
For this reason, I tried
\documentclass{book}
\usepackage{mfirstuc,fancyhdr,lipsum}
\fancypagestyle{mainmatter}{%
\fancyhf{}
\fancyhead[LE]{\thepage}
\fancyhead[RO]{\thepage}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
}
%
\let\orgMakeUppercase\MakeUppercase
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\chaptermark}{\MakeUppercase}{}{}{}
\xpatchcmd{\sectionmark}{\MakeUppercase}{}{}{}
\xpatchcmd{\@gls@makefirstuc}{\mfirstucMakeUppercase}{\orgMakeUppercase}{}{}
\makeatother
\begin{document}
\pagestyle{mainmatter}
\chapter{\ecapitalisewords{some thing} with Text}
\lipsum[1-5]
\end{document}
But without success, the chaptermark is this time ALL CAPITAL, meaning the patching did not seem to work to being with.