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:

This is a test of the article

Full error is:

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

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

  • 43
    you need to use pdflatex not pdftex as the command to process your document. Aug 4, 2015 at 12:48
  • 11
    +1 for complete example document and complete posting of error message (I wish everyone would do that:-) Aug 4, 2015 at 12:50
  • 1
    "pdflatex" worked. Figuring out what/where/how to install was the less obvious part.
    – Brad
    Aug 4, 2015 at 12:53
  • 3
    @Brad: TeXlive 2015 is available since about seven weeks, please consider to update. Is the topic solved now?
    – user31729
    Aug 4, 2015 at 13:02
  • 2
    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, 2015 at 19:29

1 Answer 1


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

% Typesetting and other code

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)

  • Upvoted. I've added full installation instructions and pdftex and pdflatex demos for Linux Ubuntu in my answer here. Your answer helped me figure out I needed to use pdflatex. Jun 17, 2023 at 18:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .