The method to change the name of the contents while using the babel package
is described here.
Per the answer included in the link, the following code may be used:
\documentclass{article}
\usepackage[american]{babel}
\addto\captionsamerican{%
\renewcommand{\contentsname}%
{newContentsName}%
}
\begin{document}
\tableofcontents
\section{Section}
\subsection{Subsection}
\end{document}
If I wanted to use a variable for the language, I thought I could make the following adjustment:
\documentclass{article}
\newcommand{\xLanguage}{american} % <-- Added this command
\usepackage[\xLanguage]{babel} % <-- Implemented here
\addto\csname captions\xLanguage\endcsname{% <-- and here
\renewcommand{\contentsname}%
{newContentsName}%
}
\begin{document}
\tableofcontents
\section{Section}
\subsection{Subsection}
\end{document}
But this does not work.
Am I approaching this correctly?
