get_full_document
Flatten a LaTeX project into one document by recursively expanding input/include directives, with source maps for tracing edits and unresolved include details.
Instructions
Flatten a LaTeX document latexpand-style: starting from rootFilePath, or from the project's root document when it is left out, every \input, \include, \subfile, and \import (also \subimport, \inputfrom, \subinputfrom, \includefrom, \subincludefrom) is replaced by the text of the file it names, recursively, and the rest of the text is kept exactly. Directives inside % comments and verbatim text are skipped. A path resolves relative to the project root first and then to the including file's folder (the other way round for \subimport and its relatives); \input and \subfile try the name as written and then with .tex, \include always means .tex, and \subfile takes in only the named file's document body. \include does not add its page breaks to the text. A directive that cannot be followed stays as written and is listed in unresolved with file, line (1-based), target, and reason: missing (no document at any candidate path), binary_file (the path is an uploaded file, not a text document), macro_argument (the path uses a macro or parameter), or excluded_by_includeonly (an \include an \includeonly list leaves out; includeOnly lists it). Returns rootFilePath, text, files (every file visited, each once, in order), unresolved, includeOnly when a file sets it, and sourceMap: one entry per run of text copied from one file, { flattenedStart, flattenedEnd, filePath, docId, originalStart, originalEnd, revision }, offsets in UTF-16 code units, half-open, into text and into that file's LF-normalized content. revision is the file's revision as read_file returns it: route an edit decided on in the flattened view back with write_file or write_section on that file, with that revision, never by writing the flattened text anywhere. Each file is read separately, so files can change between reads; each revision matches the text it was read with. text joins each file's text to what follows its directive with nothing in between, as written; a comment on a file's last line therefore reads on into the next text if text is compiled as is, though section parsing treats each file separately. An include cycle is INCLUDE_CYCLE with details.chain; nesting deeper than maxDepth is INCLUDE_DEPTH_EXCEEDED (it never cuts the result short); a result longer than 8388608 code units is DOC_TOO_LARGE with details.kind flattened, and includes that take in files more than 10000 times in all, counting a file once per inclusion, are DOC_TOO_LARGE with details.kind includes: start from a file further down, or read the files one at a time.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"projectId": "<projectId>"
},
"name": "get_full_document"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxDepth | No | Levels of includes to follow below the root document, 1 to 32; default 10 | |
| projectId | Yes | Overleaf project ID | |
| rootFilePath | No | Document to start from; defaults to the root document configured in Overleaf |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| files | Yes | ||
| sourceMap | Yes | ||
| unresolved | Yes | ||
| includeOnly | No | ||
| rootFilePath | Yes |