3

I have a simple Latex cod

\documentclass[12pt,oneside]{scrbook}

\usepackage{makeidx}
\makeindex

\renewcommand{\thepage}{%
\thechapter.\arabic{page}}

\begin{document}

\chapter{Sample}

Stuff about eigenvectors\index{eigenvector} and eigenvalues\index{eigenvalue}.

\chapter{Another Sample}

Some more stuff about eigenvectors\index{eigenvector} and
eigenvalues\index{eigenvalue}. Something about eigen decomposition\index{eigen-decomposition}.


\printindex

\end{document}

There is a problem that Makeindex cannot generate index entries. The main problem is that I want to define a page number with period (dot) between the chapter number and the page number.

\renewcommand{\thepage}{\thechapter.\arabic{page}}

In this case Makeindex cannot generate index entries. I get a message:


Scanning input file in1.idx...done (0 entries accepted, 5 rejected).

Nothing written in in1.ind.

Transcript written in in1.ilg.

However, if I put drag (-) instead period(dot),

\renewcommand{\thepage}{\thechapter-\arabic{page}}

Makeindex generate index entries What is the problem and why can not I place a point (dot) between the chapter number and the page number? If someone knows the solution, please help me.

0

2 Answers 2

5

makeindex's default compositor is a hyphen -. You can change it in a style file using page_compositor:

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.ist}
page_compositor "."
\end{filecontents*}

\documentclass[12pt,oneside]{scrbook}

\usepackage{makeidx}
\makeindex

\renewcommand{\thepage}{%
\thechapter.\arabic{page}}

\begin{document}

\chapter{Sample}

Stuff about eigenvectors\index{eigenvector} and
eigenvalues\index{eigenvalue}.

\chapter{Another Sample}

Some more stuff about eigenvectors\index{eigenvector} and
eigenvalues\index{eigenvalue}. Something about eigen
decomposition\index{eigen-decomposition}.


\printindex

\end{document}

Remember to include -s stylefile when invoking makeindex. For example, if the above document is called myDoc.tex then

pdflatex myDoc
makeindex -s myDoc.ist myDoc
pdflatex myDoc
3

MakeIndex doesn't accept “composite” page numbers. A crude but effective workaround, if you have no special needs for the index entries, can be using a different representation of the page numbers (chapter by 1000 plus page).

\documentclass[12pt,oneside]{scrbook}

\usepackage{makeidx}
\makeindex

\renewcommand{\thepage}{\thechapter.\arabic{page}}
\newcommand\thecomplexpage{\the\numexpr\value{chapter}*1000+\value{page}\relax}

\makeatletter
\renewcommand{\@wrindex}[1]{%
  \protected@write\@indexfile{\let\thecomplexpage\relax}{%
    \string\indexentry{#1|decomposepage}{\thecomplexpage}%
  }%
  \endgroup\@esphack
}
\newcommand\decomposepage[1]{%
  \begingroup
  \@tempcnta=#1\relax
  \divide\@tempcnta by 1000
  \the\@tempcnta.\the\numexpr#1-1000*\@tempcnta\relax
  \endgroup
}
\makeatother

\begin{document}

\chapter{Sample}

Stuff about eigenvectors\index{eigenvector} and eigenvalues\index{eigenvalue}.

\chapter{Another Sample}

Some more stuff about eigenvectors\index{eigenvector} and
eigenvalues\index{eigenvalue}. Something about eigen decomposition\index{eigen-decomposition}.

\printindex

\end{document}

enter image description here

0

You must log in to answer this question.

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