Skip to main content

document-structure-layout

Document Structure and Layout

Document structure and layout address the "skeleton" of a document: how the title is set, how sections are divided, how the table of contents is generated, and how page layout and headers/footers are configured. These settings only need to be configured once and take effect throughout the document—this is the core advantage of LaTeX for long documents.

Title, Author, and Date

Three steps: declare the information in the preamble, then call \maketitle in the body to render it.

\documentclass{ctexart}

\title{Paper Title} % Title (required; must be defined to render the title area)
\author{Zhang San \and Li Si} % Authors; \and separates multiple authors
\date{\today} % Date: \today for today; {} empty argument hides the date

\begin{document}

\maketitle % Render the title area here (centered title, author, date)

\end{document}

CommandPurposeCommon Usage
\title{...}Declare titleManual line breaks with \\ allowed in title
\author{...}Declare authorZhang San \and Li Si; \thanks can add affiliation footnotes
\date{...}Declare date\today for today; fixed date handwritten; {} to hide
\maketitleRender title areaPlace at the beginning of the body

Section Commands and Automatic Numbering

Sections are the basic units of structured documents. LaTeX uses a set of commands to express hierarchy, and numbering is fully automatic.

CommandLevelApplicable Document Classes
\part{...}Part (level 0, independent numbering)article / report / book
\chapter{...}Chapter (level 1, starts on a new page)report / book only
\section{...}Section (level 1 in article)all
\subsection{...}Subsection (level 2)all
\subsubsection{...}Subsubsection (level 3)all
\paragraph{...}Titled paragraph (unnumbered)all

Two things best demonstrate the value of "automatic": first, inserting a new section in the middle automatically renumbers subsequent sections; second, adding a star (e.g., \section*{...}) means unnumbered and not included in the table of contents.

Example: Sections and footnotes

\documentclass{ctexart}
\begin{document}

\section{Introduction} This is the introduction content. All section numbers are generated automatically by LaTeX.

\subsection{Research Background} Research background is introduced here\footnote{This is a footnote; numbering and layout are automatic.}.
\subsection{Research Significance} Research significance is explained here.

\section{Method}
\subsection{Data Collection}
\subsubsection{Sample Selection} Hierarchy reaches the subsubsection level.
\subsection{Model Design}

\section{Conclusion}

\end{document}

\footnote{footnote content} places a marker at the current position and moves the content to the bottom of the page; numbering is continuous throughout the document, so footnotes cannot be nested inside other footnotes.

Generating a Table of Contents

A table of contents requires only one command: \tableofcontents. It scans all section commands in the document and automatically generates a page-numbered table of contents.

Example: Generating a table of contents

\documentclass{ctexart}
\renewcommand{\contentsname}{Contents}

\begin{document}

\tableofcontents
% Table of contents on its own page; body starts on the next page
\newpage

\section{Introduction}
Introduction content.

\subsection{Research Background}
Research background is introduced here.

\section{Method}
Method content.

\section{Conclusion}
Conclusion content.

\end{document}

Table of contents page numbers rely on the .aux file for propagation, so after adding new sections the table of contents may not be immediately correct; just compile again.

To control the depth of the table of contents, set in the preamble: \setcounter{tocdepth}{2} means only subsections are included; with \setcounter{secnumdepth}{2} you can simultaneously control numbering depth in the body.

Page Layout: The geometry Package

Page margins, paper size, and other page parameters are managed uniformly by the geometry package.

Example: Common page settings

% Option 1: options directly in the square brackets before the package name (most common when there are few options)
\usepackage[a4paper, margin=2.5cm]{geometry}

% Option 2: load first, then set centrally with \geometry (clearer when there are many options)
\usepackage{geometry}
\geometry{
a4paper, % Paper: A4
margin=2.5cm, % Uniform 2.5 cm margins on all sides
includefoot % Include footer in the type area to avoid footer "hanging" outside the margins
}

A4 page with 2.5 cm margins on all sides.

The type area (controlled by the geometry package; see the compiled PDF for the actual effect).

The two writing styles produce exactly the same result; choose either. Note that package options always go in square brackets []—writing options in curly braces {} is a common beginner mistake.

OptionMeaningExample
marginUniform margin on all sidesmargin=2.5cm
top / bottom / left / rightControl one side individuallyleft=3cm,right=3cm
a4paper / a5paper / letterpaperPaper sizea4paper
landscapeLandscape pageFor wide slides or wide tables
textwidth / textheightDirectly specify type area width/heighttextwidth=15cm

For domestic theses, the "symmetric odd-even binding" is common: add bindingoffset=1cm to leave an extra 1 cm on the binding edge.

Headers and Footers: The fancyhdr Package

fancyhdr divides headers and footers into left, center, and right slots; you can fill them with whatever you want.

CommandControlled Slot
\fancyhead[L]{...}Header left
\fancyhead[C]{...}Header center
\fancyhead[R]{...}Header right
\fancyfoot[L]{...}Footer left
\fancyfoot[C]{...}Footer center
\fancyfoot[R]{...}Footer right

Example: Classic academic header and footer

\documentclass{ctexart}
\usepackage[a4paper, margin=2.5cm]{geometry}
\usepackage{fancyhdr}

\pagestyle{fancy} % Enable fancyhdr page style
\fancyhf{} % Clear all slots first to avoid residual default page numbers
\fancyhead[L]{\nouppercase\leftmark} % Header left: current top-level section name
\fancyhead[R]{Page \thepage} % Header right: page number
\fancyfoot[C]{ LaTeX Guide} % Footer center: custom text
\renewcommand{\headrulewidth}{0.4pt} % Thickness of the line below the header

\begin{document}

\section{Page Layout}
The distance between text and page is controlled by the geometry package, including margins, paper size, and header/footer areas.
Reasonable page margins make documents more readable; academic documents usually require about 2.5 cm top/bottom and 2.5 cm left/right.
Once page layout parameters are set in the preamble, they take effect automatically throughout the document; no per-page adjustment is needed.

\section{Headers and Footers}
fancyhdr divides the header and footer into left, center, and right slots, allowing free combinations.
Headers often hold section names and page numbers, while footers often hold page numbers or document names; academic journal templates have strict rules.
Page numbers increase automatically with each page; page numbers in cross-references are also provided by it.

\end{document}

\markright and \leftmark are two "dynamic bookmarks"; when typesetting each page, LaTeX automatically records the current section and writes it into the corresponding bookmark; page numbers are updated accordingly.

CommandPurposeUsage Suggestion
\newpageEnd current page, continue from new pageRecommended for daily use
\clearpageNew page and first output all pending floatsSafer at end of chapters or document
\linebreakForce line break here with justified alignmentUse sparingly; let LaTeX break lines automatically
\pagebreakSuggest a page break here (contrast with \nopagebreak)Use sparingly

Do not frequently use \newpage to "align" pages—let LaTeX paginate automatically so the document does not become misaligned when edited. Manual page breaks are only for structural breakpoints, such as after the table of contents or between chapters.

Summary

FunctionCommand / PackageLocation
Title area\title / \author / \maketitleDeclared in preamble, rendered in body
Sections\section / \subsection / \subsubsectionBody
Footnotes\footnote{...}Body (usually right after text)
Table of contents\tableofcontentsAfter preamble, before body
Page marginsgeometry packagePreamble
Headers/footersfancyhdr packagePreamble