LaTeX forum ⇒ Page LayoutIncomprehensible Error about missing Begin of Document Topic is solved

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

Incomprehensible Error about missing Begin of Document

Postby eileenmcg » Sat Sep 08, 2012 1:06 pm

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:
  1. \documentclass[12pt,a4paper,titlepage]{article}
  2. \usepackage{graphicx}
  3. \usepackage{booktabs}
  4.  
  5. \title{The Returns to University Education in Turkey by Disciplines}
  6. \author{by Eileen Joyce McGivney}
  7. \linespread{1.3}
  8.  
  9. \begin{document}
  10. \maketitle
  11. \tableofcontents
  12. \section{Introduction}


Here is the error message:
  1. ! LaTeX Error: Missing \begin{document}.
  2.  
  3. See the LaTeX manual or LaTeX Companion for explanation.
  4. Type H <return> for immediate help.
  5. ...
  6.  
  7. l.1 ï
  8. »¿\documentclass[12pt,a4paper,titlepage]{article}
  9. ?
  10. Missing character: There is no ï in font nullfont!
  11. Missing character: There is no » in font nullfont!
  12. 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

Tags:

User avatar
sommerfee
Posts: 495
Joined: Mon Apr 09, 2007 4:20 pm

Postby sommerfee » Sat Sep 08, 2012 1:23 pm

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:
  1. l.1 ï
  2. »¿\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

Postby eileenmcg » Sat Sep 08, 2012 2:05 pm

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

Postby CastroJFGF » Sat Feb 22, 2014 12:29 pm

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

Postby Jon E » Sun Nov 23, 2014 9:38 am

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.


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 1 guest