Rewriting LaTeX prose with AI without breaking commands or math
Which parts of a LaTeX document an AI rewrite is allowed to touch, how structural validation works, and a review workflow that keeps the original safe.
Paraphrasing a paragraph of LaTeX looks trivial until it is not. The prose is a minority of the characters in the file, and the majority of them are load-bearing: a backslash, a brace, a citation key, a number. A model asked to "improve this paragraph" will happily tidy all of it, including the parts that must not change.
This is a guide to keeping an AI rewrite useful: which parts of the document are protected, how validation catches the rest, and how to review a proposal without losing the original.
The failure modes, with examples
| What breaks | Example | What the model does | Why it matters |
|---|---|---|---|
| Escaped characters | 100\% of \&{} | Drops the backslash | Compile error or wrong glyph |
| Math regions | $E = mc^2$, \[ ... \] | Reflows, renames variables | Wrong physics, silently |
| Citation and label keys | \cite{smith2020} | "Corrects" the key | Broken reference, no compile error until the bibliography |
| Numbers and units | \SI{3.2}{\micro\meter} | Rounds or reformats | Falsified data |
| Line-sensitive content | verbatim, minted, aligned tables | Reindents | Broken layout, mangled code listings |
| Non-breaking spaces | Fig.~3 | Replaces with a normal space | Stray line break before the number |
| Dashes | 1--10, --- | Normalises | Wrong punctuation semantics |
Every one of those is a real incident people have had. The pattern is always the same: the model does not know which characters are structure.
Why a chat prompt is the wrong interface
Pasting a paragraph into a chat window and pasting the answer back has three structural problems.
- No contract. You asked for a rewrite; you got a rewrite of the paragraph and its numbers. Nothing prevents it.
- No diff. You must compare two blocks of LaTeX by eye, at the point where your attention is lowest.
- No original. If the result is worse, you are reconstructing what you had.
The fix is not a better prompt. It is a workflow with a constrained output format and a validation step.
A workflow that keeps LaTeX safe
1. Protect structure explicitly. Tell the model precisely what must not change: commands, math, numbers, identifiers, indentation and line breaks. The instruction is not politeness, it is the contract the validator will enforce.
2. Constrain the response format. Ask for structured data — sentence identifiers and replacement text — rather than a prose reply. A model that returns identifiers cannot reflow your document's layout, because it never sees the layout as output. Requests that return more than the agreed shape get repaired or rejected, not accepted.
3. Validate before insertion. Compare the proposal against the source: is the set of commands identical? Are the numeric literals identical? Are math regions untouched? Is the line layout compatible? A conservative checker that flags doubt is more useful than a clever one that guesses.
4. Show the change in both directions. A review view should highlight removed wording on one side and added wording on the other, so you are reading the difference rather than proofreading two blocks.
5. Keep the original and make acceptance explicit. When the validator warns — a changed number, an incompatible line layout — accepting should require an explicit override, with the original retained. A silent "improved" target is the failure state.
6. Retry narrowly, never silently. If a response is malformed or violates the contract, one bounded retry with specific feedback is reasonable. Retrying until something looks plausible is not.
What this looks like in practice
Steady Type's final-text rewrite is an implementation of that pattern: the model returns an object containing only text, the extension builds the actual edit, and protected formatting, commands, math, numbers and incompatible line layouts produce warnings that require explicit acceptance while the original is kept. Reasoning is requested at a Balanced level, requests are capped, and schema failures get at most one targeted retry. The structural checker is deliberately conservative and is not a full TeX parser — it is there to refuse, not to be clever.
None of that makes a rewrite correct. It makes it reviewable.
Here is the shape of a proposal for a sentence inside a technical passage, in a form you can check at a glance:
original: The study compared several models with 20\,000 observations
\cite{smith2020}.
proposed: Several models were compared using 20\,000 observations
\cite{smith2020}.
The wording changed; 20\,000 and the citation key did not. If the proposed version had said 20,000 or \cite{Smith2020}, the validator flags it and the change requires your explicit approval.
Reviewing a rewrite in a thesis
For long documents, the review is the part that scales badly. A few habits make it survivable:
- Rewrite in small spans. One paragraph or one sentence at a time; insert, compile, read. A wholesale rewrite of a chapter is unreviewable in practice.
- Version control the original. Your git history is the real backup; the tool's "keep original" feature is only the second line of defence.
- Recompile after every acceptance. A valid-looking rewrite can still break a
\SI{}unit or a table alignment. - Check the numbers yourself. Automated checks compare literals, not meaning. If the sentence said "approximately 20,000" and the rewrite says "roughly 20,000", only you can say whether the hedge changed the claim.
- Read for claims, not for style. The rewrite's job was to change wording; your job is to confirm that the facts, qualifiers and hedging survived.
The limits worth stating plainly
Paraphrasing is ordinary rewriting. It is not a detector guarantee, it is not a watermark guarantee, and it does not launder authorship of anything you did not write. Statistical watermark claims are unverifiable from the outside, which is why honest tools describe reduction as best effort at most.
There is also a scope question that no tool can answer for you: institutional rules, journal policies and collaboration standards decide whether an AI rewrite is acceptable in your document at all. Keep the original, keep the diff, and be able to explain precisely which sentences changed and why. If the workflow ever makes that impossible, the workflow is the problem.
Frequently asked questions
Will asking a model to rewrite my LaTeX break it?
It can. The failure modes are predictable: escaped characters lose their backslash, math delimiters get reflowed, citation keys are renamed, numbers are rounded, and line-sensitive environments break. All of them are avoidable with a constrained response format and a structural check before insertion.
Does paraphrasing remove AI watermarks?
There is no reliable public way to verify a watermark in text, and paraphrasing is not a guarantee of anything. Treat watermark reduction as best effort at most, and never as a compliance strategy.
Is AI rewriting allowed in a thesis?
That is an institutional question, not a technical one. Many universities allow language editing with disclosure and forbid generating content. Check your own rules, keep the original text, and be able to explain exactly what was changed.