1

I'm typesetting a math book. Since the book spirals, and there are different types of questions in each assignment, I'd like a simple way to refer students to problem types.

I tried using a simple index, using the imakeidx package, but that only refers to the page number. Since there are at least 5 problems, this is not ideal; I want the actual problem number. My numbers do resume, and there are some 800 problems scattered across 120 pages, therefore the problem number would be most helpful.

I can envision a system of using \label{NumOne} after every single item, but that seems a bit too tedious, don't you think? Is there a different package or maybe even a counter that I can define to help ease this implementation?

MWE:

\documentclass{book}
\usepackage{enumitem}
\usepackage{imakeidx}
\makeindex[intoc]

\begin{document}

\begin{enumerate}[resume] \item Problem\index{ProbType} \end{enumerate}

\printindex \end{document}

  • Welcome to TeX.SE. Which document class do you employ Please show us your code for a sample question. Is there a counter associated with the questions? If the answer is yes, how do you increment the counter? Please be specific. – Mico Jul 17 '22 at 13:54
  • It would be easier for us to answer your question if you post a MWE that shows how you did the work manually (possibly for a small part.) Then we just need to modify it to automate the tedious part – user202729 Jul 17 '22 at 13:56
  • I am using \documentclass{book} along with \usepackage{enumitem}. My numbers are laid out quite normally:

    \begin{enumerate}[resume] \item Problem\index{ProbType} \end{enumerate}

    The \index at the end shows the page number, but it would be better to have the problem number.

    Maybe a \renewcommand would help me change something in imakeidx?

    – josephgerth Jul 17 '22 at 18:00
  • Have you read up on previous approaches? https://tex.stackexchange.com/questions/616290/how-to-replace-page-numbers-by-item-numbers-in-the-index – Ingmar Jul 17 '22 at 18:43
  • Yes, I followed user31729's solution in the post "How to mention section number in Index created by imakeidx" and was unable to make effect the changes he had. I copied his commands, including the xindy option, writing the renewcommand, and making a new file called sectionindex_sectionpage.xdy. Nothing changed; I didn't make a for loop but that appeared to be used to get him several problems for the sake of example. link – josephgerth Jul 18 '22 at 10:50
  • OK, I figured out that I had to run texindy on the command line; I'll go back to experimenting with this approach and see if I can't get what I want. – josephgerth Jul 18 '22 at 11:11

1 Answers1

1

Got it! I used

\makeatletter
% Global redefinition of indexentry to use section, then page%
\renewcommand{\imki@wrindexentrysplit}[3]{%
 \expandafter\protected@write\csname#1@idxfile\endcsname{}%
    {\string\indexentry{#2}{\arabic{enumi}}}%
}%
\makeatother

As I mentioned above, I followed everything laid out in user31729's solution, found here. You do need to run texindy on the command line in order for the changes to take effect.