MikTex 找不到 \begin(document}

MikTex 找不到 \begin(document}

我最近遇到了一个错误,但不确定为什么会这样。

运行此脚本:

\documentclass{article}

\begin{document}
hello
\end{document} 

我收到此错误消息(问题是,我该如何解决这个问题?):

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (MiKTeX 2.9) (preloaded format=pdflatex 2013.2.18)  4 MAR 2013 00:00
entering extended mode
**template.tex
(C:\Users\trinker\Desktop\test\template.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> 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-2012-05-30, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, latin, latvian,
 lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerman, n
german-x-2012-05-30, 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.

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1 ï
     »¿\documentclass{article}
? 
Missing character: There is no ï in font nullfont!
Missing character: There is no » in font nullfont!
Missing character: There is no ¿ in font nullfont!
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\size10.clo"
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84

Overfull \hbox (20.0pt too wide) in paragraph at lines 1--284
[]
 []

\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
[1{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map}])
(C:\Users\trinker\Desktop\test\template.aux)
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 3.
LaTeX Font Info:    ... okay on input line 3.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 3.
LaTeX Font Info:    ... okay on input line 3.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 3.
LaTeX Font Info:    ... okay on input line 3.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 3.
LaTeX Font Info:    ... okay on input line 3.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 3.
LaTeX Font Info:    ... okay on input line 3.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 3.
LaTeX Font Info:    ... okay on input line 3.
 [2

]
(C:\Users\trinker\Desktop\test\template.aux) ) 
Here is how much of TeX's memory you used:
 203 strings out of 493921
 2340 string characters out of 3144870
 49031 words of memory out of 3000000
 3582 multiletter control sequences out of 15000+200000
 3640 words of font info for 14 fonts, out of 3000000 for 9000
 841 hyphenation exceptions out of 8191
 23i,4n,17p,140b,113s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files (x86)/MiKTeX 2.
9/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on template.pdf (2 pages, 11360 bytes).
PDF statistics:
 13 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

答案1

前面有一些字符\documentclass{article}。请尝试从文档中“键入”该文档,new.tex而无需从旧文档中“复制粘贴”,然后检查新的编译。

Pdflatex引擎的良好实践

  • your-filename.tex序言(Before \begin{document})中,请
    明确包含输入编码和字体编码。确保序言中提到的输入编码(latin1 或 utf8)是相同的作为当前的 TeX 编辑器编码。

  • .tex否则,当您保存文档时,可能会由于“TeX 编辑器编码”和当前文档上的“inputenc”不匹配而丢失数据。

  • 因此包括以下两行输入编码输出字体编码您为文档选择的格式。可能是 utf8x、utf8 或 latin1。

    \usepackage[latin1]{inputenc} or \usepackage[utf8]{inputenc} %input font encoding
    \usepackage[T1]{fontenc} % output font encoding
    
  • 使用unicode跨平台TeX编辑器,例如TeXworks和TeXmaker以及更多LaTeX 编辑器列表。它可以检测编码并可在所有平台上运行。

相关内容