LaTeX Tutorial Series: Your First LaTeX Document

LaTeX
Creating your first LaTeX document
Author

Anthony

Published

April 14, 2026

In the previous article, Introduction to LaTeX, we covered how to choose a compiler and editor, along with the basic operations of LaTeX — entering commands, writing comments, opening environments, and setting section depth. In this article, you will learn:

Setting Up a LaTeX Document

A LaTeX working folder can be compared to a factory: blueprints, raw materials, and a production line — all are essential. The .tex file serves as the blueprint, describing the final product; fonts, images, and other assets are the raw materials used during production; the compilation process is the assembly line that arranges all the materials according to the blueprint and ultimately outputs a .pdf file. As for references (such as .bib files), they are supplementary materials that ensure the product is complete — without them, a report loses its citation foundation.

Before you start writing a LaTeX document, in addition to creating the .tex file, it is recommended to create additional folders to organise your assets by category — for example, images in images/ and fonts in fonts/. This has two advantages: first, it makes management easier, as you only need to browse the subfolders to see all your assets at a glance; second, it makes it easier for LaTeX to reference these files — if assets are scattered around, paths become complicated and errors are more likely to occur.

Folder Setup

The following is a recommended LaTeX project structure. The subfolders are not mandatory and can be adjusted based on your needs:

my-project/
├── main.tex          # Main document
├── references.bib    # References
├── images/           # Image assets
   ├── figure1.png
   └── figure2.pdf
├── fonts/            # Custom fonts
   └── custom.ttf
└── output/           # Compilation output
    └── main.pdf

Within this structure:

  • main.tex: The main document — the starting point of everything. LaTeX begins compilation here, where the document class (\documentclass{}), packages (\usepackage{}), and the overall structure are defined. For longer documents such as theses, individual chapters can be split into separate .tex files and imported into the main file using \input{} or \include{}1.

  • references.bib: A database file that stores your reference entries. Each entry records information such as the author, title, and year in a structured format. When used with BibTeX or BibLaTeX, you simply cite sources in the text using \cite{}, and the bibliography is automatically generated at the end of the document. Citation styles such as APA and MLA can also be applied as needed.

  • images/: A centralised folder for all image assets. LaTeX supports raster images (.png, .jpg) as well as vector graphics (.pdf, .eps). Vector graphics do not lose quality when scaled and are the preferred format for academic documents2. It is recommended to use descriptive filenames (e.g., fig-result-comparison.pdf) for easier maintenance.

  • fonts/: Stores custom font files (.ttf, .otf, etc.). This folder is only needed when compiling with XeLaTeX or LuaLaTeX, as these compilers can directly access system fonts or custom font files. If you are using the traditional pdfLaTeX, the font mechanism works differently and this folder is generally not required3.

    TipFont Recommendations by System
    • Windows: Fonts are typically installed in C:\Windows\Fonts\ and can be referenced directly by name in XeLaTeX — no need to copy them into the project folder.
    • macOS: Fonts are located in /Library/Fonts/ or ~/Library/Fonts/ and can also be referenced directly by name.
    • Linux: Font paths vary by distribution but are commonly found in /usr/share/fonts/. If fonts are not recognised, run fc-cache -fv to refresh the font cache.
  • output/: Stores all files generated during compilation, including the final .pdf and intermediate files such as .aux (cross-reference data), .log (compilation log), and .toc (table of contents data). Keeping all output here prevents these intermediate files from cluttering the project root directory4.

    TipOutput Configuration by System
    • VS Code (LaTeX Workshop): In settings.json, set "latex-workshop.latex.outDir": "%DIR%/output" to redirect all output to the output/ folder.
    • Overleaf: The cloud platform manages output automatically — no configuration needed.
    • Command line: Use xelatex -output-directory=output main.tex to specify the output directory.

Viewing the Folder Structure

If you want to quickly inspect the directory structure of your LaTeX project, you can use the tree command. Navigate to the project folder and run:

tree

