Contents

LaTeX Document Structure

LaTeX has a document structure organized through document classes and supporting packages. These packages control many aspects of a document, including font size, page layout, table of contents, chapters, subsections, images, and text alignment. Because of that, choosing the right packages is important for improving the quality of your LaTeX\LaTeX document.

A LaTeX\LaTeX document has a basic structure marked by blocks enclosed by pairs of \begin and \end commands. A simple example is shown below:

\documentclass{article}

\begin{document}
Hello, world!
\end{document}

Each command in LaTeX\LaTeX begins with a backslash (\). In addition, every document should start with the command \documentclass{...} to define the type of document being processed.

There are several document classes in LaTeX\LaTeX, including the following.

  • article. The most common class for writing journal articles, academic papers, worksheets, and other documents without chapters.
  • report. Used for longer documents that contain chapters, sections, and subsections.
  • book. Used for writing books that consist of multiple chapters.
  • letter. Used for official letters.
  • beamer. Used for presentation documents.
  • slides. Used for presentations with large sans serif text.

The part between \documentclass[...] {...} and \begin{document} is called the preamble. In this section, you can declare the packages needed for your document. For example:

\documentclass[12pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{background}

Information:

  • babel. Used to set language rules in documents.
  • geometry. Used to define the layout of the document.
  • amsmath. Used for writing mathematics with more complete features.
  • amsymb. Used for mathematical symbols.
  • graphicx. Used to insert external images.
  • xcolor. Used to apply color in documents.
  • background. Used to add a document background.

The part between \begin{document} and \end{document} is called the document body. In this section, you can write plain text as well as LaTeX\LaTeX commands. For practice, copy the following code into your LaTeX\LaTeX editor, either online or offline.

\documentclass[12pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{xcolor}

\begin{document}
\section{Sample Document}
This is a sample \LaTeX\ document.

\textcolor{blue}{This text is blue.}
\end{document}

The compiled result will look like the following.

Sample compiled output of a LaTeX document structure

That concludes this overview of basic LaTeX\LaTeX document structure. I hope it provides a practical starting point for writing your own documents.

Related Content