AgentSkillsCN

emdash-tex

在 .tex 文件中,将直角引号(--- 和 Unicode —)转换为 \textemdash,以确保在 EPUB、PDF 等输出格式中正确显示。当您需要修复 LaTeX 中的直角引号、为 EPUB 准备稿件,或在导出时发现引号显示异常时,此技能便能派上用场。

SKILL.md
--- frontmatter
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 .tex files (e.g. under manuscript/content/ or project .tex paths)
  • Replace:
    1. Three hyphens --- (when used as an em dash, not in comments or commands)
    2. Unicode em dash character (U+2014) → \textemdash

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---thing is not em dash)
    • They are part of a longer dash sequence (e.g. four or more hyphens in ASCII art / rules)
  • (Unicode U+2014) → \textemdash
    Replace every Unicode em dash character with \textemdash.

3. Preserve existing \textemdash and other formatting

  • Leave existing \textemdash unchanged.
  • 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 ---):

tex
It was feasible---more than we thought---to provide a standard.

After:

tex
It was feasible\textemdash more than we thought\textemdash to provide a standard.

Before (Unicode —):

tex
Physics has found no straight lines—only waves.

After:

tex
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 \textemdash so EPUB/PDF/Wikijs all render them correctly.