Working with multi-file documents
Contents

A large LaTeX project may be best split into multiple files, each containing a well-defined section of the bigger work. This split makes it easier to manage the project.

# The Root File

The root file in a multi-file project is the one containing a document block of the following type,

What makes a .tex file a root file
\begin{document}
...
\end{document}

Note this refers to LaTeX. A plain TeX root file will have a different, simpler markers in it (for instance a \bye command).

# Subfiles

Subfiles are included into the root file using \input{...} or \include{...} commands.

A multi-file LaTeX document: root.tex
\documentclass[11pt]{article}
\begin{document}
abc
\input{a.tex}
abc
\include{b.tex}
\end{document}

where files a.tex and b.tex will be placed in the same directory and contain text without a document block,

a.tex to be used with above example
Contents of a.tex
b.tex to be used with above example
Contents of b.tex

Together the three files root.tex, a.tex and b.tex will form a multi-file LaTeX project. Any large piece of work such as a thesis or a book may be better served by a multi-file project structure.

## Creating a Subfile

Before you can include a subfile in your project for typesetting using \include or \input, it must first exist on your computer or iOS device. There are many ways to create a new subfile of an existing root file.

### Using commands \include or \input

To create a file sub.tex simply type \include{sub.tex} or \input{sub.tex} in the location in the root file where you wish to include it. Texifier will search for the file sub.tex in the parent directory of the root file, and upon failing to find it, prompt you if the file should be created. If you choose yes, the file will be created and listed in Sidebar’s Project Files section in the sidebar .

### Via Sidebar’s File Browser

The File Browser pane in the Sidebar allows you to create a new file on macOS. On macOS, the little plus button will allow you to create a file or a folder in case you wish to place the new file in a subfolder of the parent folder.

The newly created file must then be included in the root file using \include or \input. Only files included in this way will appear in the Project Files section of the sidebar.

### Outside of Texifier

You can use the File Browser (such as Finder on macOS or the Files app on iOS) to create a file in the parent folder and the include it in the root file using \include or \input.

# Project File List in the Sidebar

All subfiles are listed in Sidebar’s Project Files section in the sidebar , see apps/workspace/sidebar/contents/project-files for more.

Contents