# “Undefined control sequence” at beginning of any simple document

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.

• you need to use pdflatex not pdftex as the command to process your document. – David Carlisle Aug 4 '15 at 12:48
• +1 for complete example document and complete posting of error message (I wish everyone would do that:-) – David Carlisle Aug 4 '15 at 12:50
• "pdflatex" worked. Figuring out what/where/how to install was the less obvious part. – Brad Aug 4 '15 at 12:53
• @Brad: TeXlive 2015 is available since about seven weeks, please consider to update. Is the topic solved now? – user31729 Aug 4 '15 at 13:02
• BTW, the most basic TeX that work with pdftex is " This is a test of the article \bye", but surely you want to start to play with LaTeX, not with plain TeX. – Fran Aug 4 '15 at 19:29

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)

I found out it might be also about how you give the filename as the argument.

## Did not work

pdflatex .\main.tex

## Did work

pdflatex main.tex