TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question
up vote 5 down vote accepted

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
\addto\captionsgreek{\typeout{foo}\renewcommand{\contentsname}{\MakeUppercase\mtcontentsname}}

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}

enter image description here

share|improve this answer
    
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}
share|improve this answer
    
It doesn't change anything... :/ – Adam Feb 14 at 21:05
1  
@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
    
+1 Thanks for your answer :) – Adam Feb 14 at 22:02
    
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}

enter image description here

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}}}%
}

\addto\captionsgreek{%
  \upcasebabellabel\contentsname
  \upcasebabellabel\listfigurename
  \upcasebabellabel\listtablename
  \upcasebabellabel\abstractname
}
\addto\captionsenglish{%
  \upcasebabellabel\abstractname
}
share|improve this answer
    
+1 That works out of the box without tinkering! – Adam Feb 14 at 22:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.