1

I have two problems with the index in my .tex file. enter image description here

1) How can I put the 1.10 behind the 1.3? 2) How can I stash the zero in from \section? (E.g. 1 instead of 1.0)

Unfortunately my MWE is not that 'minimal':

\documentclass{scrbook}

\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[linktoc=none]{hyperref}
\usepackage{imakeidx}

\renewcommand\thesection{\arabic{section}} 

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


\begin{document}
\section{English football league system}
\index{System}
%
\subsection{History}
Created in 1888.
%
\subsection{Structure}
\index{Structure}
At the top is the single division of the Premier League
%
\subsection{Cup eligibility}
\index{Cup}
Being members of a league at a particular level also affects eligibility for Cup.
%
\subsection{Sub 4}
%
\subsection{Sub 5}
%
\subsection{Sub 6}
%
\subsection{Sub 7}
%
\subsection{Sub 8}
%
\subsection{Sub 9}
%
\subsection{Carobao Cup}
\index{Cup}


\printindex
\end{document}
  • unfortunately for references with this format, the sorting of makeindex is strictly "literal". 1.03 and 1.10 would sort in the desired (logical to humans but not to a computer) order. but i'm not sure how to accomplish this. – barbara beeton Jan 25 '18 at 16:29
2

You can add leading zeros so makeindex sorts, and then drop them while typesetting

enter image description here

\documentclass{scrbook}

\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[linktoc=none]{hyperref}
\usepackage{imakeidx}

\renewcommand\thesection{\arabic{section}} 

\makeindex 
\LetLtxMacro\OldIndex\index
\newcommand*{\indexpage}[5]{#2\ifnum#4=0 \else.#4\fi}
\renewcommand{\index}[1]{\OldIndex{#1|%
   indexpage
    {\ifnum\value{section}<10 0\fi}{\arabic{section}}%
    {\ifnum\value{subsection}<10 0\fi}{\arabic{subsection}}}%
}

\begin{document}
\section{English football league system}
\index{System}
%
\subsection{History}
Created in 1888.
%
\subsection{Structure}
\index{Structure}
At the top is the single division of the Premier League
%
\subsection{Cup eligibility}
\index{Cup}
Being members of a league at a particular level also affects eligibility for Cup.
%
\subsection{Sub 4}
%
\subsection{Sub 5}
%
\subsection{Sub 6}
%
\subsection{Sub 7}
%
\subsection{Sub 8}
%
\subsection{Sub 9}
%
\subsection{Carobao Cup}
\index{Cup}


\printindex
\end{document}

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.