I like to have an introducing text after the index starts (in the same way as it works for the nomenclature).
Adding the imakeidx
package to the here used makeidx
package and writing additionally\indexprologue{\noindent text}
will destroy the page numbering in the TOC. (as I tried with How to add explanatory text to an index page?)
Is this somehow possible?
\synctex=-1
\documentclass[a4paper,latin,fontsize=10pt,headsepline,parskip=half-,index=totoc,DIV=15]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage[normalem]{ulem}
\usepackage{fancybox,calc,etoolbox,lipsum}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{Glossar}
\makenomenclature
\usepackage{scrlayer-scrpage}% scrpage2 is obsolete
\pagestyle{scrheadings}
\clearpairofpagestyles% \clearscrheadings, \clearscrplain are deprecated
\automark[chapter]{chapter}
\renewcommand*\chaptermarkformat{}% uncomment if you don't want chapter numbers in the headers
\ihead[]{\headmark}
\ohead[\pagemark]{\pagemark}
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}
\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{makeidx}
% I need an introducing text before the index
% ......
\makeindex
\makeatletter % needed because I need separation between different items of the same starting character
\def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
\def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
\def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
\def\indexspace{}
\patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother
% write a text before the glossar!
\renewcommand{\nompreamble}{Beachte: Es gibt verschiedene Schokoladen.}
\makenomenclature
\begin{document}
\begin{titlepage}% because I need a custom layout
\centering
\vspace*{10cm}
titlepage
\end{titlepage}
\clearpage\pdfbookmark{\contentsname}{toc}
\tableofcontents\thispagestyle{empty}
\chapter{Einleitung}
\lipsum[1]
\newpage
\lipsum[2]
\newpage
\lipsum[3]
\chapter{Nahrung im Sommer}
\lipsum[4]
\nomenclature{Banane}{Frucht}
\nomenclature{Schokolade}{Suessigkeit \\ meistens 100 g schwer}
\index{book}
\index{summer!sun}
\index{summer!Supersonnenschirm/Supersonnenbad/ \newline Supersandstrum/Supersieg}
\index{summer!heat!sweat}
\index{sound}
\index{tower}
\count255=0
\loop\ifnum\count255<30
\advance\count255 1
\expandafter\index\expandafter{\romannumeral\count255}
\repeat
\newpage{}
\thispagestyle{empty}
\vspace*{\fill}\begin{center} \begin{Huge} Anhang \end{Huge} \vspace*{\fill}\end{center}
\addtocontents{toc}{\textbf{\sffamily \textcolor{white}{empty line}}\protect\par}
\addtocontents{toc}{\textbf{\sffamily \textcolor{white}{empty line}}\protect\par}
\addtocontents{toc}{\textbf{\sffamily Anhang}\protect\par}
\printnomenclature[2.5 cm]
\renewcommand{\indexname}{Stichwortverzeichnis}
\printindex
\end{document}
What is important:
- The page numbering in the TOC should stay the same
- The markup in the TOC should stay the same
- The headings in the document (as you see in first chapter) should stay the same
This question is proceeding to the previous intensive code work: How to solve the page numbering problems (in TOC, hyperref, scrheadings, nomenclature)? How to set the space between two index entries with the same character How to add a tex specific area after the nomenclature title starts?
This is the code I tried from @egreg 's answer below with success:
\documentclass[a4paper,latin,fontsize=10pt,headsepline,parskip=half-,index=totoc,DIV=15]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage[normalem]{ulem}
\usepackage{fancybox,calc,etoolbox,lipsum}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{Glossar}
\makenomenclature
\usepackage{scrlayer-scrpage}% scrpage2 is obsolete
\pagestyle{scrheadings}
\clearpairofpagestyles% \clearscrheadings, \clearscrplain are deprecated
\automark[chapter]{chapter}
\renewcommand*\chaptermarkformat{}% uncomment if you don't want chapter numbers in the headers
\ihead[]{\headmark}
\ohead[\pagemark]{\pagemark}
\renewcommand*\partpagestyle{empty}
\usepackage{imakeidx} % load always before the hyperref package, otherwise it can result in problems!
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}
\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{makeidx}
\makeindex[intoc,title=Stichwortverzeichnis] % no redefining is needed with \renewcommand{\indexname}{Stichwortverzeichnis} before \printindex
\makeatletter % needed because I need separation between different items of the same starting character
\def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
\def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
\def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
\def\indexspace{}
\patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother
% write a text before the glossar!
\renewcommand{\nompreamble}{Whatever you want at the beginning of the nomenclature}
\makenomenclature
\begin{document}
\begin{titlepage}% because I need a custom layout
\centering
\vspace*{10cm}
titlepage
\end{titlepage}
\clearpage\pdfbookmark{\contentsname}{toc}
\tableofcontents\thispagestyle{empty}
\chapter{Einleitung}
\lipsum[1]
\newpage
\lipsum[2]
\newpage
\lipsum[3]
\chapter{Nahrung im Sommer}
\lipsum[4]
\nomenclature{Banane}{Frucht}
\nomenclature{Schokolade}{Suessigkeit \\ meistens 100 g schwer}
\index{book}
\index{summer!sun}
\index{summer!Supersonnenschirm/Supersonnenbad/ \newline Supersandstrum/Supersieg}
\index{summer!heat!sweat}
\index{sound}
\index{tower}
\count255=0
\loop\ifnum\count255<30
\advance\count255 1
\expandafter\index\expandafter{\romannumeral\count255}
\repeat
\cleardoublepage
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
\Huge Anhang
\addtocontents{toc}{%
\protect\addvspace{0.5pc}% <------------- adjust to suit
\textbf{\sffamily Anhang}\protect\par
}
\end{center}
\vspace*{\fill}
\clearpage
\printnomenclature[2.5 cm]
\indexprologue{Whatever you want at the beginning of the index}
\printindex
\end{document}
imakeidx
. Are you? Not that is a different package frommakeidx
. If you are using the latter, try using the commands KOMA provides for defining an index preamble.imakeidx
in addition to themakeidx
and had to do some changes which resulted in creepy toc markups and wrong pagenumbers. So now I'm only using exact the here posted MWE.\setindexpreamble{some text for the preamble of the index}
.\part*{Anhang}
and the ToC commands rather than\newpage\thispagestyle{empty}...
. Just set the page style for parts as shown in my answer to your other question.