4

I'm getting an unplesant result with makeindex:

\documentclass[fontsize=12pt,twoside,parskip=half]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[ngerman]{babel} 

\usepackage[makeindex]{imakeidx}
\makeindex[title=Register,options={-g lp3.ist},options={-s lp3.ist}]

\begin{document}

This is a short Test.

\index{apple}
\index{Number}
\index{$\alpha$}
\index{7}
\index{7 the Borg}
\index{seven the Borg}
\index{soeven@söven}

\printindex

\end{document}

and lp3.ist:

quote '+'
headings_flag 1
symhead_positive "Symbols"
numhead_positive "Numbers"
heading_prefix "{\\textbf "
heading_suffix "}\\nopagebreak%\n \\indexspace\\nopagebreak%"
delim_0 "\\dotfill "
delim_1 "\\dotfill "
delim_2 "\\dotfill "
delim_r "~--~"
suffix_2p "\\,f"
suffix_3p "\\,ff"
preamble
"\\markright{INDEX}\n\n\\begin{theindex}\n\\thispagestyle{headings}\n"
postamble "\n\n\\end{theindex}\n"

enter image description here

I'm expecting 7 the Borg to be itemized under Numbers but not under Symbols. How can I achive that?

Addendum: I'm open for any solution as long as I get a correct, punctilious Index.

  • 2
    \index{7@7 the Borg} – egreg Oct 25 '16 at 15:38
  • @egreg, works fine, but not with \index{7 the Boerg@7 the Börg} any idea why? – Louis Oct 25 '16 at 15:56
  • 1
    From the makeindex manual (emphasis by me): »A special symbol is defined here to be any character not appearing in the union of digits and the English alphabetic characters. Patterns starting with special symbols precede numbers, which precede patterns starting with letters. As a special case, a string starting with a digit but mixed with non-digits is considered to be a pattern starting with a special character – clemens Oct 25 '16 at 18:57
1

If you want an item categorized under numbers, it should consist only of digits. As specified by the rules, if the index term is of the form

<pre>@<post>

the part <pre> is used for sorting, so it is this one that must consist of digits only.

Here's a possible way out.

\documentclass[fontsize=12pt,twoside,parskip=half]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[ngerman]{babel} 

\usepackage{imakeidx}
\makeindex[title=Register]

\newcommand{\numindex}[2]{%
  \begingroup\edef\y{\pdfescapehex\expandafter{\detokenize{#2}}}%
  \edef\x{\endgroup
    \noexpand\index{#1#1#1\expandafter\converthex\y 00000000\relax @\unexpanded{#1 #2}}%
  }\x
}
\def\converthex#1#2#3#4#5#6#7#8#9\relax{\number"#1#2#3#4#5#6#7#8}


\begin{document}

This is a short Test.

\index{apple}
\index{Number}
\index{$\alpha$}
\index{7}
\numindex{7}{the Borg}
\numindex{7}{se Borg}
\numindex{8}{söven}
\index{seven the Borg}
\index{soeven@söven}

\printindex

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.