2

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.
  • Did you check all index entries to look for some missing $. – Sigur Jan 8 '14 at 18:50
  • @Sigur I just went back and checked. No '$' seems to be missing. As I said, I have generated the PDF at least two or three times without error. I only started getting the error after I added the hyperref package. – Joe Johnson 126 Jan 8 '14 at 18:56
  • 2
    Line 5 can refer to a different file; if you know how to run pdflatex from a terminal window, calling it pdflatex -file-line-error followed by the file name should make it clear what file it refers to. – egreg Jan 8 '14 at 19:03
  • check the output: the erroneous $ will put the text into math mode. (My guess is an errant _ somewhere.) – Ulrich Schwarz Jan 8 '14 at 19:08
  • 1
    @JoeJohnson126 It's line 5 in notation.ind, probably a faulty index entry. – egreg Jan 28 '14 at 16:55
3

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

  • (Enrico): Would it be possible for you to make a separate page that explains this procedure step-by-step please (or even edit your answer)? It would be really helpful for all self-learners. Eg. how to launch latex run you mention initially, which file you exactly refer to etc...Grazie mile – Abhimanyu Arora Jan 28 '14 at 20:14
  • @AbhimanyuArora How to add the option depends on what method you use to launch the LaTeX run; there are really many possibilities. Can you tell what method you're using? – egreg Jan 28 '14 at 20:17
  • @Enrico: Well, I just open the shortcut to my editor to run latex. I use three editors: TeXWorks/TeXniCentre/TexMakerX. Hope that is what you ask? – Abhimanyu Arora Jan 28 '14 at 20:20
  • @AbhimanyuArora I added the procedure for TeXworks and TeXStudio. I'm afraid I can't do it for TeXnicCenter, as I am a proud nonowner of machines running Windows. ;-) – egreg Jan 28 '14 at 22:36
  • @Enrico: Grazie mile, miofratello :-), you are very kind – Abhimanyu Arora Jan 28 '14 at 23:37

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.