The terminal will display the entire folder hierarchy in a tree format, for example:

my-project/
├── main.tex
├── references.bib
├── images/
   ├── figure1.png
   └── figure2.pdf
├── fonts/
   └── custom.ttf
└── output/
    └── main.pdf

To display only directories (without listing files), add the -d flag:

tree -d

To limit the depth of the output — for example, showing only two levels — use the -L flag:

tree -L 2
TipInstallation by System

tree is pre-installed on most Linux distributions. On macOS and Windows, it needs to be installed separately:

  • macOS: Install via Homebrew

    brew install tree
  • Windows: Install via Scoop:

    scoop install tree

    Or use the built-in PowerShell tree command5

Hands-On Practice

Now we will take the commands and techniques from the previous article, put them into action in the editor, and compile them into a .tex file that outputs as a .pdf. One thing to note: this section introduces the report class in advance to cover the concept of section depth6.

\documentclass{report}
\begin{document}

This is my first {\LaTeX} typesetting example.\\
This is my first \LaTeX{} typesetting example.\\
This is my first \LaTeX\ typesetting example.\\
I am Mr. Edward G.J. Lee, G.J. is a abbreviation of my name.\\
I am Mr.\ Edward G.J. Lee, G.J. is a abbreviation of my name.\\
Please see Appendix A. We will be there soon.\\
Please see Appendix A\null. We will be there soon.

\end{document}

Document Class Setup

In LaTeX, the document class determines the overall appearance and format of the document. Different classes are suited to different purposes. The three most commonly used standard classes are article, report, and book.

Every document must begin with the \documentclass command to specify the class and its options, for example:

\documentclass[12pt, a4paper, twoside]{article}

This command sets the font size to 12pt, the paper size to A4, and enables double-sided printing. Besides the three main classes, LaTeX also supports classes such as letter and standalone, as well as options like landscape for a horizontal layout. For a deeper look at the differences between document classes, refer to LaTeX documentclass options illustrated.

About Indentation

In the example above, you may notice that the first line of the document is automatically indented. This happens because LaTeX treats the content before the first line break as an introductory paragraph when no chapter or section has been defined yet. There are two ways to address this:

  • Add \noindent at the start of the first line to tell LaTeX not to indent that specific line. However, this only takes effect where the command is placed — other paragraphs will still follow the default indentation rules.
  • Add \parindent=0pt in the preamble to set the indentation to zero throughout the entire document, effectively removing all paragraph indentation.

Note that if your document requires every paragraph to be indented (such as an academic report), neither of the above methods is ideal, and you will need to adjust based on your specific requirements7.

The Document’s Identity Card: Title Page Information

The title page is the centrepiece of the entire document — it can be thought of as the document’s “identity card.” It records the title (the document’s name), the author (who created it), and the date (the document’s “birthday,” or the moment it first said “Hello, World!”).

In the report class, the title page appears as the first page of the document. In the standard LaTeX format, it includes the title, author, date, and acknowledgements. Let us look at the following example:

\documentclass{report}
\title{Report File}
\author{Noname\thanks{Thanks to the readers.}}
\date{\today}
\begin{document}

This is the first sentence in my \LaTeX\ file.

\chapter{First Chapter}
\section{Section}
...
\end{document}

After compiling, if you find that there is no title page at all, you have spotted the issue! Even after setting the title page information in the preamble, you must add \maketitle between \begin{document} and \end{document} for LaTeX to actually render that information in the document:

\documentclass{report}
\title{Report File}
\author{Noname\thanks{Thanks to the readers.}}
\date{\today}
\begin{document}
\maketitle

This is the first sentence in my \LaTeX\ file.

\chapter{First Chapter}
\section{Section}
...
\end{document}

Adding Chapter Headings

Adding chapter headings in LaTeX is very straightforward — there is no need to adjust font sizes manually; you simply use the corresponding command8. In the report class, \chapter{} adds a chapter, while \section{} and \subsection{} correspond to sections and subsections respectively. By default, LaTeX uses Arabic numerals for chapter numbering. If you do not want a number, add an asterisk (*) after the command — for example, \chapter*{} or \section*{} — and LaTeX will omit the number and display only the heading text.

