If I want to use the babel
package and redefine a macro such as \contentsname
, what is the right way to go about this? Just putting \renewcommand
in the preamble doesn't work.
This sort of works
\documentclass{article}
\usepackage[english]{babel}
\AtBeginDocument{%
\renewcommand\contentsname{Foo}%
}
\begin{document}
% \selectlanguage{english}
\tableofcontents
\end{document}
but if you uncomment the \selectlanguage{english}
, the definition is undone.
The best I could come up with is to use the following.
\usepackage{etoolbox}
\patchcmd\captionsenglish{Contents}{Foo}{}{}
Best Answer
Use
\addto\captionsenglish
.EDIT: See e.g p. 78 of the babel documentation, where the definitions are changed for the Esperanto language (
\addto\captionsesperanto
).