63

Very new to Tex. Trying to get the most basic doc to work. Not matter what I do I always get an "Undefined control sequence" at line 1 of my document. As of now, I am only trying to build the following:

\documentclass{article}
\begin{document}
This is a test of the article
\end{document}

Full error is:

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
(./example.tex
! Undefined control sequence.
l.1 \documentclass
                  {article}
?

I have tried many other variations, including \usepackage directives that people mentioned - nothing every varies.

Brad
  • 765

1 Answers1

41

Each LaTeX document has basically this structure (which will not run though, since packageA and packageB are not valid packages (as far as I know!)

\documentclass{book}  % Replace book with some other class 

\usepackage{packageA}  % Load package named packageA
\usepackage{packageB}  % Load package named packageB

% Some other definitions to follow, i.e. user defined counters, lengths

\begin{document}
% Typesetting and other code
\end{document}

This can't be compiled with pdftex -- Use either latex, pdflatex, xelatex or lualatex for this.

Each of the commands above are LaTeX format additions, completely unknown to pdftex and its variants, so pdftex stops at \documentclass already.

Packages always must have the ending .sty, so e.g. hyperref.sty, it's sufficient to use \usepackage{hyperref} then.

It is possible to load code contained in other files than having the .sty extension by saying \input{foo} (foo.tex is another ASCII - file then) basically at any position in the document, either in the preamble or in the document body.

The part including \documentclass downto \begin{document} is called preamble, the part between \begin{document}...\end{document} is the document body. Typesetting is allowed in the body only. Preamble commands like \documentclass, \usepackage etc. mustn't be used in the body.

The above document would not do anything so far (depending on the packages of course)