1

I need your help! enter image description here

This is how I made it:

\begin{filecontents*}{Idx.ist}
headings_flag 1
heading_prefix "{\\hrulefill  \n \n \\textbf{"
heading_suffix "}} \\nopagebreak"

delim_0 "\n\n  \\item  "

group_skip "\n\n \\hrulefill"
\end{filecontents*}
\documentclass[8.5pt twoside, a4paper]{book} 
\let\cleardoublepage\clearpage
\usepackage[T1]{fontenc}
\usepackage[german]{babel} 
\usepackage[utf8]{inputenc} 

\usepackage[scaled]{uarial} 
\renewcommand{\familydefault}{\sfdefault}
\usepackage{multicol}

\usepackage{titlesec}

\usepackage{imakeidx} 


\usepackage{hyperref}

\makeindex[options=-s Idx.ist]

\makeatletter
\let\mygobble\@gobble
\LetLtxMacro\OldIndex\index
\renewcommand{\index}[1]{\OldIndex{#1|mygobble}} 
\makeatother

\begin{document}
\chapter{Test}
Irgendein Text.
\section{Eins}
Blablabla.
\subsection{Regeln}
\index{Ausland}
\index{Sieger}
\index{Spieler}
\index{Spielfeld}
\subsection{Beschäftigung}
\index{Beruf}
\index{Arbeit}
\vfill
\pagebreak

\addcontentsline{toc}{section}{\textbf{Stichwortverzeichnis}}
\renewcommand{\indexname}{Stichwortverzeichnis}
\fontsize{7.5pt}{0pt}
\printindex 

\end{document}

Edit: The section numbering and the thing with a line at the end worked fine! THANKS!
But the indentation does not work. \struntbox does not work..

Edit2.0: If I have more indeces, there is a columnbreak within a "group" of alphabetic characters. How can I avoid this?

3rd Edit: I just realized that I need an extra row/line after the groups. Like this: enter image description here

How can add such a row/line?

1 Answers1

6

If you want the page numbers at the index, simply do not remove them with your redefinition of \index. The formatting can be done with some changes of Idx.ist and some additional definitions:

\RequirePackage{filecontents}
\begin{filecontents*}{Idx.ist}
headings_flag 1
heading_prefix "\\indexheading{"
heading_suffix "}"

delim_0 "\\hfill"

group_skip "\n"
preamble "\\begin{theindex}\\starttheindex"
postamble "\n\\stoptheindex\\end{theindex}"
\end{filecontents*}
\documentclass[8.5pt,% book does not know this option (but don't forget the comma!)
  twoside,% this is default
  openany,% so usually you do not need \let\cleardoublepage\clearpage
  a4paper]{book} 
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel} % use new spelling instead of old
\usepackage[utf8]{inputenc} 

%\usepackage[scaled]{uarial}% uarial is a very ugly mix of Arial and Helvetica 
\renewcommand{\familydefault}{\sfdefault}
\usepackage{multicol}

\usepackage{titlesec}

\usepackage{imakeidx} 


\usepackage{hyperref}

\makeindex[options=-s Idx.ist]

% If you do not want page numbers but, e.g. subsection numbers in the index:
%\LetLtxMacro\OldIndex\index
%\newcommand*{\indexpage}[2]{#1}
%\renewcommand{\index}[1]{\OldIndex{#1|indexpage{\thesubsection}}} 
\newcommand*{\indexheading}[1]{%
  \indexrule
  \textbf{#1}\par
  \nopagebreak
  \vskip-\baselineskip% go back to the heading line
}
\newcommand*{\indexrule}{%
  \par\nopagebreak
  \vskip-\ht\strutbox
  \hrulefill\par\pagebreak[3]
  \vskip -\baselineskip
  \hrulefill\par\nobreak
}
\newcommand*{\starttheindex}{\raggedcolumns}
\newcommand*{\stoptheindex}{\indexrule}
\makeatletter
\renewcommand*{\@idxitem}{\par\hangindent 2em\hskip 1.5em}% indent the entry
\makeatother

\begin{document}
\chapter{Test}
Irgendein Text.
\section{Eins}
Blablabla.
\subsection{Regeln}
\index{Ausland}
\index{Sieger}
\index{Spieler}
\index{Spielfeld}
\subsection{Beschäftigung}
\index{Beruf}
\index{Arbeit}
\vfill
\clearpage% should be used before \addcontentsline

\addcontentsline{toc}{chapter}{Stichwortverzeichnis}% the index is a chapter and becomes the font for chapter entries that is already bold
\renewcommand{\indexname}{Stichwortverzeichnis}
\fontsize{7.5pt}{0pt}
\printindex 

\end{document}

Index with page numbers

If you remove the % in front of

\LetLtxMacro\OldIndex\index
\newcommand*{\indexpage}[2]{#1}
\renewcommand{\index}[1]{\OldIndex{#1|indexpage{\thesubsection}}} 

you'll get:

Index with subsection numbers

To avoid column breaks inside groups you can add an additional \nopagebreak in the definition of \@idxitem:

\RequirePackage{filecontents}
\begin{filecontents*}{Idx.ist}
headings_flag 1
heading_prefix "\\indexheading{"
heading_suffix "}"

delim_0 "\\hfill"

group_skip "\n"
preamble "\\begin{theindex}\\starttheindex"
postamble "\n\\stoptheindex\\end{theindex}"
\end{filecontents*}
\documentclass[8.5pt,% book does not know this option (but don't forget the comma!)
  twoside,% this is default
  openany,% so usually you do not need \let\cleardoublepage\clearpage
  a4paper]{book} 
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel} % use new spelling instead of old
\usepackage[utf8]{inputenc} 

%\usepackage[scaled]{uarial}% uarial is a very ugly mix of Arial and Helvetica 
\renewcommand{\familydefault}{\sfdefault}
\usepackage{multicol}

\usepackage{titlesec}

\usepackage{imakeidx} 


\usepackage{hyperref}

\makeindex[options=-s Idx.ist]

% If you do not want page numbers but, e.g. subsection numbers in the index:
%\LetLtxMacro\OldIndex\index
%\newcommand*{\indexpage}[2]{#1}
%\renewcommand{\index}[1]{\OldIndex{#1|indexpage{\thesubsection}}} 
\newcommand*{\indexheading}[1]{%
  \indexrule
  \textbf{#1}\par
  \nopagebreak
  \vskip-\baselineskip% go back to the heading line
}
\newcommand*{\indexrule}{%
  \par\nopagebreak
  \vskip-\ht\strutbox
  \hrulefill\par\pagebreak[3]
  \vskip -\baselineskip
  \hrulefill\par\nobreak
}
\newcommand*{\starttheindex}{\raggedcolumns}
\newcommand*{\stoptheindex}{\indexrule}
\makeatletter
\renewcommand*{\@idxitem}{\par\nopagebreak\hangindent 2em\hskip 1.5em}% indent the entry
\makeatother

\begin{document}
\chapter{Test}
Irgendein Text.
\section{Eins}
Blablabla.
\subsection{Regeln}
\index{Ausland}
\index{Sieger}
\index{Spieler}
\index{Spielfeld}
\subsection{Beschäftigung}
\index{Beruf}
\index{Arbeit}
\index{Test1}\index{Test2}\index{Test3}\index{Test4}\index{Test5}
\index{Test6}\index{Test7}\index{Test8}\index{Test9}\index{Test10}
\vfill
\clearpage% should be used before \addcontentsline

\addcontentsline{toc}{chapter}{Stichwortverzeichnis}% the index is a chapter and becomes the font for chapter entries that is already bold
\renewcommand{\indexname}{Stichwortverzeichnis}
\fontsize{7.5pt}{0pt}
\printindex 

\end{document}

But I would not recommend this, because you will get overfull columns if a group is larger than the column height.

To change the vertical distance above the rule, just change the line

  \vskip-\ht\strutbox

in the definition of \indexrule, e.g.,

\newcommand*{\indexrule}{%
  \par\nopagebreak
  \vskip\dp\strutbox\nopagebreak
  \hrulefill\par\pagebreak[3]
  \vskip -\baselineskip
  \hrulefill\par\nobreak
}

would result in

with gap before the line

Note that I've used another font, because I do not have the ugly URW-Arial installed.

You should also have a look at the several notes I've added to the code.

Schweinebacke
  • 26,336