Skip to main content

The codec provides a convenient way of going between text written in LaTeX and unicode. Since it is not a LaTeX compiler, it is more appropriate for short chunks of text, such as a paragraph or the values of a BibTeX entry, and it is not appropriate for a full LaTeX document. In particular, its behavior on the LaTeX commands that do not simply select characters is intended to allow the unicode representation to be understandable by a human reader, but is not canonical and may require hand tuning to produce the desired effect.

The encoder does a best effort to replace unicode characters outside of the range used as LaTeX input (ascii by default) with a LaTeX command that selects the character. More technically, the unicode code point is replaced by a LaTeX command that selects a glyph that reasonably represents the code point. Unicode characters with special uses in LaTeX are replaced by their LaTeX equivalents. For example,

original text

encoded LaTeX

¥

\yen

ü

\"u

\N{NO-BREAK SPACE}

~

~

\textasciitilde

%

\%

#

\#

\textbf{x}

\textbf{x}

The decoder does a best effort to replace LaTeX commands that select characters with the unicode for the character they are selecting. For example,

original LaTeX

decoded unicode

\yen

¥

\"u

ü

~

\N{NO-BREAK SPACE}

\textasciitilde

~

\%

%

\#

#

\textbf{x}

\textbf {x}

#

#

In addition, comments are dropped (including the final newline that marks the end of a comment), paragraphs are canonicalized into double newlines, and other newlines are left as is. Spacing after LaTeX commands is also canonicalized.

For example,

hi % bye
there\par world
\textbf     {awesome}

is decoded as

hi there

world
\textbf {awesome}

When decoding, LaTeX commands not directly selecting characters (for example, macros and formatting commands) are passed through unchanged. The same happens for LaTeX commands that select characters but are not yet recognized by the codec. Either case can result in a hybrid unicode string in which some characters are understood as literally the character and others as parts of unexpanded commands. Consequently, at times, backslashes will be left intact for denoting the start of a potentially unrecognized control sequence.

Given the numerous and changing packages providing such LaTeX commands, the codec will never be complete, and new translations of unrecognized unicode or unrecognized LaTeX symbols are always welcome.

Release files for latexcodec 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for latexcodec 3.0.1
File Size Uploaded
latexcodec-3.0.1.tar.gz 31.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for latexcodec 3.0.1
File Interpreter ABI Platform
latexcodec-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 49.8 kB

Release files / latexcodec-3.0.1.tar.gz

Download URL latexcodec-3.0.1.tar.gz
Size 31.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e78a6911cd72f9dec35031c6ec23584de6842bfbc4610a9678868d14cdfb0357
BLAKE2b-256 checksum
How to use checksums
27dd4270b2c5e2ee49316c3859e62293bd2ea8e382339d63ab7bbe9f39c0ec3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0rc1

Release files / latexcodec-3.0.1-py3-none-any.whl

Download URL latexcodec-3.0.1-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9eb8200bff693f0437a69581f7579eb6bca25c4193515c09900ce76451e452e
BLAKE2b-256 checksum
How to use checksums
b54023569737873cc9637fd488606347e9dd92b9fa37ba4fcda1f98ee5219a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0rc1

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.2

2 release files

0.3.1

1 release file

0.3.0

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page