# Correctly add custom table of content item [duplicate]

Possible Duplicate:

I want to add a custom section to my table of contents. I know I can use addcontentsline{toc}{section}{title}. However, it doesn't use correct reference. When clicking on the item in the toc, it just jumps to the wrong section.

MWE:

\documentclass[a4paper]{scrartcl}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{nameref}
\usepackage{makeidx}

\makeindex

\begin{document}
\tableofcontents

\section{Section 1}
\index{bla}. \index{blub}.
\section{Section 2}

\printindex
\end{document}


To compile, run:

pdflatex file.tex
makeindex file
pdflatex file.tex
pdflatex file.tex


When clicking on Index it jumps to "2 Section 2" instead of "Index".

-
 Issue \clearpage\phantomsection\addcontentsline{toc}{section}{Index}\printindex. – Werner Jun 15 '12 at 23:06 \usepackage[nottoc]{tocbibind} takes care of the matter without any \addcontentsline command. – egreg Jun 15 '12 at 23:08 Is tocbibind good for KOMA class as well? – cherrung Jun 15 '12 at 23:27

## marked as duplicate by egreg, percusse, Werner, Gonzalo Medina, Marco DanielJun 16 '12 at 7:04

Since you are using one of the KOMA-Script document classes, all you have to do is to add the index=totoc class option:

\documentclass[a4paper,index=totoc]{scrartcl}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{nameref}
\usepackage{makeidx}

\makeindex

\begin{document}
\tableofcontents

\section{Section 1}
\index{bla}. \index{blub}.
\section{Section 2}

\printindex
\end{document}

-