name: emdash-tex description: Converts literal em dashes (--- and Unicode —) to \textemdash in .tex files for correct display in EPUB, PDF, and other outputs. Use when fixing em dashes in LaTeX, preparing manuscripts for EPUB, or when dashes display incorrectly in exports.
Em Dash to \textemdash for LaTeX
Converts literal em dash forms to the LaTeX command \textemdash in .tex files so they render correctly in EPUB, PDF, Wikijs, and other output formats.
When to Apply
- User asks to fix em dashes, convert --- to \textemdash, or prepare .tex for EPUB/other outputs
- Em dashes appear as raw hyphens or wrong characters in built EPUB/PDF
- Adding or editing .tex content and you want consistent, portable em dashes
Scope
- Files: Only
.texfiles (e.g. undermanuscript/content/or project .tex paths) - Replace:
- Three hyphens
---(when used as an em dash, not in comments or commands) - Unicode em dash character
—(U+2014) →\textemdash
- Three hyphens
Workflow
1. Identify target .tex file(s)
If the user names a file or directory, use that. Otherwise, common locations: manuscript/content/**/*.tex.
2. Replace literal em dashes
---→\textemdash
Replace three consecutive hyphens when they act as an em dash (pause, aside, parenthetical).
Do not replace when:- The line is a comment (after
%on that line, or whole line is comment) - The hyphens are inside a LaTeX command name (e.g.
\some---thingis not em dash) - They are part of a longer dash sequence (e.g. four or more hyphens in ASCII art / rules)
- The line is a comment (after
—(Unicode U+2014) →\textemdash
Replace every Unicode em dash character with\textemdash.
3. Preserve existing \textemdash and other formatting
- Leave existing
\textemdashunchanged. - Do not change en dashes
--(two hyphens) used for ranges/compounds. - Do not alter LaTeX commands,
{}, math, or structure; only replace the two patterns above.
4. Save and optionally report
- Write changes to the same .tex file(s).
- Optionally report: file(s) updated and approximate count of replacements (--- and —).
Examples
Before (literal ---):
It was feasible---more than we thought---to provide a standard.
After:
It was feasible\textemdash more than we thought\textemdash to provide a standard.
Before (Unicode —):
Physics has found no straight lines—only waves.
After:
Physics has found no straight lines\textemdash only waves.
Do Not Change
- Comment lines or content after
% - En dashes:
10--20,east--west,1950--1960 - Hyphenated words:
well-known,self-contained - LaTeX command names or arguments (except where the only change is replacing
---or—in normal prose)
Notes
- Conservative: Only replace
---when it clearly functions as an em dash in the sentence. - Consistent: After this skill, em dashes in prose should be
\textemdashso EPUB/PDF/Wikijs all render them correctly.