How to Write a Book in LaTeX
Updated July 2026
To write a book in LaTeX, use the book class (or memoir for more control). Organise the file with \frontmatter, \mainmatter, and \backmatter, split each chapter into its own file loaded with \include, and structure content with \part and \chapter. Compile with latexmk so the table of contents and cross-references resolve across the whole book.
Step by step
- 1
Choose book or memoir
book is the standard two-sided class; memoir adds fine control over design.
- 2
Divide front/main/back matter
Use \frontmatter, \mainmatter, \backmatter for correct numbering.
- 3
One file per chapter
Load each chapter with \include{chapters/ch01} to keep the project manageable.
- 4
Add parts and a TOC
Group chapters with \part and generate contents with \tableofcontents.
- 5
Compile
latexmk runs the passes needed for the TOC, index, and references.
1. Choose the class
The book class is the standard choice: it is two-sided, starts chapters on the right, and supports \part. The memoir class is a superset with extensive control over page design, chapter styles, and captions — pick it if you want to design the look yourself.
\documentclass[11pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\part{Foundations}
\include{chapters/ch01}
\include{chapters/ch02}
\backmatter
\printindex
\end{document}2. Front, main, and back matter
\frontmatter switches to Roman page numbers and unnumbered chapters (preface, contents). \mainmatter restarts Arabic numbering for the body. \backmatterkeeps numbering but stops numbering chapters, which suits the bibliography and index.
3. One file per chapter
Keep each chapter in its own .tex and load it with \include. While drafting,\includeonly{chapters/ch03} compiles just that chapter while preserving page and reference numbers — a big time-saver on a long book.
Big books compile slowly on desktop TeX; LetX compiles on cloud workers so even a long manuscript builds in seconds. See also table of contents and headers & footers.
Frequently asked questions
Should I use the book or memoir class?
Use book for a standard two-sided book. Use memoir when you want detailed control over page layout, chapter styling, and captions — it is a superset of book with many design hooks.
How do I split a book into chapters?
Put each chapter in its own .tex file and load it with \include{chapters/ch01}. Use \includeonly while drafting to compile a single chapter without losing page and reference numbers.
How do I set up two-sided printing?
Pass the twoside option to the class: \documentclass[twoside]{book}. Chapters then start on right-hand (odd) pages and margins alternate for binding.
Why is my book slow to compile?
Long documents run many passes over lots of content. Use \includeonly while writing, and a cloud editor like LetX that compiles on dedicated workers to keep builds fast.
Try this in LetX now
Open the editor, paste the example, and compile in 1 second — free, in your browser.
Start Writing Free