# Capital part names in book class

This is a follow-up question to the one about the capitalization of chapter names in the book class. Now I would like to make capital the names of book parts in the book class.

Part 1 --> PART 1

I use ShareLaTeX with XeLaTeX.

\documentclass{book}

\usepackage{fontspec}

\usepackage[english,greek]{babel}

\setmainfont
[
UprightFont = *,
BoldFont = *Bold,
ItalicFont = *It,
BoldItalicFont = *BoldIt,
Extension = .otf,
Ligatures = TeX,
Mapping = tex-text
]{GFSArtemisia}

\setsansfont[Mapping = tex-text]{GFSArtemisia.otf}

\setmathfont{latinmodern-math.otf}

\setmathfont[range = \varnothing]{Asana-Math.otf}

\setmathfont[range = \int]{latinmodern-math.otf}

\begin{document}

\end{document}

-
So you haven't even tried using \renewcommand\partname{PART}? If this doesn't work, please provide more information regarding your setup. Some things (like packages or language settings) influence the availability or formatting of sectional units. – Werner Mar 1 at 20:57
@Werner That was the second thing that I tried...The first was very shameful to admit. :P – Adam Mar 1 at 20:59

This should work for some (but not all) languages.

\documentclass{book}

\let\oldpartname\partname

\renewcommand{\partname}{\MakeUppercase{\oldpartname}}

\begin{document}

\part{Foo}

\end{document}


Here's a babel based setup (for some arbitrary languages, say German and Spanish)

\MakeUppercase acts on a stored copy of \partname -- \let\oldpartname\partname generates this copy.

\documentclass{book}
\usepackage[ngerman,spanish]{babel}

\renewcommand{\partname}{\MakeUppercase{\oldpartname}}}

\renewcommand{\partname}{\MakeUppercase{\oldpartname}}}

\begin{document}
\tableofcontents
\otherlanguage{ngerman}
\part{Foo}

\selectlanguage{spanish}
\part{Foobar}

\end{document}

-
This too doesn't work. :/ – Adam Mar 1 at 21:01
@Adam: It would have helped if you would have provided your fontspec related stuff before! – Christian Hupfer Mar 1 at 21:05
Sorry! Now it works. Thank you very much. :) – Adam Mar 1 at 21:07

It's quite simple:

\documentclass{book}

\usepackage{fontspec}

\usepackage[english,greek]{babel}

\setmainfont[
Extension = .otf,
UprightFont = *,
BoldFont = *Bold,
ItalicFont = *It,
BoldItalicFont = *BoldIt,
]{GFSArtemisia}

\setsansfont{GFSArtemisia.otf}

\makeatletter
\protected@edef\partname{\MakeUppercase{\partname}}%
}
\protected@edef\partname{\MakeUppercase{\partname}}%
}
\makeatother

\begin{document}

\part{Τίτλος}

\selectlanguage{english}

\part{Title}

\end{document}


When \selectlanguage{<language>} or \begin{otherlanguage}{<language>} is scanned, LaTeX will process \captions<language> (for instance \captionsgreek). In this phase \partname is set to some language dependent string. With the trick

\protected@edef\partname{\MakeUppercase{\partname}}


we tell LaTeX that \partname is the uppercase version of the just defined string.

Note that \begin{document} executes \selectlanguage{greek} (because this is the last selected language), so everything comes out right.

-
+1 Thank you. Excellent answer. :) – Adam Mar 1 at 22:21