[Tex/LaTex] Missing $ Inserted After Index

imakeidxindexing

I am typing some notes. I ran "makeindex" on my two indices. I PDFLaTeX'd the notes and all was well. Then I added the hyperref package. I then ran "makeindex" to generate my indices by doing "makeindex index.idx" and "makeindex notation.idx" Now when I PDFLaTeX it gives me an error of "missing $ inserted". The notes are separated into sections, each section with its own TeX file. The error says it occurs on line 5, which in my main file is \usepackage{setspace}. What might be causing this?

EDIT: Here are some things from my .log file. I have omitted errors that I feel are not needed. The line the error from [4] references is a section title that use $'s to achieve math mode.

[4]
("C:\Users\jjohnson\Dropbox\Jolie\Joe Teaching\Linear Algebra\Spring 2014\Notes
\section12.tex"

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `math shift' on input line 1.


Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `superscript' on input line 1.


Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `math shift' on input line 1.




[22]
("C:\Users\jjohnson\Dropbox\Jolie\Joe Teaching\Linear Algebra\Spring 2014\Notes
\notation.ind"
! Missing $ inserted.
<inserted text> 
            $
l.5 

I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

Best Answer

The best way to cope with these error messages is, first of all, looking at the log file and not simply at the short messages given by front ends.

If possible, launch the LaTeX run (whatever engine) with the -file-line-error that will better inform about what file is involved in the error. In any case, a file that's input is reported in the log file with an open parenthesis followed by the file name; in some cases it might be difficult to find it, with the -file-line-error option activated, the l. 5 indicator (of line 5 in the currently input file) is substituted by <filename>:<line number>.

Your log file tells us that the error is in notation.ind, at line 5; this is a file produced by MakeIndex. The probable cause is a malformed index entry.

How to activate the -file-line-error option? This could be recommended in all cases, by the way. If the TeX distribution is MiKTeX, the name of the option could be different, check the documentation.

TeXworks

Go to the Preferences, Typesetting tab and edit the pdflatex tool according to the following picture

enter image description here

Click OK twice and you're done.

TeXStudio (formerly TeXMakerX)

Go to the Preferences, Commands tab; add -file-line-error to the build commands; in the picture I added it to pdflatex. The path to the binaries could be different, but the general flavor should be the same.

enter image description here

Related Question