LaTeX Script Structure

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

In general, a document structure may include the document title, paragraphs, chapters, sections, comments, table of contents, figures, tables, and other supporting elements.
Document Title
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:
\maketitleIf you do not want to use the current date, replace \today with any date you want.
Paragraphs
In a document, paragraphs are separated by one or more blank lines, or by using:
\parIf you want to start a new line without starting a new paragraph, use:
\\or
\newlineTo begin a new page, the common commands are:
\newpage
\clearpage
\cleardoublepage
\clearemptydoublepageCommands 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.
Chapters, Subchapters, and Sections
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
\backmatterTheir roles are:
\frontmatterfor preliminary pages such as the title page, preface, and table of contents,\mainmatterfor the main content,\backmatterfor 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}Example of a book Document Structure
\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}Comments
In , 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.
Table of Contents, List of Figures, and List of Tables
If your document uses structural commands such as \part, \chapter, and \section, the table of contents can be generated automatically with:
\tableofcontentsIf the document contains many figures and tables, you can also generate their lists with:
\listoffigures
\listoftablesClosing
That is a short overview of document structure. Once you understand the basic layout, writing a neat and consistent document becomes much easier.




