Skip to main content

Extract text and mathematical equations from .docx files

Project description

docxlatex

A python library for extracting text and images from .docx files with LaTeX support

Influenced by python-docx and python-docx2txt. This project aims to expand the above libraries' functionality by allowing you to extract the equations in a .docx file and converts them to valid LaTeX, primarily for use with MathJax.

docxlatex DOES NOT convert the entire .docx file to a LaTeX source file.

docxlatex is still in beta and does not work perfectly on all equations. However, it does work with reasonable accuracy on standard symbols and equations, and works reliably when the equations in the document have been converted to linear format.

Installation

Install using pip
pip install docxlatex

Usage

Import the Document class from docxlatex

from docxlatex import Document

Create a Document object, giving it the path to the .docx file, and call the get_text() method

doc = Document("path/to/document")
text = doc.get_text()

You can also set some settings on the Document object to customize behaviour, like setting the delimiters that will go before and after an equation, and flags to extract header and footer text. Read the documentation at hrushikeshrv.github.io/docxlatex for all options.

doc.inline_delimiter = "%" # "$" by default
doc.block_delimiter = "%%" # "$$" by default

Limitation

docxlatex currently requires all the mathematical equations in the .docx document to be converted into linear format to extract successfully. Make sure all the equations in the .docx file are converted into linear form.

To convert all your equations into linear format, click on any equation, go to the Equation tab, make sure LaTeX is selected, and click on Convert → All - Linear

Please report any bugs on this project's GitHub page docxlatex/issues

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

docxlatex-1.0.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

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

docxlatex-1.0.0-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

Details for the file docxlatex-1.0.0.tar.gz.

File metadata

  • Download URL: docxlatex-1.0.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for docxlatex-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b90b6ab0dd654fb44b194174542f63f351b178ceee10b73fe47af3fc51393d1d
MD5 a69a2dbdfabb3b87a7182d40767f032a
BLAKE2b-256 3e7953580841a76aacd182826212d5fd5de9abb37d3f40bb321923c634cd10ca

See more details on using hashes here.

File details

Details for the file docxlatex-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: docxlatex-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for docxlatex-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bc02f04bee665390053edc33869bf4ab45bb10fe03ce76a9574804fbe56ad79
MD5 cb780461cd23d4fae7bb56fd1629f47f
BLAKE2b-256 0beade070fe1ca8f0498aafd5cc6d7bb06a9b34715928559d822ccb1d59e8d3b

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