• Stars
    star
    244
  • Rank 165,885 (Top 4 %)
  • Language
    R
  • Created almost 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Query the mathpix API to convert math images to LaTeX

mathpix

Project Status: Active - The project has reached a stable, usable state and is being actively developed. CRAN_Status_Badge packageversion Last-changedate

Linux/Mac Travis Build Status AppVeyor Build Status codecov

Downloads GitHub forks GitHub stars Twitter

Installation:

mathpix is now on CRAN, so you can install using

install.packages("mathpix")

If you’re after newer development features (if there are any); you can install from GitHub using

devtools::install_github("jonocarroll/mathpix")

Authentication

The free API key has been removed due to overuse. Please sign up at https://dashboard.mathpix.com/ then save your ID and key in your .Renviron file as

MATHPIX_APP_ID='yourid'
MATHPIX_APP_KEY='yourkey'

Note that this requires you to accept Mathpix’s terms and conditions and sign up for any relevant pricing scheme.

You can check that your credentials are loaded correctly with credentials().

Usage

If you have an image you would rather properly encode in LaTeX, for example

then simply calling

mathpix("./integral.jpg")

(with the appropriate path to the file) will insert a LaTeX block into your document which will render what the image represents

$$
 \int \frac { 4 x } { \sqrt { x ^ { 2 } + 1 } } d x  
$$

which renders to

Even complicated, hand-drawn figures work

mathpix("matrix_3x3.jpg")
$$
 A = \left( \begin{array} { l l l } { 2 } & { 7 } & { 3 } \\ { 3 } & { 5 } & { 2 } \\ { 9 } & { 4 } & { 1 } \\ \end{array} \right)  
$$

If your image only result in warnings and no LaTeX, use retry = TRUE to attempt some pre-processing of the image into a more amenable form. Unfortunately, there are still images which fail.

To not insert the resulting equation directly into your document, but rather store it in a variable, use insert = FALSE.

If you also wish to generate the images (although rmarkdown will gladly do this for you) this can be achieved using

render_latex(latex, fileDir)

where latex is the LaTeX generated by mathpix() (or any other escaped LaTeX) and fileDir is the (optional) directory where you wish to save the image (by default, a temp file). This requires that you have pdflatex set up correctly and available on your machine.

API Documentation

Refer to http://docs.mathpix.com/

More Repositories

1

ggeasy

ggplot2 shortcuts (transformations made easy)
HTML
267
star
2

ggshape

Arrange 'ggplot' facets in arbitrary shapes
R
79
star
3

ntfy

Lightweight Wrapper to the ntfy.sh Service
JavaScript
60
star
4

ggghost

👻 Capture the spirit of your ggplot call
R
49
star
5

purrr2for

Automagically Convert purrr R Calls to Efficient Julia for Loops
R
49
star
6

regexmagic

Automated Detection of Regular Expression Patterns
R
37
star
7

githubtools

Tools to complement building and using R packages installed from GitHub
R
24
star
8

dash

RStudio Addin to Run a Selection as a Background Job
R
22
star
9

DFplyr

A `DataFrame` (`S4Vectors`) backend for `dplyr`
R
20
star
10

importAs

Idiomatic Python Shorthand Imports
R
20
star
11

charcuterie

Handle Strings as Vectors of Characters
R
19
star
12

realtime

R
15
star
13

TriangulArt.jl

Artify images using Delaunay Triangulation
Julia
15
star
14

butteRfly

Build a social network dashboard in R (Twitter/Facebook/GitHub/etc...)
R
14
star
15

starryeyes

"Oh my God! — it's full of stars!"
R
12
star
16

tidyGDPR

General Data Protection Regulation as Tidy Object(s)
R
11
star
17

VolunteerVignettes

The world needs more #rstats vignettes, so I'll be the change I want to see
R
9
star
18

runkeepR

Extract, plot, and analyse Runkeeper(TM) data.
R
9
star
19

opr

🔐 Interact with the 1Password CLI tool 'op'
R
7
star
20

btts

We need to go... Back To The Source
R
6
star
21

22degrees

Attempts to investigate moon halo star counts vs rain events in R
R
5
star
22

jcarroll.com.au

HTML
5
star
23

rx86

Simulated x86 assembly processing
R
4
star
24

chaint

"chain with a tee" -- add tee functions to magrittr/dplyr chains
R
4
star
25

advent-of-code

My Advent of Code Solutions in R and Rust
R
3
star
26

bluey

Episode scripts for the TV show Bluey scraped from the fandom site
Python
3
star
27

AUelection2016

Analysis of the 2016 Australian Federal Election with flexdashboard
HTML
3
star
28

itdepends

Is It Sufficient To Use Imports?
R
2
star
29

rps.rs

Rock, Paper, Scissors game, demonstrating enums
Rust
1
star
30

RDataGovAU

Access data.gov.au open data sets with R
R
1
star
31

jonocarroll

Jonathan Carroll
1
star
32

SAHansard

Wraps the SA Parliament Hansard API
CSS
1
star
33

FEN.rs

[toy project] FEN chess notation parser in Rust
Rust
1
star
34

useR2022

CSS
1
star
35

chessclub

R
1
star
36

weasel

Provides `pop()` and `push()` functionality
R
1
star