LaTeX template for a thesis: setup and structure
The best LaTeX template for a thesis is your university's own class or template, if it has one. If it doesn't, start from the report class with a short preamble, one file per chapter, roman page numbers before Chapter 1 and Biber for the references. Below is a template I compiled and checked line by line, how to set it up in Overleaf, and the fixes for the errors that stop a thesis compiling.
- Look for an official LaTeX template on your graduate school's or library's thesis page. Use it if it exists, and check it against the current written guide.
- No official template? In Overleaf, click New project › Blank project and paste the template from section 03, built on
\documentclass[12pt,a4paper]{report}. - Create the folders
frontmatterandchapterswith the New folder button above the file list, then add the filesmain.texasks for:titlepage.tex,abstract.tex, one file per chapter (brought in with\include{chapters/01-introduction}) andreferences.bib. Section 03 shows each one. - Click Recompile. If
??or a bare citation key is still there, click it once more: the contents, cross-references and citations need more than one LaTeX run to fill in.
01Which LaTeX thesis or dissertation template to use
The right LaTeX template for a thesis is, in order: your university's official class or template, then a template your department or graduate school recommends, then a plain report class document that you set to your university's written guide. The written guide always wins. A template is only a starting point that someone set to that guide at some point in the past.
A document class is the file named in \documentclass{…} on the first line. It decides which commands exist (for example, whether \chapter works) and the default page layout. A template is a ready-made project built on a class, with a title page, a preamble and empty chapters.
University templates in the Overleaf gallery
Overleaf's gallery has a Theses category with thousands of entries, many of them named after a university. Some are official, published or approved by the university. Many are not: entries such as "University of Michigan Dissertation Template (Unofficial)" say so in the title. An unofficial template was written by a student or a department to match the rules on the day it was made, and nobody has to update it when the rules change.
Before you write a word in a gallery template, open your university's current thesis guide and check four things in the PDF it produces: the margins, the order of the front pages, the page numbering, and the reference style. In LaTeX theses that reach me, the problems rarely sit in the chapters. They sit in a template inherited from an older student, set to a guide that has since changed.
No template? Choose a class
If your university offers no LaTeX template, use one of the standard classes. The LaTeX2e reference manual describes report as the class "for documents of length between an article and a book, such as technical reports or theses", and book as the class for full-length books with chapters and front matter. Both have \chapter. The article class does not: \chapter in an article stops with "Undefined control sequence".
| Class | \chapter | \frontmatter | Default layout | Good for |
|---|---|---|---|---|
| report | Yes | No | One-sided, chapters start on any page, separate title page | Most theses, printed one-sided or submitted as PDF |
| book | Yes | Yes | Two-sided, chapters start on a right-hand page | Theses printed and bound two-sided |
| memoir | Yes | Yes | Book-like, with many layout commands built in | Writers who want fine control without extra packages |
| article | No | No | Sections only | Papers, not theses |
oneside, openany, titlepage; book: twoside, openright). I compiled each \chapter and \frontmatter claim in TeX Live 2025.My default for a thesis is report. It is in every LaTeX installation, it behaves predictably, and most university templates are built on it or on book. If your guide asks for two-sided printing with chapters on right-hand pages, use book, or add twoside,openright to report's options.
02Set up an Overleaf thesis template
An Overleaf thesis template takes four steps to set up: New project, the thesis category under Templates, the template's thumbnail, then Open as Template. Overleaf makes your own copy, which you edit and compile in the browser. Nothing has to be installed on your computer. A new blank project compiles with pdfLaTeX, Overleaf's default; a template may be set to another compiler, which you can see under File › Settings.
Start from a gallery template
- On the Overleaf project dashboard, click New project.
- Under Templates, click the thesis category. It opens the Theses gallery. You can also search the gallery at overleaf.com/gallery for your university's name.
- Click a template's thumbnail to see its details, then click Open as Template. Your own copy opens in the editor.
- Click Recompile before you change anything, so you know the untouched template compiles.
Start from your own files
- For a new project from the template in this guide, click New project › Blank project, name it, and replace the contents of
main.tex. - To bring an existing thesis folder in, zip it and click New project › Existing project (.zip). Overleaf keeps the folder structure. Its limits: no single file over 50 MB, up to 180 files per upload, 2000 files per project, and no more than 7 MB of editable material in the zip.
Choose the compiler
Overleaf compiles with pdfLaTeX unless you change it. To change it, open File › Settings (or the gear icon), click Compiler and pick from the Compiler list: pdfLaTeX, LaTeX, XeLaTeX or LuaLaTeX. Keep pdfLaTeX for the template in this guide. Switch to XeLaTeX or LuaLaTeX only if you need TrueType or OpenType fonts (for example, a guide that names a specific font) or non-Latin scripts. Overleaf recommends those two for non-Latin scripts and notes that both support TrueType and OpenType fonts. The same settings panel has the TeX Live version, and Overleaf recommends the most recent one for new projects.
The same files compile on your own computer with a TeX distribution such as TeX Live. I tested the template below with TeX Live 2025 and latexmk -pdf main.tex, which runs pdfLaTeX, Biber and pdfLaTeX again until everything settles.
03A LaTeX thesis template that compiles
This LaTeX thesis template is a main.tex file of about 40 lines, built on the report class. It gives you a title page without a number, roman page numbers (i, ii, iii) for the abstract and lists, arabic numbers from Chapter 1, an automatic contents page, APA 7 references, and one file per chapter. I compiled it with pdfLaTeX and Biber in TeX Live 2025: three passes, no errors, no warnings.
\documentclass[12pt,a4paper]{report}
% Language, fonts and page layout
\usepackage[T1]{fontenc}
\usepackage[british]{babel}
\usepackage[left=30mm,right=25mm,top=25mm,bottom=25mm]{geometry}
\usepackage{setspace}
\onehalfspacing
% Figures, tables and lists
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{booktabs}
\usepackage[nottoc]{tocbibind}
% References in APA 7 (compiled with Biber)
\usepackage{csquotes}
\usepackage[backend=biber,style=apa]{biblatex}
\addbibresource{references.bib}
\usepackage{hyperref} % load it last
\begin{document}
\pagenumbering{gobble}
\input{frontmatter/titlepage}
\pagenumbering{roman}
\input{frontmatter/abstract}
\tableofcontents
\listoffigures
\listoftables
\cleardoublepage
\pagenumbering{arabic}
\include{chapters/01-introduction}
\include{chapters/02-literature-review}
\printbibliography[heading=bibintoc,title={References}]
\appendix
\include{chapters/appendix-a}
\end{document}
What each part does
12pt,a4papersets the body text size and the paper. The report class also accepts10pt(its default) and11pt. Useletterpaperin North America if your guide asks for US Letter.babelwithbritishselects British English, including its hyphenation patterns.fontencwithT1loads a font encoding that contains accented letters as single characters, which the LaTeX font guide gives as the reason words with accented letters, such as "Universität", can be hyphenated.geometrysets the four margins.setspaceprovides\singlespacing,\onehalfspacingand\doublespacing; use the one your guide sets.tocbibindadds the lists of figures and tables to the contents. Thenottocoption stops the contents from listing itself.biblatexwithstyle=apaloads biblatex-apa, which implements APA 7th edition citations and references and needs the Biber backend.csquotesremoves the warning biblatex gives when babel is loaded.hyperrefmakes the contents, citations and cross-references clickable in the PDF. Its manual says to load it after every other package, because its job is to redefine many LaTeX commands.\cleardoublepageends the front matter. In a one-sided thesis it simply starts a new page; withtwosideit also makes Chapter 1 start on a right-hand page.
The title page and abstract live in their own files, as in Part 5 of Overleaf's thesis series. A minimal frontmatter/titlepage.tex:
\begin{titlepage}
\centering
\vspace*{2cm}
{\LARGE\bfseries Brand trust and customer loyalty\\
in subscription services\par}
\vfill
{\large Your Name\par}
\vspace{1cm}
A thesis submitted for the degree of Master of Science\par
\vspace{1cm}
Month Year
\end{titlepage}
Your university's guide sets what goes on the title page and in what order: the full title, your name, the degree, the faculty, the month and year, sometimes a logo or a declaration. The asterisk in \vspace* keeps the space at the top of the page, where LaTeX would otherwise drop it, and \vfill pushes the lines below it to the bottom. My guide to the thesis title page lists what universities usually require.
The abstract file starts with \chapter*{Abstract} followed by \addcontentsline{toc}{chapter}{Abstract}, and then the text. The starred command gives an unnumbered heading, and the second line puts it in the contents, which starred headings skip.
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
This study tests how brand trust shapes loyalty among subscribers.
Each chapter file holds only its chapter. chapters/02-literature-review.tex and chapters/appendix-a.tex follow the same pattern as the introduction, each with its own \chapter{…} line:
\chapter{Introduction}
\label{ch:intro}
\section{Background}
\textcite{morgan1994} define trust as confidence in a
partner's reliability and integrity.
The last file, references.bib, holds the reference library; the entry the template cites is shown in section 06.
main.tex compiles only once every file it names exists: a missing \input file stops the compile with a "File not found" error. I compiled exactly these files and that entry, starting from an empty folder, with no errors and no warnings.
Your university's template, a 150-page draft and two weeks left?I can set it up for you
04The structure of a thesis in LaTeX
A thesis in LaTeX has three parts in main.tex: front matter with roman page numbers (title page, abstract, contents, lists), the chapters with arabic numbers restarting at 1, and the end matter (references and appendices), whose numbers carry on from the last chapter. \pagenumbering{roman} and \pagenumbering{arabic} switch the style, and each one restarts the count at 1.
\include line each. The title page shows no number, the abstract, contents and lists run i to iv, \pagenumbering{arabic} restarts the count at 1 for Chapter 1, and the references and Appendix A carry on from the last chapter.Front matter
The front matter is everything before Chapter 1: title page, declaration, abstract, acknowledgements, contents, lists of figures and tables, abbreviations. Your university's guide sets which of these you need and their order. Each one is an unnumbered chapter (\chapter*{Acknowledgements}), with \addcontentsline if it should appear in the contents.
The title page prints no number because it uses the titlepage environment. The template also starts with \pagenumbering{gobble}, the style the LaTeX2e reference manual lists as outputting no page number. Without it, the title page counts as arabic page 1, the same as Chapter 1, and hyperref warns about two pages with the same identifier (see section 07). After the title page, \pagenumbering{roman} numbers the abstract i. Many guides count the title page as page i without printing it, so the abstract is ii. In that case, add \setcounter{page}{2} straight after \pagenumbering{roman}.
Use \frontmatter before the title page, \mainmatter before Chapter 1 and \backmatter before the references instead of the two \pagenumbering lines. The LaTeX2e reference manual: \frontmatter numbers pages in lowercase roman and stops chapters being numbered; \mainmatter resets the page number and turns chapter numbers back on. Report doesn't have these commands.
Chapters, sections and how deep the numbering goes
In the report class the heading levels are \chapter, \section, \subsection, \subsubsection, \paragraph and \subparagraph. Overleaf's sectioning guide numbers them 0 to 5, with \part at −1 above them. In the sample thesis, \chapter{Literature review} becomes Chapter 2, \section{Brand trust} becomes 2.1 and \subsection{Defining trust} becomes 2.1.1.
LaTeX numbers headings down to the level set by the secnumdepth counter. In the report and book classes, \subsubsection (level 3) isn't numbered by default; \setcounter{secnumdepth}{3} in the preamble numbers it. How many levels the contents lists is a separate counter, tocdepth, covered with the rest of the contents page in my guide to the LaTeX table of contents and lists of figures.
End matter
\printbibliography[heading=bibintoc,title={References}] prints the reference list under the heading your guide uses (References or Bibliography) and adds it to the contents. \appendix switches chapter numbering to letters, so the next \chapter{Survey items} becomes Appendix A. Whether appendices come before or after the references depends on your style and university; my guide to thesis structure covers the usual orders.
05One file per chapter: \include and \input
Writing a thesis in LaTeX is easier with one .tex file per chapter. \include{chapters/02-literature-review} starts the chapter on a new page, keeps a separate auxiliary file for it, and works with \includeonly, which compiles only the chapters you name while keeping the page numbers and cross-references of the rest. \input pastes a file in place with no new page.
The folder for the template looks like this:
main.tex
references.bib
frontmatter/
titlepage.tex
abstract.tex
chapters/
01-introduction.tex
02-literature-review.tex
appendix-a.tex
images/
A chapter file holds only the chapter: it starts with \chapter{Introduction} and has no \documentclass and no \begin{document}. The LaTeX2e reference manual sets three limits on \include: it can only appear in the document body, \includeonly must go in the preamble, and you can't use \include inside a file that is itself being included.
- Use
\includefor chapters and appendices. Each starts on a new page anyway. - Use
\inputfor the title page, the abstract, or a large table kept in its own file, anywhere a new page would be wrong. - Use
\includeonly{chapters/02-literature-review}in the preamble while you work on one chapter of a long thesis. Compile the whole thesis once first, so the auxiliary files of the other chapters exist.
Overleaf also documents the subfiles package, which lets each chapter compile on its own as well as inside main.tex. It is useful when a supervisor wants single chapters as PDFs, but every chapter file then needs its own \documentclass[../main.tex]{subfiles} line and has to sit between \begin{document} and \end{document}. For most theses \include is enough.
06References, figures, tables and margins
The rest of a LaTeX thesis is built from a handful of packages: biblatex (or BibTeX with natbib) for references, graphicx for figures, booktabs and longtable for tables, geometry for margins. Each has its own guide on this site. This section gives the one fact about each that most often goes wrong in a thesis, and where to read more.
References
References come from a .bib file, a plain-text library with one entry per source. In a chapter, \parencite{morgan1994} prints (Morgan & Hunt, 1994) and \textcite{morgan1994} prints Morgan and Hunt (1994) with the template's APA style. The entry behind both:
@article{morgan1994,
author = {Morgan, Robert M. and Hunt, Shelby D.},
title = {The commitment-trust theory of relationship marketing},
journal = {Journal of Marketing},
year = {1994},
volume = {58},
number = {3},
pages = {20--38},
doi = {10.1177/002224299405800302}
}
Citations need an extra program between LaTeX runs: Biber for biblatex, BibTeX for natbib and the older styles. When I compile the template, latexmk runs pdfLaTeX, then Biber, then pdfLaTeX twice more. On Overleaf, click Recompile, and again if a citation still shows as its key. Choosing between BibTeX, biblatex and natbib is in my guide to the LaTeX bibliography, writing entries for every source type in BibTeX entries and citations, and the APA settings in biblatex-apa for APA 7.
Figures, captions and tables
Figures and tables are floats: LaTeX moves them to where they fit, so refer to them by number (Table~\ref{tab:sample}), never as "the table below". Put \label after \caption, so the label picks up the caption's number. The details are in my guides to figures in LaTeX, captions in LaTeX, LaTeX tables and long tables across pages. In the report class, figures and tables are numbered by chapter (Table 1.1, Figure 2.1), which many thesis guides ask for; check yours, because some want continuous numbering (Table 1, Table 2).
Margins and page numbers
Margins are one line of geometry options. Overleaf's thesis series also shows bindingoffset=6mm, extra space on the bound edge for a printed copy; check whether your guide's left margin already includes the binding. Thesis guides differ widely here, so take the numbers from yours. My guides to LaTeX margins for a thesis and LaTeX page numbering cover the settings and where the numbers sit on the page.
Two hundred references and a guide that wants a house style?I can format the LaTeX side for you
07LaTeX thesis errors and how to fix them
Most LaTeX thesis errors fall into a few groups: references and citations that haven't been resolved yet (they show as ?? or as the bare citation key), a command LaTeX doesn't know ("Undefined control sequence"), a character that only works in maths ("Missing $ inserted"), and on Overleaf, a compile that runs out of time. I reproduced each one below with the template.
?? instead of a number, or a citation key instead of the author
LaTeX writes labels and citations to auxiliary files on one run and reads them on the next, so ?? after a single run is normal. The log says "Label(s) may have changed. Rerun to get cross-references right" and "Please (re)run Biber". On Overleaf, click Recompile; offline, run latexmk -pdf main.tex. If one ?? stays, Overleaf's guide to undefined references gives the cause: the name in \ref{…} doesn't match any \label{…} exactly, often a typo such as tab:sample against tab:samples. A citation key that stays as a key is missing from the .bib file, or is spelt differently there.
"Undefined control sequence"
LaTeX met a command it doesn't know. Overleaf's guide lists three causes: a typo in the command, a command whose package isn't loaded, and a backslash in ordinary text, such as a Windows file path. In theses I see two more: \chapter in a document that uses the article class, and \frontmatter in one that uses report. The log line shows the file and line number, and the unknown command is the last thing printed on the line below the message.
"Missing $ inserted"
TeX met a character or command that only works in maths mode. The usual culprit in a thesis is an underscore in ordinary text: a variable name such as brand_trust or a file name. Write brand\_trust, or put URLs in \url{…}, which the template's hyperref package already provides. A blank line inside an equation environment, or $ signs inside align, cause the same error.
The compile times out on Overleaf
Overleaf's own steps, in order: turn on Stop on first error under the Recompile drop-down and fix the first error, because a pile of errors can block the build; then try Fast [draft] from the same menu, which replaces images with boxes. If the draft compiles and the normal one doesn't, the images are the problem: Overleaf advises PDF files for diagrams and plots and JPEG only for photographs. For a long thesis, \includeonly also cuts the work while you write.
The contents or a list is empty or out of date
The contents, the lists of figures and tables, and the reference list are all written on one run and read on the next. Overleaf's guide to lists of tables and figures notes that the document may need compiling twice. If they still don't change after a full compile, choose Recompile from scratch in the Recompile drop-down; offline, run latexmk -C and compile again.
"destination with the same identifier (name{page.i})"
This hyperref warning appears when two pages carry the same number in the same style, typically a title page and an abstract both numbered i, or a title page and Chapter 1 both numbered 1. The PDF links still work, but clicks can land on the wrong page. In the template, \pagenumbering{gobble} before the title page removes it; I added that line after my first test compile printed this warning.
Fighting LaTeX the week before submission?I can take the LaTeX formatting off your hands
08LaTeX or Word for a thesis?
LaTeX suits a thesis with many equations, cross-references and citations, and a writer who prefers plain-text files that work well with version control. Word suits a thesis that supervisors edit with tracked changes, or a university that supplies only a Word template. Both produce a correct thesis when the styles and settings are right; the university's guide decides the format, not the program.
Check one thing before you start in LaTeX: whether your supervisors, examiners or the repository need a Word file at any stage. Converting a finished LaTeX thesis to Word loses some layout, and converting a Word draft to LaTeX means rebuilding the citations. My guides to converting LaTeX to Word and converting a Word document to LaTeX show what survives each way. If only the equations matter and the thesis is in Google Docs, the guide to LaTeX equations in Google Docs is enough.
Whichever you choose, the formatting rules are the same. My thesis formatting checklist lists them, from front matter to final checks, and works for a LaTeX thesis as well as a Word one.
09Questions people ask
Is there an official LaTeX template for my university?
An official LaTeX thesis template, if your university has one, is linked from the graduate school's or library's thesis formatting page. Overleaf's gallery also lists many university templates, but some are marked "Unofficial", so check any template against the current written guide.
Which document class is best for a PhD dissertation in LaTeX?
For a PhD dissertation in LaTeX without a university class, report is the safest choice for a one-sided PDF, and book (or memoir) for a two-sided printed copy with chapters on right-hand pages. The article class has no \chapter command, so it doesn't suit a dissertation.
Can I write a thesis in LaTeX without installing anything?
Yes. Overleaf compiles a LaTeX thesis in the browser with TeX Live, so nothing needs installing. The same project downloads as a zip and compiles offline with TeX Live and latexmk if you later want to work on your own computer.
Should I use pdfLaTeX, XeLaTeX or LuaLaTeX for a thesis?
pdfLaTeX, Overleaf's default, is fine for a thesis in English with the standard fonts. XeLaTeX or LuaLaTeX are the compilers to use when the guide names a TrueType or OpenType font, or the thesis includes non-Latin scripts.
How do I make the abstract page number ii instead of i?
To number the abstract ii, add \setcounter{page}{2} right after \pagenumbering{roman}. The title page then counts as page i without showing a number, which is what many university guides ask for.
Can I use APA 7 in a LaTeX thesis?
Yes. The biblatex-apa style implements APA 7th edition citations and references; load it with \usepackage[backend=biber,style=apa]{biblatex} and compile with Biber. APA's rules for headings, tables and figures still have to be set separately.
I compiled the template and every error in section 07 with TeX Live 2025 (pdfTeX 1.40.27, Biber, latexmk) on Windows 11, and tested the class claims in Figure 1 the same way. Overleaf steps come from Overleaf's documentation and its thesis series; LaTeX behaviour from the LaTeX2e reference manual and the CTAN package pages. All pages are listed under Sources.
Sources
- How to Write a Thesis in LaTeX (Part 1): Basic Structure Overleaf
- How to Write a Thesis in LaTeX (Part 2): Page Layout Overleaf
- How to Write a Thesis in LaTeX (Part 4): Bibliographies with BibLaTeX Overleaf
- How to Write a Thesis in LaTeX (Part 5): Customising Your Title Page and Abstract Overleaf
- LaTeX templates: Theses Overleaf gallery
- Creating a project from a template Overleaf docs
- Uploading a project Overleaf docs
- Selecting a TeX Live version and LaTeX compiler Overleaf docs
- Recompiling your project Overleaf docs
- Fixing and preventing compile timeouts Overleaf docs
- Sections and chapters Overleaf
- Page numbering Overleaf
- Multi-file LaTeX projects Overleaf
- Bibliography management with biblatex Overleaf
- Lists of tables and figures Overleaf
- There were undefined references Overleaf
- Undefined control sequence Overleaf
- Missing $ inserted Overleaf
- Document classes LaTeX2e reference manual
- Document class options LaTeX2e reference manual
- \frontmatter, \mainmatter, \backmatter LaTeX2e reference manual
- \pagenumbering LaTeX2e reference manual
- \include & \includeonly LaTeX2e reference manual
- Cross referencing sections, equations and floats Overleaf
- Your first project Overleaf docs
- LaTeX2e font selection LaTeX Project
- hyperref (and its manual, Hypertext marks in LaTeX) CTAN
- babel CTAN
- biblatex-apa CTAN
- tocbibind CTAN
- setspace CTAN
- memoir CTAN