Set Main Document
The main document in Overleaf is the file which LaTeX will be told to compile first. It is the main file of the project, which all other parts (classes, packages, chapters etc.) will be inputted into. When this is not set manually, Overleaf will choose a document in the project which includes the \documentclass[...]{...}
command. For this reason, if you have a separate file for your preamble, it is better not to include the \documentclass[...]{...}
command in the preamble file, but rather at the start of the main document. If you do not do this, only the preamble will be compiled. To set the main document on a project, simply click into the menu in the top lefthand corner:
and go to Main document:
See here to learn more about managing large projects in LaTeX.
Compiling several documents in the same project
To allow you to quickly compile different documents in the same project, Overleaf will compile whichever file is open in the editor as the main document once it includes the \documentclass[...]{...}
command. This is particularly convenient for editing with the subfiles
package.
Issues with main file selection
The main file should always be in the root directory (outside of any folders), to ensure that all of the compilation steps will be run in the correct directory and to ensure that the required auxiliary files are available, for instance, when adding an index. See some tips on reorganising your project to compile on Overleaf here.
If the selected main file is contained in a folder and there is a file of the same name in the root directory, the file with that name in the root directory will be compiled rather than the selection. E.g. , if version1/main.tex
is set as the main file but main.tex
is also in the project, main.tex
will be compiled. This problem is due to the way Latexmk is run on Overleaf. To avoid issues from this, give any files you will want to compile on Overleaf a unique name.
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips