Unexpected latex error: Text line contains an invalid character
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).
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).