PDFLaTeX 未定义控制序列 documentclass ^^@

PDFLaTeX 未定义控制序列 documentclass ^^@

我今天刚开始使用 texmaker,但无法编译 .tex 文件,即使是一个简单的 helloworld 文件。运行 pdflatex 命令后,我收到一个日志文件,其中第一个错误是:

! Undefined control sequence.
l.1 \^^@
    ^^@^^@d^^@^^@^^@o^^@^^@^^@c^^@^^@^^@u^^@^^@^^@m^^@^^@^^@e^^@^^@^^@n^...
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

这是 .tex 文件中的文本:

\documentclass[11pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
Hello, world!
\end{document}

这是由向导生成的,我刚刚插入了一行测试文本。pdflatex 的命令如下:

pdflatex -synctex=1 -interaction=nonstopmode %.tex

这又是默认设置。目前,编码字体是 UTF-32,但无论我选择哪种编码,似乎都会遇到同样的问题。

有人能看出哪里出了问题吗?pdflatex 似乎在每个字母之间插入了 ^^@,但为什么呢?我在网上其他地方找不到同样的问题。

谢谢!

编辑:是的。UTF8 有效。我真尴尬,我确信我试过了!非常感谢!:)

答案1

看来您的输入源文件是 UTF16 或 UTF32。UTF32 文件包括(每个字节):

zero zero zero \ zero zero zero d zero zero zero o zero zero zero c ...

TeX 将其解释\ zero为具有单个字符(ASCII 零)的控制序列,并且该控制序列(TeX\^^@在日志文件中报告)未定义。

对源文件仅使用 ASCII 或单字节编码或 UFT8。

相关内容