A weird problem with LaTeX

I had a very weird problem with LaTeX. I had a document that worked well (no problems from the LaTeX software), and I added a lot of text from another file. Then, when I tried to "typeset" it, the software gave me an error, like this:

ieee: Warning! No \journal given!
[2]
! Missing $ inserted.
< inserted text >
        $
l.33 \end{document}

?

The warning is not the issue. You can fix that by putting "\journal{ }" in the LaTeX file. The problem is that line 33 is the "end{document}" line, and there is no obvious need for a $. So it must be in math mode? It's easy to forget a $, but the problem here is that adding a $ does not help. Try it, and it will give the same error.

Now here is the weird part: commenting and uncommenting lines changes whether this error appears. Or I could add lines, and it would go away. But the problem would appear again after adding even more lines.

There seemed to be no consistency to this error. When faced with an error like this, the best thing to do is to strip away everything that is not essential to the error. Then examine what is left.

The symptoms

I have the following LaTeX source file that demonstrates this problem, and a very similar one that does not have this problem. Here is what the problem file looks like:
\documentclass[final]{ieee}

\title[journal_Example]{Blah blah blah}

\begin{document}

\maketitle

Blah blah blah. \vspace{5in}

Blah blah blah. \vspace{5in}

Blah blah blah. \vspace{5in}

Blah blah blah. \vspace{5in}

Blah blah blah. \vspace{5in}

Blah blah blah. \vspace{5in}

Blah blah blah. \vspace{5in}

Blah blah blah. \vspace{5in}

Blah blah blah.


\end{document}

And the file that works has only one difference - the last line before the "\end{document}". Here is the "fixed" version:
% Blah blah blah.

The solution

Obviously, commenting out a line of text that you want is not a good solution. I turned to the Internet for help, but could not find this issue. Then I ran across this: "this is most often caused by the use of underline characters in nonmath mode." That's when it started to make sense. It was not necessarily math mode, but perhaps an errant underscore that was the problem. I did a search on the file, and came up with the following line right away.

\title[journal_Example]{Blah blah blah}

The short title I gave had an underscore. I removed this underscore, and then the problem went away.

It was as simple as changing this:

\title[journalExample]{Blah blah blah}



--
Michael Weeks, copyright 2008, 2009