4

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}
5
  • In your other comment, you said you were using imakeidx. Are you? Not that is a different package from makeidx. If you are using the latter, try using the commands KOMA provides for defining an index preamble.
    – cfr
    Apr 7, 2015 at 16:51
  • I was using imakeidx in addition to the makeidx 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.
    – laminin
    Apr 7, 2015 at 16:54
  • 1
    Try \setindexpreamble{some text for the preamble of the index}.
    – cfr
    Apr 7, 2015 at 16:56
  • Also, you can just use \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.
    – cfr
    Apr 7, 2015 at 17:00
  • Your setindexpreamble command perfectly works!!
    – laminin
    Apr 7, 2015 at 17:15

2 Answers 2

2

There has to be a better way of writing the ToC line, but still...

\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[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
\setindexpreamble{some text for the preamble of 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

\part*{Anhang}
\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}

index with preamble

0
1

The imakeidx package should be loaded before hyperref.

Then you just need

\makeindex[intoc,title=Stichwortverzeichnis]

and, where you want to print the index,

\indexprologue{Whatever you want at the beginning of the index}
\printindex

(no \renewcommand{\indexname} is needed, because of the title= option).

After these changes to your document, the table of contents page is

enter image description here

While the index page is

enter image description here

Note

Instead of the horrible hack you're doing for adding “Anhang” with some space before it, use

\cleardoublepage
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
\Huge Anhang
\addtocontents{toc}{%
  \protect\addvspace{2pc}% <------------- adjust to suit
  \textbf{\sffamily Anhang}\protect\par
}
\end{center}
\vspace*{\fill}
\clearpage
4
  • I tried to reproduce it and put the used code in my initial question. Why is the vertical spacing between Stichwortverzeichnis-IntroducingText-FirstIndexEntry different from the vertical spacing between Glossar-IntroducingText-FirstGlossarEntry?
    – laminin
    Apr 7, 2015 at 17:52
  • @laminin Because so decided (wrongly) the developers of nomencl. If you want no space, use \indexprologue[\vspace{0pt}]{Text}
    – egreg
    Apr 7, 2015 at 18:01
  • By your pt command (0.5pt is not possible) I can at least adjust the introducing text distance to the first entry from index plus nomenclature. But Starting from header "Stichwortverzeichnis" and introducing text is still different from "Glossar" and introducing text
    – laminin
    Apr 7, 2015 at 18:03
  • 1
    @laminin The two packages use a different model, unfortunately. Add \vspace{-6pt} in front of the text in \indexprologue (adjust to get the same distance).
    – egreg
    Apr 7, 2015 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .