Rewrite one LaTeX section
edit_sectionReplace an entire section of a .tex file by title, rewriting from its heading to the next same-or-higher-level heading without removing trailing content.
Instructions
Replace one whole section of a .tex file, located by its title. Use replace_text for a smaller change and this to rewrite a section wholesale. The section runs from its heading to the next heading of the same or a shallower level, never swallowing trailing matter such as \end{document} or the bibliography. newContent replaces that range line for line, so it must start with the \section{...} command itself or the heading is lost, and should end with a newline to keep the blank line before the next heading. sectionTitle is compared case-insensitively with the title in braces: an exact match wins, otherwise the first heading in document order that contains it. Pulls from Overleaf first, then edits only the local clone; push_changes publishes it. Returns the heading replaced and its former line range; if no title matches, nothing changes and the reply lists the titles.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the .tex file relative to the project root. | |
| project | No | Which project to use: its Overleaf address, its 24-character id, or a registered project name. Omit to use the default project. | |
| newContent | Yes | The section's full replacement text, starting with its own sectioning command, e.g. \section{Introduction} followed by the new body. | |
| sectionTitle | Yes | Title of the section to replace, as it appears in the sectioning command. Matched case-insensitively, with a substring fallback. Call list_sections if unsure. | |
| expectedRevision | No | Optional guard: the 64-character revision hash returned by read_file with mode=full or mode=smart for this same file. When given, the edit is refused if the file changed since that read — for example because pulling from Overleaf brought in a collaborator's version. Pass it whenever the edit depends on content you read earlier. |