I have generated a Table of Contents in a document and I would like to make the title "Contents" in uppercase letters, i.e. "CONTENTS". All I have found searching was how to customize the entries in the table and not the title. How can this be done?

I work in ShareLaTeX with XeLaTeX and my full preamble is:

\documentclass{article}

\usepackage
[
top=0.7in,
bottom=1.2in,
left=0.8in,
right=0.8in,
]{geometry}

\usepackage{parskip}

\setlength{\parindent}{0cm}

\usepackage{amsmath}

\usepackage{unicode-math}

\usepackage{fontspec}

\usepackage[english,greek]{babel}

\setmainfont
[
Ligatures=TeX,
Extension=.otf,
UprightFont=*,
BoldFont=*Bold,
ItalicFont=*It,
BoldItalicFont=*BoldIt,
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}

\usepackage{listings}

\usepackage{multicol}

\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

\usepackage{tikz}

\usepackage{lipsum}

\usepackage{hyperref}

\usepackage[normalem]{ulem}

\usepackage{mdframed}

-

Normally touhami's solution should work, but the special babel settings prevent his solution.

In this case, the redefinition of the \contentsname should be shifted after \begin{document} -- this can be done with \AtBeginDocument{...}.

Another possibility should be the \addto... way. I'll try to provide this as well.

Alternatively, say

\selectlanguage{greek}
\let\mtcontentsname\contentsname


in the preamble.

I believe, using polyglossia is the better variant in conjunction with XeLaTeX instead of babel.

\documentclass{article}

\usepackage
[
top=0.7in,
bottom=1.2in,
left=0.8in,
right=0.8in,
]{geometry}

\usepackage{parskip}

\setlength{\parindent}{0cm}

\usepackage{amsmath}

\usepackage{unicode-math}

\usepackage{fontspec}

\usepackage[english,greek]{babel}

\setmainfont
[
Ligatures=TeX,
Extension=.otf,
UprightFont=*,
BoldFont=*Bold,
ItalicFont=*It,
BoldItalicFont=*BoldIt,
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}

\usepackage{listings}

\usepackage{multicol}

\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

\usepackage{tikz}

\usepackage{lipsum}

\usepackage{hyperref}

\usepackage[normalem]{ulem}

\usepackage{mdframed}

\AtBeginDocument{%
\let\mtcontentsname\contentsname
\renewcommand\contentsname{\MakeUppercase\mtcontentsname}
}
\begin{document}

\tableofcontents
\section{Foo}
\end{document}


-
Exactly the same as before. There is no problem but not any result either... :/ – Adam Feb 14 at 21:59
@Adam: Well, you should only a preamble, but not anything shortly after the \begin{document}. Either there is the culprit or some other setting is completely wrong. Hard to tell without any code – Christian Hupfer Feb 14 at 22:00
Ok then as you have checked that this works I believe that it will work for me too eventually. Thank you very much for your effort. – Adam Feb 14 at 22:02

Here is

\documentclass{article}
\let\mtcontentsname\contentsname
\renewcommand\contentsname{\MakeUppercase\mtcontentsname}
\begin{document}
\tableofcontents

\end{document}

-
It doesn't change anything... :/ – Adam Feb 14 at 21:05
@Adam: If touhami's solution does not work for you because you have a peculiar setup you should provide more information. – Christian Hupfer Feb 14 at 21:18
@ChristianHupfer I provided my full setup. – Adam Feb 14 at 21:47
Sorry, I did not mean to steal the tick – Christian Hupfer Feb 14 at 22:08

The simplest way is to patch \tableofcontents so that it prints the title uppercase:

\documentclass{article}

\usepackage{amsmath}
\usepackage{unicode-math}

\usepackage[english,greek]{babel}
\usepackage{etoolbox} % for \patchcmd

\setmainfont[
Ligatures=TeX,
Extension=.otf,
UprightFont=*,
BoldFont=*Bold,
ItalicFont=*It,
BoldItalicFont=*BoldIt,
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}

\patchcmd{\tableofcontents}{\contentsname}{\MakeUppercase\contentsname}{}{}

\begin{document}

\tableofcontents

\section{ενότητα τίτλο}

\subsection{ενότητα τίτλο}

\end{document}


Alternatively, use

\addto\captionsgreek{%
\edef\contentsname{%
\noexpand\MakeUppercase{\unexpanded\expandafter{\contentsname}}%
}%
}


and similarly if you need it for English.

The uppercasing you want is formatting, rather than redefining fixed labels, so the \patchcmd method is better suited. However, it can become complicated if you need to patch several commands.

In this case the \addto method might be preferable and we can provide an abstraction. For instance, let's suppose you also want the list of figures and tables to have uppercased title and also the name for the abstract; the last one should be available in uppercase for both Greek and English.

\newcommand{\upcasebabellabel}[1]{%
\edef#1{\noexpand\MakeUppercase{\unexpanded\expandafter{#1}}}%
}