3

I like to show the index in the table of contents. The index shall be shown like a section, it is including the section number and then the section name. Also the same when the index is printed at the end of the document. The index shall be printed like a section with section number and a horizontal line under it from left to right.

Here I call the index = "Sache" to have a differentiation to the standard.

What is the best way to do that ?

Thank you and with best regards, Timo

\documentclass[twoside]{article} % Packages required by doxygen \usepackage{calc} \usepackage{doxygen} \usepackage{graphicx} \usepackage[utf8]{inputenc} \usepackage{makeidx} \usepackage[xindy]{imakeidx}% \usepackage{multicol} \usepackage{multirow} \usepackage{textcomp} \usepackage[table]{xcolor} % Font selection \usepackage[T1]{fontenc} \usepackage{mathptmx} % similar to Times New Roman \usepackage[scaled=.90]{helvet} % \usepackage{courier} % \usepackage{amssymb} \usepackage{sectsty} \renewcommand{\familydefault}{\sfdefault} % % generate the index \renewcommand{\indexname}{Sache} \makeindex \usepackage{geometry} \geometry{% a4paper} \fancypagestyle{plain} \usepackage{titletoc} \usepackage{titlesec} % % start every section (in "article" / chapter in "report") with/at a new page \let\stdsection\section \renewcommand{\section}{\newpage\stdsection} % % define how deep the numbering of the table-of-contents can be \setcounter{tocdepth}{5} \setcounter{secnumdepth}{5} % %================================ C O N T E N T S \begin{document} %--- End generated contents by doxygen --- \section{Sache} \addcontentsline{toc}{section}{Sache} % print out the index at the end of the document \printindex % %================================================================================ % \label{lastpage} % get a label for the last page to be printed in the footer % % print for test purpose the total number of page(s) {last page : } \pageref{lastpage} % \end{document} 
2
  • Please make your document compilable! Index 'section' headers etc. normally don't have numbers Commented May 19, 2015 at 14:18
  • 1
    There is no point in using makeidx and imakeidx together! Commented May 19, 2015 at 15:27

1 Answer 1

3

Since imakeidx package is used, the intoc option to the \makeindex command should work!

For the appearance as section instead of of unnumbered \section* use the level=\section option of \indexsetup, for the horizontal rule use \indexprologue for example.

Some notes:

  • \renewcommand{\section}{...} looks weird in this context.
  • I had to comment out doxygen and \fancypagestyle{plain}

\documentclass[twoside]{article} % Packages required by doxygen \usepackage{calc} %\usepackage{doxygen} \usepackage{graphicx} \usepackage[utf8]{inputenc} %\usepackage{makeidx} useless in conjunction with imakeidx \usepackage[xindy]{imakeidx}% \usepackage{multicol} \usepackage{multirow} \usepackage{textcomp} \usepackage[table]{xcolor} \makeatletter %\def\imki@indexlevel{\section} \makeatother % Font selection \usepackage[T1]{fontenc} \usepackage{mathptmx} % similar to Times New Roman \usepackage[scaled=.90]{helvet} % \usepackage{courier} % \usepackage{amssymb} \usepackage{sectsty} \renewcommand{\familydefault}{\sfdefault} % % generate the index \renewcommand{\indexname}{Sache} \indexsetup{level=\section} \indexprologue{\hrule} \makeindex[intoc] \usepackage{geometry} \geometry{% a4paper} %\fancypagestyle{plain} \usepackage{titletoc} \usepackage{titlesec} \usepackage{xpatch} % % start every section (in "article" / chapter in "report") with/at a new page %\let\stdsection\section %\renewcommand{\section}{\newpage\stdsection} \xpretocmd{\section}{\clearpage}{}{} % % define how deep the numbering of the table-of-contents can be \setcounter{tocdepth}{5} \setcounter{secnumdepth}{5} % %================================ C O N T E N T S \begin{document} \tableofcontents %--- End generated contents by doxygen --- \section{Sache} %\addcontentsline{toc}{section}{Sache} % print out the index at the end of the document \printindex % %================================================================================ % \label{lastpage} % get a label for the last page to be printed in the footer % % print for test purpose the total number of page(s) {last page : } \pageref{lastpage} % \end{document} 

enter image description here

2
  • Hello and thank you for your answer and time ! But, I don't make use of the imakeidx package , it is an error I have removed it. Do you think there is a way to do it with the makeidx package only ? What I get is a section headline called "Sache", plus an index (without numbering). Could I for example remove the index headline "Index" and start the index content directly after the section "Sache" ? Commented May 20, 2015 at 8:03
  • According to your example you use imakeidx, not makeidx. And your editing/transforming your question away from the original version, leaving all my efforts useless. imakeidx is the better package, believe me Commented May 20, 2015 at 11:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.