Split a long LaTeX document into one file per section or chapter with \input and \include, lay out the folder, and keep Coauthor's main file, auto compile, and collaborators in sync.
Multi-File Projects
A paper with several coauthors, or a thesis with ten chapters, is easier to manage as several files than as one long main.tex. LaTeX stitches them together at compile time with \input and \include, and Coauthor compiles the whole folder as one project. This page shows a sensible layout and the rules that keep it working.
A Typical Layout
My Paper/ <- Coauthor folder
main.tex <- marked as main
references.bib
sections/
introduction.tex
method.tex
experiments.tex
conclusion.tex
figures/
pipeline.pdf
results.png
venue.sty <- style file from the template, if any
Create the subfolders from the project folder's menu (Create Folder) in the workspace panel, or import an existing tree in one go; relative paths are preserved. See Organizing Folders and Files.
The Main File
main.tex holds the preamble and the skeleton, and pulls in the pieces:
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{figures/}}
\usepackage{natbib}
\title{...}
\author{...}
\begin{document}
\maketitle
\input{sections/introduction}
\input{sections/method}
\input{sections/experiments}
\input{sections/conclusion}
\bibliographystyle{plainnat}
\bibliography{references}
\end{document}
Each section file contains only body text, starting with its heading:
% sections/method.tex
\section{Method}\label{sec:method}
We propose ...
Section files have no \documentclass and no \begin{document}; they are fragments. Paths are relative to the main file and the .tex extension is optional.
In Coauthor, mark main.tex with Set as main (see LaTeX Main Files). The main badge tells everyone in the workspace which file drives the compile.
\input versus \include
\input{file} | \include{file} | |
|---|---|---|
| Page break | None; text continues inline | Starts a new page before and after |
| Nesting | Can be nested freely | Cannot be nested inside another \include |
| Where | Anywhere, including the preamble | Body only |
| Partial builds | No | Works with \includeonly{ch1,ch3} to compile a subset while keeping numbering |
| Typical use | Sections of a paper, shared macro files | Chapters of a thesis or book |
For papers, use \input. For a thesis where each chapter starts on a new page anyway, \include plus \includeonly speeds up compiles while you work on one chapter.
Compiling in Coauthor
- Every file under the project folder, including subfolders, is sent to the compiler, so
\input{sections/method}and\includegraphics{results}(with\graphicspath) resolve. - When you are editing a file that sits in the same folder as the main file, the toolbar button reads Compile main, Ctrl+S compiles the main file, and auto compile triggers on save.
- When you are editing a file inside a subfolder such as
sections/method.tex, the toolbar shows No main file set, because the main-file lookup is per folder. The file is still compiled as part of the project; to trigger a build, switch tomain.tex(or any file in the top folder) and press Ctrl+S, or wait for a save in the top folder to kick off auto compile. If that gets in the way, keep the section files in the same folder asmain.texand use a name prefix instead (01-introduction.tex,02-method.tex). - SyncTeX Go to PDF works from the main file and from section files in the same folder; from a file in a subfolder the lookup may report no matching location, because the editor sends only the file name. The reverse jump (double-click in the PDF) lands in the file currently open. See Jumping Between Source and PDF (SyncTeX).
- Compile error line numbers refer to the file being processed at the time; the raw log line in the Compilation Results panel shows which one. See Compile Errors, Warnings, and Logs.
Working With Collaborators
Splitting into files also reduces friction when several people write at once: each coauthor opens their own section file, and Coauthor's real-time editing keeps every file in sync. Labels, citation keys, and macros are global to the project, so agree on the prefixes in Cross-References and Labels and put shared \newcommand definitions in one macros.tex that main.tex inputs in the preamble. See Real-Time Editing.
Shared Macros and Settings
% macros.tex (input from the preamble)
\newcommand{\vect}[1]{\mathbf{#1}}
\newcommand{\E}{\mathbb{E}}
\DeclareMathOperator*{\argmin}{arg\,min}
% main.tex preamble
\input{macros}
Common Problems
| Symptom | Cause | Fix |
|---|---|---|
File 'sections/method.tex' not found | Wrong path or the file is in a different folder | Compare against the tree in the workspace panel; paths are relative to main.tex |
Can be used only in preamble | A section file contains \usepackage or \documentclass | Move preamble lines to main.tex |
\begin{document} ended by \end{...} | A section file contains its own \end{document} | Remove it; fragments have neither begin nor end |
| Chapter missing from the PDF | Not listed in \includeonly, or the \input line is commented out | Check main.tex |
| The AI coauthor edited the wrong file | It read the file you attached or had open | Mention the exact file name in your request ("in sections/method.tex, ...") |
Related articles
Prefer to ask?
Inside Coauthor, ask the AI coauthor how any feature works — it answers from these same help articles. For anything else, use the ? button in the top-right corner of the app.