2

I'm writing a document in Spanish (with babel), but the name of \tableofcontents is still "Contents". I've tried with \renewcommand{\contentsname}, \addto\captionsspanish and a lot of different combinations but it doesn't work.

I don't know what is happening, because the name of the bibliography is in Spanish, so babel is working properly there.

This is the code I'm using:

\documentclass[11pt,aps,prd,preprintnumbers,nofootinbibn,onecolumn]{revtex4}
\usepackage{graphicx} 
\usepackage{dcolumn}  
\usepackage{bm}       
\usepackage{amssymb}   
\usepackage[utf8x]{inputenc}
\usepackage[spanish]{babel}
\usepackage{shapepar}
\usepackage{amsmath}
\usepackage{array}
\usepackage{fancybox}
\usepackage{multirow}
\usepackage{appendix}
\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{caption}
\usepackage{float}
\usepackage{braket}
\usepackage{amsfonts}
\usepackage{mathrsfs,amsmath}
\usepackage{chemmacros}
\usepackage{bbold}
\usepackage{framed}
\usepackage[usestackEOL]{stackengine}
\usepackage{lipsum}
\usepackage{blindtext}
\usepackage{soul}
\newcommand*\dif{\mathop{}\!\mathrm{d}}
\newcommand*\Dif[1]{\mathop{}\!\mathrm{d^#1}}
\hyphenation{ALPGEN}
\hyphenation{EVTGEN}
\hyphenation{PYTHIA}
\addtolength{\textwidth}{0cm}
\addtolength{\hoffset}{0cm}
\addtolength{\textheight}{1.6cm}
\addtolength{\voffset}{0cm}
\DeclareMathOperator{\Tr}{Tr}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\usepackage{geometry}\geometry{a4paper, total={160mm,247mm}, left=25mm, top=25mm, }
\usepackage{setspace}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\title{\huge{Título}\\[0.4cm]}
\thispagestyle{empty}

\begin{abstract}
\begin{center}
\today\\
\vspace{1cm}

\hspace{1em}{\bf Autor:}\\
\vspace{0.1cm}
\hspace{1em}NAME $^\ddagger$\\
\vspace{0.8cm}
{\it Universidad}\vspace{2em}
\end{center}
\hline\vspace{1em}
{\bf Abstract:} \vspace{-0.5em}
\singlespacing
\small{...}\vspace{2em}\hline \vspace{1em}
\scriptsize{$^\ddagger$  E-mail: \texttt{...}
\end{abstract}

\clearpage
\maketitle

\newpage
\thispagestyle{empty}
\spacing{2}
\begin{quotation}
\tableofcontents
\end{quotation}

\section{Introducción}
\setcounter{page}{1} 

\begin{thebibliography}{99}
\bibitem{1}
...

\end{thebibliography}
\end{document}

Thank you.

TsuKi
  • 41
  • I've already tried that, but it doesn't work, no variation of \renewcommand{\contentsname} seems to change the name in my document. – TsuKi Jan 08 '17 at 10:16
  • Alright, I've a look. Please wrap that long lines with \usepackage{...} at the beginning, that's awful.... You're loading some packages, epsfig is outdated and why manipulating layout parameters whereas you use geometry already? –  Jan 08 '17 at 10:16
  • Sorry, I'm new here ... How do I wrap lines? – TsuKi Jan 08 '17 at 10:19
  • 1
    Using the newline 'enter' key on your keyboard? –  Jan 08 '17 at 10:20
  • Probably some of the commands aren't needed, but the sample for the document was given to me with all of them. They've worked properly other times so I think the problem with \tableofcontents is not there... – TsuKi Jan 08 '17 at 10:25
  • 2
    note size change commands like \small and huge do not take an argument so \small ... not \small{...} commands \bf and \it are deprecated and don't load epsfig unless you need to emulate a document using a package from 1990. – David Carlisle Jan 08 '17 at 10:25
  • Your document's preamble loads quite a few packages that are either deprecated (e.g., subfigure), fully or nearly duplicative (e.g., epsfig, given that you also load graphicx), almost surely unneeded (shapepar -- really?!), or get loaded more than once (e.g., amsmath). The preamble also contains statements that are subsequently overridden by later statements. E.g., why modify \hoffset and \voffset by hand if you then go on to load the geometry package and issue a \geometry statement? Do yourself a big favor and simplify and shorten the document's preamble. – Mico Jan 11 '17 at 00:38

1 Answers1

3

The name of the ToC is stored in \tocname.

Use

\addto\captionsspanish{\renewcommand{\tocname}{Índice}}

instead of \renewcommand{\contentsname}{Índice}}

\documentclass[11pt,aps,prd,preprintnumbers,nofootinbibn,onecolumn]{revtex4}

\usepackage[utf8]{inputenc} 
\usepackage[spanish]{babel} 
\addto\captionsspanish{\renewcommand{\tocname}{Índice}}
\begin{document}
\tableofcontents
\section{Introducción}

\end{document}

I kicked all unnecessary (and wrong content) out of the preamble

enter image description here

  • Ok, it is working now! The name apperas properly adding that command line. Thank you very much! @Christian Hupfer

    Do I need to erase all the other packages? Some of them are needed for math equations...

    – TsuKi Jan 08 '17 at 10:28
  • @TsuKi: Just for shortness. Your document was not compilable at all. –  Jan 08 '17 at 10:29
  • 1
    @TsuKi but only put back the packages that you actually use. It makes no sense at all to have lipsum, blindtext, epsfig in a current math paper and probably not shapepar, stackengine, better to use utf8 than utf8x and only load chemmacros if you are using that chemistry package, etc. – David Carlisle Jan 08 '17 at 11:33
  • 1
    Belated congratulations on passing the 100k rep mark!! – Mico Jan 10 '17 at 15:21
  • Please consider to accept this answer since it was the solution –  Jan 15 '17 at 18:11