# Redefining Page Numbers Makes Index Disappear

This is my code:

\documentclass[a4paper]{scrbook}
\usepackage{imakeidx}
\makeindex
\begin{document}
\renewcommand*\thepage{\thechapter---\arabic{page}}

text\index{test}

\printindex
\end{document}


This file has only two pages, and no index. When I comment out the line \renewcommand*\thepage{\thechapter---\arabic{page}}, the index is generated on the third page.

I followed the troubleshooting in, and took the MWE from, this question; and I took the modified page numbers from this one.

The default “page compositor” is a hyphen.

You can change it to --- by using a personal style. The simplest way is to generate an .ist file in the working directory.

\begin{filecontents*}{emdash.ist}
page_compositor "---"
\end{filecontents*}

\documentclass[a4paper]{scrbook}
\usepackage{imakeidx}

\makeindex[options=-s emdash]

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

\begin{document}

\chapter{Title}

text\index{test}

\printindex

\end{document}


Available on your TeX Live system as texdoc ind.

Of course it's up to you to change the page number format before printing the index.