Skip to content

Convert LaTeX math embedded in a Markdown document to local bitmap image

Notifications You must be signed in to change notification settings

faridcher/math2img

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mathjax (the javascript library) renders mathematical equations in a web page. But it's heavy and may not be supported everywhere. For example, Github Wiki does not allow use of external javascript libraries. HTML pages with bitmap equations are light and with as little dependency as possible.

What

This script generates png images from equations in a (R)Markdown document and replace an equation enclosed in $ or $$ with a reference to the rendered image.

Installation and Dependencies

In a Debian based OS:

sudo apt install bash texlive-base grep sed imagemagick
# install required latex packages
tlmgr install array standalone mathtools amssymb amsthm

git clone https://github.com/faridcher/math2img
cd math2eqn
chmod +x eqn2img.sh

Usage

# first argument is an auto-created directory to put the images and a (Github) Markdown document is read from stdin
./math2img eqn < gfm.md

Alternatives

Relative to the above alternatives, this script is simpler and minimal dependencies.

Limitations

  • Only works with equations enclosed in single $ for inline and double dollar sign ($$) for display equations
  • Sed scripts are concise but notorious for not being readable and hence this Bash script as well

Todo

  • Support [] for display and () for inline equations

License

GPL v2

About

Convert LaTeX math embedded in a Markdown document to local bitmap image

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published