Skip to main content

Converts a number to a LaTeX string in scientific notation.

Project description

real2tex

real2tex is a Python module that converts a real number to a string of LaTeX code that represents the number in scientific notation.

Installation

pip install real2tex

Usage

from real2tex import real2tex

tex = real2tex(1.2345e-6, precision=2)
print(tex) # "1.23 \cdot 10^{\minus 6}"

Is it also possible to change the default arguments of the module (precision, multiply_symbol, ...) with the set_options function. Furthermore, the current options can be retrieved with the get_options function and reset to the default values with the reset_options function.

import real2tex as rt

tex = rt.real2tex(1.2345e-6)
print(tex) # "1.23 \cdot 10^{\minus 6}"

rt.set_options(precision=4, multiply_symbol="*")
tex = rt.real2tex(1.2345e-6)
print(tex) # "1.2345 * 10^{\minus 6}"

print(rt.get_options()) # Get current options

rt.reset_options() # Reset options to default

As an alternative to set_options, the SetOptions context manager can be used to temporarily change the options.

with rt.SetOptions(precision=4, multiply_symbol="*"):
    tex = rt.real2tex(1.2345e-6)
    print(tex) # "1.2345 * 10^{\minus 6}"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

real2tex-1.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

real2tex-1.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file real2tex-1.1.0.tar.gz.

File metadata

  • Download URL: real2tex-1.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for real2tex-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d68188b7074c05cd5c6dbc7dd99a2a59a9874a363651d6dd3db1ccf64f4fafbd
MD5 8b2bc0831e7900d4c7e636ba9bbb5a2d
BLAKE2b-256 8e2e617ea72313bb60887b2798e3617323eb37a3403d248ca7db4a2d10bfa157

See more details on using hashes here.

File details

Details for the file real2tex-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: real2tex-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for real2tex-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f1a393ff0c98f3be9810371546b2d50484cf9a760508ec13272ce5605d58d36
MD5 554e1d6ad33ee5df2b646a2807e85dcb
BLAKE2b-256 a8744fd85058a1187ddae03cc15032c6cae960e3bd1cd375ada0b24125c46ef1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page