Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

I'm running into an error recently and am unsure why I get it.

Running this script:

\documentclass{article}

\begin{document}
hello
\end{document} 

I get this error message (question being how do I fix this?):

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)
share|improve this question

marked as duplicate by Werner, Tyler Rinker, Stefan Kottwitz Mar 4 '13 at 7:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
There is some character sitting infront of \documentclass{article}. Try typing the document from a new.tex document without copy-paste from old one and check the new compilation. –  texenthusiast Mar 4 '13 at 5:15
    
I updated too at the same time and using your advice the issue is gone. Please put as an answer for future searchers. +1 –  Tyler Rinker Mar 4 '13 at 5:27
1  
i have added the answer with some good practice details. It can be improved as and when time progresses. I was a victim of encoding issues in first days. –  texenthusiast Mar 4 '13 at 5:53

1 Answer 1

up vote 3 down vote accepted

There is some character sitting infront of \documentclass{article}. Try "typing" the document from a new.tex document without "copy-paste" from old one and check the new compilation.

Good practice for Pdflatex engine:

  • In your-filename.tex preamble (Before \begin{document}) please include the
    input encoding and font encoding explicitly. Make sure that input encoding (latin1 or utf8) mentioned in the preamble is same as the current TeX Editor encoding.

  • Otherwise you may lose data due to mismatch between the 'TeX Editor encoding' and 'inputenc' on the present .tex document' when you save it.

  • Hence include these two lines based on input encoding and output font encoding which you choose for your document. it may be utf8x, utf8 or latin1.

    \usepackage[latin1]{inputenc} or \usepackage[utf8]{inputenc} %input font encoding
    \usepackage[T1]{fontenc} % output font encoding
    
  • Use a unicode Cross-platform TeX editor for example TeXworks and TeXmaker and many more from the LaTeX editors list. It can detect the encoding and will work on all platforms.

share|improve this answer
    
“There is some character sitting infront”: Unicode Byte order mark (English Wikipedia). –  Speravir Mar 4 '13 at 17:58

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