\documentclass{report}          % Use the report class
\begin{document}                % Document begins

\chapter{Introduction}          % Numbered chapter

\section{Background Theories}   % Section

\subsection{Purpose}            % Subsection

\chapter*{Acknowledgements}     % Unnumbered chapter

\end{document}                  % Document ends

LaTeX automatically handles numbering, table of contents updates, and font sizing — the author only needs to focus on the content itself. The table below shows the full hierarchy of section commands:

Depth Command Description
-1 \part{} Part
0 \chapter{} Chapter (not available in article class)
1 \section{} Section
2 \subsection{} Subsection
3 \subsubsection{} Sub-subsection
4 \paragraph{} Paragraph
5 \subparagraph{} Subparagraph

Adding an Abstract

To add an abstract, use the abstract environment:

\documentclass{report}          % Use the report class
\title{Report File}             % Document title
% Author name; \thanks generates a footnote acknowledgement
\author{Noname\thanks{Thanks to the readers.}}
\date{\today}                   % Automatically inserts today's date
\begin{document}                % Document begins
\maketitle                      % Renders the title page

\begin{abstract}                % Abstract environment begins
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent varius neque vel
commodo aliquet. Integer ornare hendrerit ligula et ultricies...
\end{abstract}                  % Abstract environment ends

\chapter{Introduction}          % Chapter 1

\section{Background Theories}   % Section

\subsection{Purpose}            % Subsection

\chapter*{Acknowledgements}     % Unnumbered chapter

\end{document}                  % Document ends

Text inside the abstract environment is automatically indented on both sides. Note that only the article and report classes support abstract — the book class cannot use this environment. Additionally, in the report class, the abstract appears on its own page, has no page number, and is not included in the table of contents. This may differ from the formatting requirements of some academic journals or institutions, so please keep this in mind.

Adding Footnotes

LaTeX supports two types of notes: footnotes and marginal notes. Footnotes are numbered using Arabic numerals by default and appear at the bottom of the page. In the report/book class, numbering resets at each new chapter; in the article class, numbering is continuous throughout the document. Marginal notes have no number and use the normal font size. Since marginal notes involve package configuration and page margin settings, they are not covered in this article — only footnotes are introduced here.

To add a footnote, simply append \footnote{your footnote content} after the relevant text:

\documentclass{report}          % Use the report class
\title{Report File}             % Document title
% Author name; \thanks generates a footnote acknowledgement
\author{Noname\thanks{Thanks to the readers.}}
\date{\today}                   % Automatically inserts today's date
\begin{document}                % Document begins
\maketitle                      % Renders the title page

\begin{abstract}                % Abstract environment begins
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
\end{abstract}                  % Abstract environment ends

\chapter{Introduction}          % Chapter 1

Proin sed lorem sed est malesuada dictum...

\section{Background Theories}   % Section

Vivamus ut consequat nisl...

\subsection{Purpose}            % Subsection

% \footnote{} inserts a footnote directly after the text
Sed sagittis quis est in mollis.\footnote{Curabitur vel tortor a lorem commodo volutpat eget nec dui.}

\chapter*{Acknowledgements}     % Unnumbered chapter

Cras elementum dui a nulla volutpat...

\end{document}                  % Document ends

Exercises

Which document class does not support the \chapter{} command?

  • article
  • report
  • book
  • beamer

article does not support \chapter{}; its highest-level sectioning command is \section{}. Both report and book include \chapter{}. beamer also lacks \chapter{}, but it is a presentation class with an entirely different structure. This is why this chapter uses report to demonstrate the full range of sectioning depth.

After setting \title{}, \author{}, and \date{} in the preamble, which command must appear in the document body to actually output the title page?

  • \begin{title}
  • \titlepage
  • \maketitle
  • \printtitle

