0

For a German book about butterflies and moths I want to prepare an index of the plants on which the caterpillars grow. Unfortunately the German nomenclature consists of mixed single terms and composed terms: Buche (beech) and Hain-Buche (hornbeam). I want to order Buche ! Hain- ! butterfly. When Buche is used without the second argument splitindex (and makeindex as well) fails. So I add the \leer; this, however, adds an empty line.

\documentclass[11pt,a5paper]{scrbook}
\usepackage[russian,ngerman]{babel}
\usepackage{splitidx,xparse}
\newindex[Raupenwirtspfanzen]{pfl}
\newcommand{\leer}{\hspace*{0.1mm}}
\newcommand{\PFL}[3]{#2#1\sindex[pfl]{#1!#2!#3}}
\usepackage{hyperref}
\begin{document}
\PFL{Buche}{\leer}{Pieris rapae}
\PFL{Buche}{Hain-}{Pieris rapae}
 
\printindex*
\end{document}

Pdflatex and splitindex are used to compile. How can I get of the empty line after "Buche"?

(BTW, this works easily in docbook xml. You have only to leave the second argument empty.)

1 Answer 1

1

You forgot the \makeindex in your example. You can redefine \subitem to look ahead and do nothing if e.g. \relax is detected:

\documentclass[11pt,a5paper]{scrbook}
\usepackage[russian,ngerman]{babel}
\usepackage{splitidx,xparse}
\newindex[Raupenwirtspfanzen]{pfl}
\newcommand{\PFL}[3]{#2#1\sindex[pfl]{#1!#2!#3}}
\usepackage{hyperref}
\makeindex
\ExplSyntaxOn\makeatletter
\renewcommand*\subitem{\peek_meaning_ignore_spaces:NF\relax{\@idxitem \hspace*{20\p@}}}
\ExplSyntaxOff\makeatother
\begin{document}
\PFL{Buche}{\relax}{Pieris rapae}
\PFL{Buche}{Hain-}{Pieris rapae}

\printindex*
\end{document}

enter image description here

You must log in to answer this question.

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