Page LayoutIncomprehensible Error about missing Begin of Document

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
eileenmcg
Posts: 2
Joined: Sat Sep 08, 2012 12:48 pm

Incomprehensible Error about missing Begin of Document

Post by eileenmcg »

Hi,

I'm a beginning user, so I think the answer to my problem might be simple, but I just can't figure it out. Every time I compile using PDFLaTeX (written in WinEdt, using MiKTeX) I get an error that \begin{document} is missing even though it is there. Here is the code and the error:

Code: Select all

\documentclass[12pt,a4paper,titlepage]{article}
\usepackage{graphicx}
\usepackage{booktabs}

\title{The Returns to University Education in Turkey by Disciplines}
\author{by Eileen Joyce McGivney}
\linespread{1.3}

\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
Here is the error message:

Code: Select all

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1 ï
     »¿\documentclass[12pt,a4paper,titlepage]{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!
In my PDF there is a blank page at the beginning, too.

From what I have read in other answers to this problem, either I have typed something wrong (left out a \ or something), or there is some problem with "BOM"s. I can't find any mistakes in my typing, and all the other advice I have read is pretty over my head. If this is a dumb question, I'm sorry, just a beginner. Also, I chose this forum because it appears to be a problem with the page formatting at the beginning but if I should post somewhere else please let me know.

Thanks in advance for any advice!
Eileen

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Incomprehensible Error about missing Begin of Document

Post by sommerfee »

First of all, "missing \begin{document}" doesn't mean that there is no \begin{document} somewhere in your document, but that you tried to typeset some text without a leading \begin{document}.

Here's your problem:
eileenmcg wrote:

Code: Select all

l.1 ï
     »¿\documentclass[12pt,a4paper,titlepage]{article}
"l.1" means line 1, so the error occurred in the very first line. Furthermore one see that there are at least two strange characters before \documentclass. Some text editors create such tag to indicate the character set used to typeset this text, e.g. UTF-8. TeX does not like that and try to treat it as text.

So the solution is telling your text editor it should not create such character set tag at the very beginning of the text file.
Last edited by cgnieder on Sat Sep 08, 2012 8:29 pm, edited 1 time in total.
eileenmcg
Posts: 2
Joined: Sat Sep 08, 2012 12:48 pm

Incomprehensible Error about missing Begin of Document

Post by eileenmcg »

Thanks so much for your help!

For anyone else experiencing the same problem, here's how I fixed it after poking around. In WinEdt 7:
  1. Go to "Document" > "Document Settings" > "Format"
  2. Un-check the box saying "Include Unicode BOM"
That fixed it and I no longer get an error or a blank page at the start of the document.

Thanks again.
CastroJFGF
Posts: 1
Joined: Sat Feb 22, 2014 12:16 pm

Re: Incomprehensible Error about missing Begin of Document

Post by CastroJFGF »

Had exactly the same problem. I use TeXnicCenter on windows 7. The characters are not displayed by the TeX editor, so I could not erase them. Neither Notepad or Wordpad showed up the strange characters. I finally discovered that opening the .tex file with Word (and selecting MS-DOS coding) displayed the characters. I could erase them and save back the file, solving the problem.

Hope this helps.
Jon E
Posts: 1
Joined: Sun Nov 23, 2014 9:35 am

Re: Incomprehensible Error about missing Begin of Document

Post by Jon E »

Ran into the exact same issue. One easy alternative to MS Word DOS encoding is to copy and paste into a web-based terminal. For instance, I've had great luck with sharelatex.com. That editor showed every character, including the ones that were tripping me up.
Post Reply