# Correctly add custom table of content item [duplicate]

Possible Duplicate:
Index is incorrectly listed in the table of contents

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[pdftex,bookmarks=true,bookmarksnumbered,colorlinks=true]{hyperref} % http://ctan.org/pkg/hyperref
\usepackage{nameref}
\usepackage{makeidx}

\makeindex

\begin{document}
\tableofcontents

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

\addcontentsline{toc}{section}{Index}
\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".

-

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

## 1 Answer

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[pdftex,bookmarks=true,bookmarksnumbered,colorlinks=true]{hyperref} % http://ctan.org/pkg/hyperref
\usepackage{nameref}
\usepackage{makeidx}

\makeindex

\begin{document}
\tableofcontents

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

\printindex
\end{document}

-