[Tex/LaTex] Changing the title of table of contents in lyx

lyxtable of contents

I've already tried to follow the answer here:
How to change the title of ToC?

by using \renewcommand{\contentsname}{Whatever}

However, it does not seem to work with lyx, neither in the preamble nor as ERT
The package being used is babel.

Please help me solve this problem

Minimum working example of .lyx file:

\pagenumbering{roman} 
\renewcommand{\chaptername}{}

\renewcommand{\thechapter}{\arabic{chapter}}

\renewcommand{\contentsname}{Innholdsfortegnelse}

1. Innledning

\pagenumbering{arabic} 

Heisann

Best Answer

  1. Document > Settings... > Language > Language package: None

  2. Document > Settings... > LaTeX Preamble >

Write:

\usepackage[norsk]{babel}
\addto\captionsnorsk{%
\renewcommand{\contentsname}{Innholdsfortegnelse}}

The result must be the equivalent to this plain LaTeX:

\documentclass{article}
\usepackage[norsk]{babel}
\addto\captionsnorsk{%
\renewcommand{\contentsname}{Innholdsfortegnelse}}
\begin{document}
\tableofcontents
\section{Section}
\end{document}

mwe

If doing this you got a Package babel Error: Unknown languagexxxxx'`:

Mwe

Then, go to View Complete Log ...

mwe

As you can see, this is because there are an \select@language {english} in the .aux file of the previous run. You can remove it manually (in the case of the screenshot in a Linux system it was /tmp/lyx_tmpdir.T23297/lyx_tmpbuf6/newfile6.aux) but you can just click on Close and LyX will clean the auxiliary files for you (at least if there are only this error). In next run it should work.

Related Question