LaTeX Unicode Encoder
Convert Unicode characters to LaTeX command syntax for use in LaTeX documents.
Usage
npx tsx scripts/encode.ts [options] <text-or-file>
Options
--file - Read input from file instead of command line argument
--output <file> - Write output to file
--format <type> - Output format: braced (default) or compact
Examples
Encode text with accents
npx tsx scripts/encode.ts "café naïve"
# Output: caf'{e} na\"{i}ve
Encode from file
npx tsx scripts/encode.ts --file input.txt --output output.tex
Encode for BibTeX
npx tsx scripts/encode.ts --format braced "Müller"
# Output: M\"{u}ller
Supported Characters
- Accented characters: é, è, ê, ë, ñ, ü, etc.
- Ligatures: æ, œ, ß
- Special characters: &, %, $, #, _
- Greek letters: α, β, γ, δ, etc.
- Dashes: – (en-dash), — (em-dash)
- Quotes: ", ", ', '
Technical Details
The encoder converts Unicode characters to LaTeX commands using a comprehensive mapping table:
- Accented vowels:
é → '{e}, ü → \"{u}
- Special characters:
& → \&, % → \%
- Ligatures:
æ → \ae, ß → \ss
Regular spaces are NOT escaped. Only special LaTeX characters and Unicode characters without ASCII equivalents are encoded.
1---2name: tex-encode3description: Encode Unicode characters to LaTeX commands. Use when converting text with special characters (é, ü, ñ, etc.) to LaTeX format for use in .tex files, BibTeX entries, or LaTeX documents.4---56# LaTeX Unicode Encoder78Convert Unicode characters to LaTeX command syntax for use in LaTeX documents.910## Usage1112```bash13npx tsx scripts/encode.ts [options] <text-or-file>14```1516## Options1718- `--file` - Read input from file instead of command line argument19- `--output <file>` - Write output to file20- `--format <type>` - Output format: `braced` (default) or `compact`2122## Examples2324### Encode text with accents25```bash26npx tsx scripts/encode.ts "café naïve"27# Output: caf'{e} na\"{i}ve28```2930### Encode from file31```bash32npx tsx scripts/encode.ts --file input.txt --output output.tex33```3435### Encode for BibTeX36```bash37npx tsx scripts/encode.ts --format braced "Müller"38# Output: M\"{u}ller39```4041## Supported Characters4243- **Accented characters**: é, è, ê, ë, ñ, ü, etc.44- **Ligatures**: æ, œ, ß45- **Special characters**: &, %, $, #, _46- **Greek letters**: α, β, γ, δ, etc.47- **Dashes**: – (en-dash), — (em-dash)48- **Quotes**: ", ", ', '4950## Technical Details5152The encoder converts Unicode characters to LaTeX commands using a comprehensive mapping table:53- Accented vowels: `é` → `'{e}`, `ü` → `\"{u}`54- Special characters: `&` → `\&`, `%` → `\%`55- Ligatures: `æ` → `\ae`, `ß` → `\ss`5657Regular spaces are NOT escaped. Only special LaTeX characters and Unicode characters without ASCII equivalents are encoded.