2

If been trying to change the name of my table of contents. I've put this in my preamble:

\renewcommand\contentsname{Table of Contents}

I also tried to put it after the \tableofcontents command, but both times nothing is happening. I don't get an error or something, but the name isn't changed. Can someone help me out?

\documentclass[fleqn,10pt]{wlscirep}
\usepackage{float}
\usepackage{microtype}
\begin{document}
\tableofcontents
\renewcommand\contentsname{Table of contents}
Torbjørn T.
  • 206,688
  • Can you please post a minimal working example that compiles, is as small as possible and demonstrates your problem. The solution depends on your documentclass and where you put this line. –  Dec 09 '16 at 09:05
  • Welcome to TeX.SE. Which document class do you use? (If the macro \contentsname is defined at all, it'll be defined in the document class file.) Please also be more specific as to what exactly "nothing is happening" means. What is currently typeset at the top of the table of contents? – Mico Dec 09 '16 at 09:07
  • 1
    (1) welcome, (2) in addition to Andrews comment, a macro like \contentsname is often controlled by the babel package, so it has to be changed in a very specific manner – daleif Dec 09 '16 at 09:08
  • 1
    See http://tex.stackexchange.com/questions/82993/. I don't know your setup, but there you'll find information specific to various documentclasses, and for documents using babel/polyglossia, as @daleif mentioned. – Torbjørn T. Dec 09 '16 at 10:36
  • Thank you for responding. With 'nothing is happening' I mean that the command I've put in doesn't change the name. This is my working example: \documentclass[fleqn,10pt]{wlscirep} \usepackage(float) \usepackage(microtype) \begin{document} \tableofcontents \renewcommand\contentsname{Table of contents} – Justine Hoek Dec 10 '16 at 16:20
  • And I don't use a babel package – Justine Hoek Dec 10 '16 at 16:27
  • 1
    Please add code examples to your question instead of comments, comments are not really suited for blocks of code. I added your snippet, and replaced the () for the \usepackage lines with {} (assume it was a typo). Are you really adding the \renewcommand after \tableofcontents? If so, move it to before \tableofcontents. – Torbjørn T. Dec 11 '16 at 09:25

2 Answers2

2

The obvious problem with the code snippet you show is that you're changing the definition of \contentsname after it has been used, so the redefinition naturally doesn't have any effect.

Hence, instead of

\tableofcontents
\renewcommand\contentsname{Table of contents}

you need

\renewcommand\contentsname{Table of contents}
\tableofcontents

However, you say that you've added the \renewcommand to the preamble. If you have the same version of wlscirep.cls as is found on Overleaf, you are in fact using babel, as the class contains the line

\RequirePackage[english]{babel}

When you do the redefinition after \begin{document}, it still works. But if you want the redefinition to be in the preamble (before \begin{document}), you need

\addto\captionsenglish{%
 \renewcommand\contentsname{Table of contents}
 }
Torbjørn T.
  • 206,688
0

Try to put the command in this way.

 \begin{document}
 \author{Namef}
  \title{Title of Thesis}
  \date{December 2016}
   \frontmatter

    \renewcommand*\contentsname{Table of Contents}

     \maketitle
      \tableofcontents
Ahmed Arif
  • 1,345