[Tex/LaTex] Unexpected latex error: Text line contains an invalid character


My latex started showing this error:

Error | line 3|! Text line contains an invalid character.

out of nowhere. Actually, it shows 100 of this errors, all in the same line.

I started to investigate and tried to test where the error could come from. In the end I ended with the following code:

  Hello $1,2,3$.

and the same error appears.
I tried to remove the \documentclass but the same error appears.
Here's a printscreen of the error(s);

image of the error(s)

If any of you guys would help me, this is driving me mad!

The log file:

LOG FILE : This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9
64-bit) (preloaded format=pdflatex 2015.6.27) 3 AUG 2015 17:47
entering extended mode

**main.tex ("C:\Users\Admin\Dropbox\Mestrado\Tese\Latex\Minhatese\main.tex"
LaTeX2e <2011/06/27> Babel and hyphenation
patterns for english, afrikaans, ancientgreek, ar abic, armenian,
assamese, basque, bengali, bokmal, bulgarian, catalan, coptic,
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish,
french, ga lician, german, german-x-2013-05-26, greek, gujarati,
hindi, hungarian, iceland ic, indonesian, interlingua, irish, italian,
kannada, kurmanji, latin, latvian, lithuanian, malayalam, marathi,
mongolian, mongolianlmc, monogreek, ngerman, n german-x-2013-05-26,
nynorsk, oriya, panjabi, pinyin, polish, portuguese, roman ian,
russian, sanskrit, serbian, slovak, slovenian, spanish, swedish,
swissgerm an, tamil, telugu, turkish, turkmen, ukenglish, ukrainian,
uppersorbian, usengl ishmax, welsh, loaded.

("C:\Program Files\MiKTeX2.9\tex\latex\base\report.cls" Document Class: >report 2007/10/19 v1.4h Standard LaTeX document class ("C:\Program >Files\MiKTeX
2.9\tex\latex\base\size12.clo" File: size12.clo 2007/10/19 v1.4h Standard >LaTeX file (size option) ) \c@part=\count79
\bibindent=\dimen102 )

("C:\Users\Admin\Dropbox\Mestrado\Tese\Latex\Minha tese\main.aux" !

Text line contains an invalid character. l.3 … A funny symbol that
I can't read has just been input. Continue and I'll forget it ever
happened. ! Text line contains an invalid character. l.3 … A funny
symbol that I can't read has just been input. Continue and I'll forget
it ever happened.

[… the same error over and over …]

! ==> Fatal error occurred, no output PDF file produced!

Best Answer

Sometimes I get such errors due to corrupted auxiliary files, e.g. a truncated *.aux or such due to killing pdflatex. Other source can be "invisible" garbage in the file, which can be e.g. control characters that snuck in, or even some hilarity like a terminal escape that goes back and overwrites some junk with spaces. Another possibility is that you have characters in the file that look normal, but aren't (e.g. modern systems display UTF-8 text with little trouble; a Greek omicron looks like Latin o, but they are different characters; unless you set the encoding up for UTF-8 you'll get grief). Practical solution: Delete all intermediate files and try again. If the problem persists, open the file and retype the offending line, deleting the original. Sometimes you'd need to rewrite a paragraph to fix this.

Update: Just had an infuriating round with pdflatex because somehow I inserted some strange character (looked like a apostrophe, but wasn't --- next to invisible).