Why copied AI equations contain extra commas—and how we normalize them safely

An engineering note on distinguishing French decimal commas from invisible spacing artifacts, unit separators, and multiplication markers in copied AI equations.

A comma inside a copied equation can represent a decimal separator, punctuation, a coordinate separator, or visual spacing inserted by an AI interface. Removing every comma fixes some equations and silently corrupts others.

This engineering note documents a class of AIText2Doc bugs that appeared harmless in plain text but affected preview, Word, and PDF output. It explains why broad regular expressions failed and how a small regression set made normalization safer.

The first symptom: a comma before the unit

A copied physics example contained:

On prend (g = 10,\text{N/kg}).

The intended rendering was g = 10 N/kg. The comma was not mathematical punctuation. It represented visual spacing between the number and unit.

Another display equation ended with:

E_{pp} = 0{,}5 \times 10 \times 30 = 150,J

The expected output was 150 J. Again, the comma acted as spacing.

A simple fix appeared obvious: remove commas before letters. That rule immediately created a second problem.

The decimal comma is real data

The same source language used:

m = 0{,}5 kg

Here the comma is the decimal separator and must remain. LaTeX braces around {,} make the intent clearer, but copied AI output is not always consistent.

A rule that removes all commas near digits can turn 0,5 into 05. A rule that replaces all commas with periods changes the language convention and may alter coordinates or lists.

The converter therefore needs context, not a global replacement.

A third case: commas around multiplication points

Another copied expression used this form:

W_e = U_{AB},.,I,.,\Delta t

The visible chat rendering treated each point as multiplication and hid the commas. The required output was:

W_e = U_{AB} · I · Δt

Removing both commas and points would produce adjacent variables with no operator. Keeping everything would display ,., in preview and Word.

The normalization has to preserve the multiplication intent while deleting only the copied spacing separators.

Why AI copy text differs from the screen

AI products often send mathematical source text to a rendering library. The screen displays the rendered formula, not every character in the source representation.

When a user clicks Copy, the clipboard may contain:

  • LaTeX commands.
  • Escaped punctuation.
  • Unicode mathematical symbols.
  • Hidden or visually collapsed spacing.
  • Separators introduced by the interface.
  • Line breaks that were not visible on screen.

This explains why the original chat screenshot can look correct while the pasted source contains !, *, commas, or additional slashes.

The issue is not necessarily that the AI generated an incorrect equation. The screen renderer and clipboard representation are different layers.

The normalization strategy

AIText2Doc applies narrow transformations around known patterns.

Preserve explicit decimal commas

Expressions such as 0{,}5 represent decimal notation. The braces are removed during conversion, but the comma remains.

Remove spacing commas before recognized units

Cases such as 150,J, 30,m, 0{,}5,kg, and 10,\text{N/kg} are normalized when the surrounding structure matches a quantity-unit pattern.

The converter does not assume every letter sequence is a unit. The supported regression set contains common physics and chemistry units observed in real copied examples.

Convert copied multiplication sequences

The ,., sequence is interpreted as a multiplication point between equation terms. A clearer source is \cdot, but the converter accepts the copied pattern because users often cannot control the clipboard source.

Preserve commas used by the equation

Commas may be meaningful in:

  • Q_{r,eq} subscripts.
  • Coordinate pairs.
  • Function arguments.
  • Sets and sequences.
  • Prose surrounding inline mathematics.

Any cleanup rule has to avoid these positions.

Regression cases

The current test pack includes:

  1. (m = 500,g = 0{,}5,kg)
  2. (h = 30,m)
  3. (g = 10,\text{N/kg})
  4. E_{pp} = 150,J
  5. W_e = U_{AB},.,I,.,\Delta t
  6. Q_{r,eq} inside a reaction quotient

Each case is checked in preview and DOCX. Equation-heavy display cases are also checked in Chromium PDF output.

The downloadable regression pack lets users reproduce the current behavior. The compatibility matrix records the expected result.

Why one successful screenshot is not enough

A rule can fix one formula while breaking another. For example:

  • Removing a comma fixes 150,J.
  • The same rule corrupts 0,5.
  • Removing periods fixes ,., artifacts.
  • The same rule removes multiplication.
  • Removing all punctuation fixes raw copy noise.
  • The same rule damages subscripts such as r,eq.

A regression pack forces the implementation to satisfy several conflicting examples at once. That is more reliable than adjusting the parser until the current screenshot looks correct.

What users can do when a unit is not recognized

If an uncommon unit still contains an extra comma:

  1. Change only the spacing comma, not decimal punctuation.
  2. Use explicit multiplication or spacing, such as \cdot or \,.
  3. Keep the complete quantity inside equation delimiters.
  4. Preview before exporting.
  5. Report the shortest failing input.

For example, rewrite:

x = 12,unit

as:

x = 12\,\mathrm{unit}

This communicates spacing and upright unit text explicitly.

What this teaches about AI document conversion

The visible AI answer is not the complete source document. A converter must account for the clipboard layer while avoiding aggressive cleanup that changes meaning.

Safe normalization has three properties:

  • It is context-specific.
  • It is covered by conflicting regression examples.
  • It produces equivalent structure in preview, DOCX, and PDF.

This is why AIText2Doc does not advertise arbitrary LaTeX support. It documents tested patterns and blocks known layout formats that cannot be exported reliably.

For current cases, see the compatibility matrix. For the complete pipeline, read the tested AI-to-DOCX workflow. For chemistry-specific units and isotope notation, use the chemistry guide.