You must call \maketitle inside \begin{document} to render the title information set in the preamble. A common beginner mistake is to define \title{} and friends but forget \maketitle, resulting in a document with no title page at all.

The abstract environment is not available in which document class?

  • article
  • report
  • book
  • All three support it

book does not support the abstract environment — attempting to use it will throw an error. Both article and report support it, though with slightly different behaviour: in article, the abstract appears directly below the title; in report, it occupies its own unnumbered page and does not appear in the table of contents.

Using the report class, write a LaTeX document that includes: a title My Report, an author Your Name, today’s date, a short abstract, and a chapter named Introduction.

\documentclass{report}

\title{My Report}
\author{Your Name}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This is the abstract. It typically summarises the purpose, methods, and conclusions of the work.
\end{abstract}

\chapter{Introduction}

This is the body of the first chapter.

\end{document}

Key points: \maketitle must come after \begin{document}; the abstract environment follows immediately after \maketitle; \chapter{} is only available in the report and book classes.

Add a footnote to the following sentence, with the content “This is a sample footnote.”:

LaTeX is a typesetting system.
LaTeX is a typesetting system\footnote{This is a sample footnote.}.

\footnote{} is inserted directly after the word or phrase being annotated. LaTeX automatically numbers and typesets it at the bottom of the page. Note the punctuation placement: the full stop goes after \footnote{}, not before it.

Chapter Summary

This chapter started with setting up the project folder and concluded with a fully structured LaTeX document. Here is a summary of the key points covered:

  • Project structure: A well-organised LaTeX project should separate .tex files, images, fonts, and output into their own folders. The tree command can be used to inspect the folder structure at any time.
  • Document class: The \documentclass[]{} command determines the basic format of the document. article, report, and book are the three most commonly used classes.
  • Indentation control: Use \noindent for a single line, or set \parindent=0pt in the preamble to disable indentation document-wide. Choose based on your needs.
  • Title page: Set \title{}, \author{}, and \date{} in the preamble, then call \maketitle in the document body for the title page to appear.
  • Chapter structure: Commands such as \chapter{}, \section{}, and \subsection{} let LaTeX handle numbering and layout automatically. Adding * removes the numbering.
  • Abstract: Use the abstract environment — available only in the article and report classes.
  • Footnotes: \footnote{} is inserted inline in the text, and LaTeX automatically formats it at the bottom of the page.

The next article will cover LaTeX document environment configuration, including page layout, font selection, and package usage.

Back to top

Footnotes

  1. \input{} directly embeds the content of the target file, similar to copy-paste. \include{} starts the content on a new page and supports \includeonly{} for selective compilation, which is useful for speeding up builds in large documents.↩︎

  2. Vector graphics are typically exported as .pdf files from tools such as Inkscape or Illustrator, or drawn directly in LaTeX using packages like TikZ or PGFPlots.↩︎

  3. pdfLaTeX uses .tfm and .pfb font formats managed through packages such as fontenc and inputenc, which is a different font handling approach from XeLaTeX and LuaLaTeX.↩︎

  4. Some editors or compilation tools output intermediate files to the root directory by default. You may need to adjust the settings manually to redirect them to output/.↩︎

  5. The built-in Windows tree command (tree /F) has a slightly different format from the Unix version but can also display the full directory structure.↩︎

  6. The reason for using the report class is simple: the article class does not have \chapter, which makes it impossible to fully demonstrate section depth. Therefore, report is used here.↩︎

  7. Personal note: I personally dislike first-paragraph indentation and prefer the asymmetry that comes from indenting only subsequent paragraphs. That said, if your professor or supervisor has specific requirements, it is always safer to follow their instructions.↩︎

  8. In Word, you would need to manually adjust font sizes for each heading, which can easily lead to formatting issues. If you are unfamiliar with Word’s heading styles, refer to Word Layout Tips: Styles, Hierarchy, Table of Contents, Headers & Footers, Paragraphs.↩︎