6

I'm currently writing some appendices and I'm wondering why some keywords don't show up in the index.

The page-number is redefined for every section of the Appendix (A..., B..., C..., etc.).

I've discovered, that there is always this error:

Scanning input file testfile.idx...done (0 entries accepted, 4 rejected).

Content of file testfile.idx:

\indexentry{A}{C1}
\indexentry{B}{C1}
\indexentry{C}{C2}
\indexentry{D}{C2}

Content of makeindex-logfile:

Scanning input testfile.idx...
!! Input index error (file = testfile.idx, line = 1):
   -- Illegal Roman number: position 2 in C1.
!! Input index error (file = testfile.idx, line = 2):
   -- Illegal Roman number: position 2 in C1.
!! Input index error (file = testfile.idx, line = 3):
   -- Illegal Roman number: position 2 in C2.
!! Input index error (file = testfile.idx, line = 4):
   -- Illegal Roman number: position 2 in C2.
done (0 entries accepted, 4 rejected).

This works fine for pages starting with A, B and E (probably more), but fails with C and D. Therefore, I'm afraid that makeindex is interpreting C and D as Roman numerals for 100 and 500, respectively.

MWE:

\documentclass{scrbook}
\usepackage{makeidx}
\makeindex

\begin{document}
    \pagenumbering{arabic}\renewcommand{\thepage}{C\arabic{page}}
    A\index{A}  B\index{B}
    \clearpage
    C\index{C}  D\index{D}
    \cleardoublepage
    \printindex
\end{document}

What do I have to do to get makeindex interpreting "C1", etc. as it is?


UPDATE:

Problem on the pagenumbering encountered with hyperref:

Adobe Reader

  • I'm afraid this is an inherent limitation of MakeIndex. – egreg Sep 1 '13 at 20:29
  • Hmm, still wondering why "C4" is not working, but "C-4" does. It seems that makeindex can indeed accept a non-roman character but refuses to work with arabic numbers. I'm confused... – MrD Sep 1 '13 at 20:41
6

If you are not totally committed to that page format makeindex is happier if you have a - separator:

\documentclass{scrbook}
\usepackage{makeidx}
\makeindex

\begin{document}
    \pagenumbering{arabic}\renewcommand{\thepage}{A-\arabic{page}}
    A\index{A}  B\index{B}
    \clearpage
    C\index{C}  D\index{D}
    \cleardoublepage


    \pagenumbering{arabic}\renewcommand{\thepage}{C-\arabic{page}}
    A\index{A}  B\index{B}
    \clearpage
    C\index{C}  D\index{D}
    \cleardoublepage
    \printindex
\end{document}

enter image description here

As egreg noted in comments (and included here with permission:-) the trick to having an invisible page separator is the `page_compositor_ setting in a makeindex style.

\protected\def\?{}
\renewcommand\thepage{C\?\arabic{page}

in the LaTeX file and

page_compositor "\\?"

in a foo.ist file to be called by

 makeindex -s foo filename

or a filename.mst

  • Yes, I've had this before, but to be honest - I don't like it very much (see also on page A-15), as I think page A15 is smoother. Also I don't know why the minus solves this issue. I'll think about this and maybe I'll customize the source code of my very own version of makeindex if nothing else is possible... – MrD Sep 1 '13 at 20:38
  • @DL6ER I'm sure in a previous life I had a makeindex style that made a separator visible to makeindex but typestting as empty, failed to recreate it just now, but it may come back to me:-) – David Carlisle Sep 1 '13 at 20:40
  • @DL6ER oh I used same page format as you suggest in source2e :-) – David Carlisle Sep 1 '13 at 20:43
  • 2
    @DL6ER egreg told me to edit it in to here :-) – David Carlisle Sep 1 '13 at 21:17
  • 2
    @DL6ER The idea for a page_compositor expanding to nothing was David's. – egreg Sep 1 '13 at 21:46
1

A cheap work-around if you really don't want C-1, C-2, … :

Go ahead and do it with C- anyway. LaTeX will generate foo.idx from your foo.tex file and then MakeIndex will create foo.ind will no rejections. When you're happy with everything else and still have those hated C- page numbers in your index, open foo.ind and do a global search-and-replace to change every C- to just C. Fix your foo.tex file to use C not C- in the appendix and LaTeX it one last time and there you have it.

  • You'll want a script or batch file or makefile so you don't have to remember or type these steps. – Ethan Bolker Jun 11 '14 at 20:14
1

Addition for hyperref to David Carlisle's answer:

\usepackage{hyperref}

% disable \? in page labels, destinations and links
\pdfstringdefDisableCommands{\let\?\relax}
\makeatletter
\g@addto@macro\theindex{\let\?\@empty}
\makeatother

A full example using \jobname.mst as style file for makeindex.

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

\documentclass{scrbook}
\usepackage{makeidx}
\makeindex

\usepackage{hyperref}

\newcommand*{\?}{}
\protected\def\?{}

%%% hyperref support
\pdfstringdefDisableCommands{\let\?\relax}
\makeatletter
\g@addto@macro\theindex{\let\?\@empty}
\makeatother
%%%

\begin{document}
    \pagenumbering{arabic}\renewcommand{\thepage}{C\?\arabic{page}}
    A\index{A}  B\index{B}
    \clearpage
    C\index{C}  D\index{D}
    \cleardoublepage
    \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.