Giter Club home page Giter Club logo

docxlatex's Introduction

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

docxlatex's People

Contributors

hrushikeshrv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ajpenner

docxlatex's Issues

extract equations in tables and cells

using document.get_text() method might work on documents but I see no way of extracting equations inside a table or a cell. Like in python-docx there is a support of tables and cells and text in a cell can be extracted by cell.text, but how do I use docxlatex to extract the equations and the text only in a particular cell of a table ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.