The main file
Every compile starts from one .tex file, the main file. It holds \documentclass and \begin{document}, and it pulls in the other files with \input or \include. Luzbase picks the main file for you. There is no setting to choose it in a project.
How Luzbase picks the main file
Section titled “How Luzbase picks the main file”Luzbase checks these rules in order and uses the first one that matches:
- The project’s own main file, if it was set when the project was created and the file still exists. A project created from a template uses the template’s main file. A project imported from a
.zipuses the file detected during the import. main.texat the top level of the project (not inside a folder).- A
.texfile that contains\documentclassoutside a comment. If there are several, the one closest to the top of the project wins. - The first
.texfile in the project.
A multi-file project
Section titled “A multi-file project”A typical layout looks like this:
main.texreferences.bibchapters/introduction.texchapters/method.texfigures/setup.pngAnd main.tex includes the other files:
\documentclass{report}\usepackage{graphicx}\begin{document}\include{chapters/introduction}\include{chapters/method}\bibliographystyle{plain}\bibliography{references}\end{document}Write paths in \input, \include and \includegraphics from the top level of the project, for example figures/setup.png. Your own .sty, .cls, .bst and .bib files are found anywhere in the project, even inside folders, without any extra setup.
Change which file compiles
Section titled “Change which file compiles”If the project was created from a template or imported from a .zip, its main file was set or detected at that point, so it can have any name, such as thesis.tex.
If the main file is renamed or deleted later, Luzbase falls back to the rules above. Deleting main.tex shows a warning, because the build breaks until another file can take over.
To compile a different file:
- Rename the file you want to compile to
main.texand move it to the top level of the project. - If the project came from a template or a
.zipimport and its original main file still compiles, rename that original file too (for example toold-thesis.tex). The project’s own main file wins for as long as it exists under its original name.
When you import a .zip
Section titled “When you import a .zip”When you import a project from a .zip, Luzbase looks for its main file once, in this order:
- A
% !TEX root = …comment in the first 20 lines of a.texfile, naming the main file. If files name different main files, the one named most often wins. main.texat the top level of the archive.- The
.texfile that contains both\documentclassand\begin{document}outside a comment. If there are several, the one closest to the top wins.
The file it finds becomes the project’s own main file. If none of these rules finds one, the project has no main file of its own, and the rules in How Luzbase picks the main file apply.