5

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:

\documentclass[12pt,twoside]{report}
\begin{document}
  Hello $1,2,3$.
\end{document}

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 \c@chapter=\count80 \c@section=\count81 \c@subsection=\count82 \c@subsubsection=\count83 \c@paragraph=\count84 \c@subparagraph=\count85 \c@figure=\count86 \c@table=\count87 \abovecaptionskip=\skip41 \belowcaptionskip=\skip42 \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!

  • Perhaps you have a different encoding. How about creating a new blank document and retype the document and see what happens. – Werner Aug 3 '15 at 4:47
  • I tried that and it worked fine! Every other document that I have and every new document that I create with this exact code (and the original longer code that gave the original error) work fine. The error seems to be associated with this exact file irregardless of what I type into it. Strange... – RPavao Aug 3 '15 at 17:08
  • 1
    Ah. It seems like you have a faulty.aux file. Delete it and try again. – Werner Aug 3 '15 at 18:29
14

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.

  • 2
    I've deleted the *.aux file and it worked. Thank you very much. – RPavao Aug 4 '15 at 0:23
  • 1
    "Sometimes you'd need to rewrite a paragraph to fix this." That's what I'd been doing, and it was driving mad: in a way relieved to find that it wasn't a completely insane thing to do... Thanks. – PatrickT Apr 25 '16 at 7:19
  • I haveve deleted the .AUX file and now it is normally run. Thank you so much – user115274 Sep 29 '16 at 6:15
  • 2
    After adding some text, I was getting this error with trailing NULs (^@) at a random, unrelated line, and I could never grep them in the sources or find out how it was related to the change. I tried commenting out dangerous-looking lines but there seemed to be no pattern to how it reacted. Then I noticed that xelatex was giving me different results regardless of commenting; two runs in a row from identical sources might either compile ok, or break with invalid character. Turns out I had forgotten a latexmk -pvc process running in another tab, and I was competing with myself. – melissa_boiko Feb 12 '18 at 10:12
  • 2
    @melboiko: I know this is a while ago, but my God this saved my day! I was scratching my head for a long, long time, getting strange, non-reproducible errors all over the place. Like you, I had a latexmk -pvc process in another tab... Who knows how long I would have spent before realizing this - thanks for mentioning it! – Bendik May 15 at 16:59
1

My assumption is that the wrong input file is used. Instead of the source file, LaTeX is given a binary file, like a PDF file, for example.

Another option is a wrong encoding. There is some support for UTF-8. But UTF-16 and UTF-32 are not supported. The added zero bytes also cause these kind of error.

When TeX is running, it generates a file with extension .log. This log shows you the input files as well as the complete error messages. Please, update the question to include the .log file (at least from the start up to the first error messages, no need for all error messages).

  • Am encoding error would probably be picked up on line 1 though, not 3. – Werner Aug 3 '15 at 5:41
  • @Werner The first line of a PDF file is a valid TeX comment line: %PDF-1.5. The second line often contain a comment with binary bytes to avoid to be treated as text file. The comment character of PDF and PS is the percent character, a common comment character of TeX files. – Heiko Oberdiek Aug 3 '15 at 8:05

protected by Community Oct 23 '18 at 5:39

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.