Contents

LaTeX Script Structure

After installing LaTeX\LaTeX on your computer and getting familiar with document classes and packages, the next step is to start writing documents with a clear structure.

LaTeX script structure

In general, a LaTeX\LaTeX document structure may include the document title, paragraphs, chapters, sections, comments, table of contents, figures, tables, and other supporting elements.

The title, author name, and date can be written like this:

\title{Document Title}
\author{Author Name}
\date{\today}

Then display them in the document body with:

\maketitle

If you do not want to use the current date, replace \today with any date you want.

In a LaTeX\LaTeX document, paragraphs are separated by one or more blank lines, or by using:

\par

If you want to start a new line without starting a new paragraph, use:

\\

or

\newline

To begin a new page, the common commands are:

\newpage
\clearpage
\cleardoublepage
\clearemptydoublepage

Commands beginning with \clear will place pending floats such as figures or tables before creating the new page. \cleardoublepage is often used in book-style documents so a new major section starts on the right-hand page.

For the article document class, the common structure commands are:

\section{Section Name}
\subsection{Subsection Name}
\subsubsection{Subsubsection Name}
\paragraph{Paragraph Name}
\subparagraph{Subparagraph Name}

For the report and book document classes, there are additional commands:

\part{Part Name}
\chapter{Chapter Name}

These commands automatically generate numbering. If you want an unnumbered heading, use the starred form, for example:

\section*{Introduction}
\chapter*{Preface}

In the book class, large document divisions are usually marked with:

\frontmatter
\mainmatter
\backmatter

Their roles are:

  • \frontmatter for preliminary pages such as the title page, preface, and table of contents,
  • \mainmatter for the main content,
  • \backmatter for the final section such as bibliography, index, or glossary.

Example of an article Document Structure

\documentclass{article}
\title{Learning LaTeX}
\author{Aan Triono}
\date{\today}

\begin{document}
\maketitle

\section{Introduction}
Introduction text.

\section{Discussion}
\subsection{First Topic}
First topic text.

\subsection{Second Topic}
Second topic text.

\section{Closing}
Closing text.

\end{document}
\documentclass{book}
\title{Book Title}
\author{Author Name}
\date{\today}

\begin{document}
\frontmatter
\maketitle
\tableofcontents

\mainmatter
\chapter{Introduction}
First chapter content.

\chapter{Discussion}
\section{Topic One}
Topic one content.

\backmatter
\chapter*{Bibliography}

\end{document}

In LaTeX\LaTeX, comments start with the percent symbol % and continue to the end of the line.

% This is a comment and will not be printed
\section{Introduction}

Comments are useful for notes or for temporarily disabling code.

If your document uses structural commands such as \part, \chapter, and \section, the table of contents can be generated automatically with:

\tableofcontents

If the document contains many figures and tables, you can also generate their lists with:

\listoffigures
\listoftables

That is a short overview of LaTeX\LaTeX document structure. Once you understand the basic layout, writing a neat and consistent document becomes much easier.

Related Content