3

I’m looking for any possible clues in trying to track down a cause for the following error while writing or processing the .ind file for a memoir class document (using latexmk with pdflatex):

\mathit allowed only in math mode

This is occurring, in the first instance with .ind entry

\item \idxmark{Urysohn Metrization Theorem}, \hyperpage{506}, 
    \mainref{580}

The function \mainref is defined as:

\newcommand{\mainref}[1]{\textbf{\emph{\hyperpage{#1}}}}

But the error occurs even if I change \mainref to: \newcommand{\mainref}[1]{#1}

The log shows:

./book.ind:1772: LaTeX Error: \mathit allowed only in math mode.

 ...                                              

l.1772 \item \idxmark{Urysohn Metrization Theorem}
                                                  , \hyperpage{502},

The preamble invokes hyperref as follows:

\usepackage{hyperref}
\hypersetup{
  plainpages=false,pdfpagelabels,
  bookmarksnumbered,
  breaklinks=true,
  colorlinks, citecolor=red, filecolor=black, linkcolor=blue, urlcolor=blue,
  linktocpage=true,linktoc=all, %
}

The portion of doc.ind around the cited line is:

\item \idxmark{upper semicontinuous map}, \hyperpage{317}, 
        \hyperpage{497}
\item \idxmark{Urysohn Metrization Theorem}, \hyperpage{502}, 
        \mainref{578}
\item \idxmark{Urysohn's Lemma}, \hyperpage{200}, \hyperpage{577}, 
        \mainref{577}, \hyperpage{578}
\item \idxmark{usual ordering}, \hyperpage{12--13}

And the end of book.idx is:

\indexentry{Urysohn's Lemma|mainref}{585}
\indexentry{Urysohn's Lemma|hyperpage}{585}
\indexentry{Urysohn's Lemma|)hyperpage}{586}
\indexentry{Tietze Extension Theorem|mainref}{586}
\indexentry{normal space!and Tietze Extension Theorem|hyperpage}{586}
\indexentry{normal space|)hyperpage}{586}
\indexentry{Urysohn Metrization Theorem|mainref}{586}

The document’s .ist file is:

item_0  "\n\\item \\idxmark{"
delim_0 "}, "
% not forgetting the subitem case
item_x1 "} \n \\subitem "
headings_flag 1
heading_prefix "{\\medskip\\hfill\\large\\textsf{\\textbf{"
heading_suffix "}}\\hfill}\\medskip\\nopagebreak\n"

where \idxmark is defined in my preamble by:

\providecommand\gobbleone[1]{}
\newcommand{\idxmark}[1]{{\let\gobbleone\relax\markboth{\sffamily\bfseries#1}{\sffamily\bfseries#1}}#1}

The purpose of \idxmark is to cause the header on each Index page to show the first and last entries on the page (except for the first page).

If I comment out the \index entries for that “Urysohn Metrization Theorem”, then the same error occurs for other entries or subentries.

I can (awkwardly) work around the error by ignoring it and processing the source once more with pdflatex, but clearly something is wrong.

In case it helps, the index entry in question appears on the final page of output, shown here:

End of index includes entry causing error

Likely resolution:

The error arises from my improper use of the repeatindex package, in that I did not modify index entries by causing index entries to be created in the form \item [Main Item A], 1, 3, 6 ). And that can be accomplished by using makeindex -s repeatindex, that is, by using the file repeatindex.ist that is part of the repeatindex package. But this may conflict with my existing custom .ist file shown above. I have deferred asking about that to How modify custom .ist to incorporate repeatindex.

I apologize for not yet providing a complete, minimal working example for reproducing the error, but I think some clue might help me devise such. The document in question is of book length, with a complex source structure that includes multiple style files constituting the preamble.

murray
  • 7,944
  • 1
    can't say much without an example, but is the error you show the first error or did an earlier error (eg from a mis-placed ^) start an unexpected math mode somewhere – David Carlisle Feb 14 '20 at 21:48
  • 1
    Is there a page break around this place? – Ulrike Fischer Feb 14 '20 at 21:50
  • add \tracingmacros=1 a bit before the index entry and then show in the log-file. – Ulrike Fischer Feb 14 '20 at 22:02
  • @UlrikeFischer: I'm not seeng any page break around the \index entry in source or in the corresponding output. – murray Feb 14 '20 at 22:09
  • well there is a column break. Where are the dots from? – Ulrike Fischer Feb 14 '20 at 22:14
  • @UlrikeFischer: The dots at the top of the index column come from package repeatindex. They occur whenever a main entry is continued from the end of one page to the next or from the end of one column to the next. Many pages of the (long) index get such dots, and without errors when the entries around them are being processed. – murray Feb 14 '20 at 22:20
  • Aha! Eliminating use of repeatindex eliminates the error. But the error is something that has occurred only within the past several weeks. The repeatindex package is old. This suggests some recent change in latex or memoir or some other package I'm using is causing repeatindex no longer to work without complaint. – murray Feb 14 '20 at 22:29
  • The error line you show contains the page number 502; the portion of the .idx file is for page 578; and the index page image you include shows pages 508 and 576. At least the output page doesn't agree with the error lines and the example selection. Simple question: did you remove the old .idx and .ind files before rerunning? – barbara beeton Feb 14 '20 at 22:30
  • @murray repeatindex messes around with afterpage and changes the output routine. Lots of thing can fail here, and lots of things can be the cause - even a simple index entry more that changed the order. As I said you could add \tracingmacros to investigate, but from your output and the index entries it doesn't look as if you actually used repeatindex as intended - you only added odd dots in some places. – Ulrike Fischer Feb 14 '20 at 22:38
  • @UlrikeFischer: I did not explicitly add anything in the source to insert those dots. So far as I know, they were all added automatically by repeatindex . But I see that I should be modifying the latexmk so as to use the form makeindex -s repeatindex file, which I had not done. I'll see if that helps. The question remains: why now is the error arising, whereas it never did earlier in time. – murray Feb 14 '20 at 22:53
  • 4
    I’m voting to close this question because: OP added a likely resolution to the question and deferred asking about that to https://tex.stackexchange.com/q/528520/6865 – Stephen Nov 20 '22 at 17:35
  • I'm voting as well to close the question, but would like to point out that the error message is triggered by the line "\indexentry{Urysohn's Lemma|)hyperpage}{586}", where the |) is interpreted as \), which is indeed the closer for inline math. – barbara beeton Nov 20 '22 at 19:28
  • Yes, appropriate to close. – murray Nov 21 '22 at 18:08

0 Answers0