Package 'mathpix'

Title: Support for the 'Mathpix' API (Image to 'LaTeX')
Description: Given an image of a formula (typeset or handwritten) this package provides calls to the 'Mathpix' service to produce the 'LaTeX' code which should generate that image, and pastes it into a (e.g. an 'rmarkdown') document. See <https://docs.mathpix.com/> for full details. 'Mathpix' is an external service and use of the API is subject to their terms and conditions.
Authors: Jonathan Carroll [aut, cre]
Maintainer: Jonathan Carroll <[email protected]>
License: GPL (>=3)
Version: 0.6.0
Built: 2024-10-26 03:55:36 UTC
Source: https://github.com/jonocarroll/mathpix

Help Index


Detect mathpix credentials

Description

Checks environmental variables for MATHPIX_APP_ID and MATHPIX_APP_KEY values.

Usage

credentials()

Value

a list of detected credentials (or this package's credentials)


Get a mathpix API key

Description

Get a mathpix API key

Usage

get_api_key()

Value

NULL (invisibly). Used for the side-effect of opening a browser.


Convert an image of an equation to a 'LaTeX' expression

Description

Given an image file location, mathpix performs the relevant transformations and send the data to the 'Mathpix' API, which returns a 'LaTeX' expression which should generate the typeset equation/expression in that image. When using 'RStudio', the resulting 'LaTeX' expression is automatically inserted into the current rmarkdown document.

Usage

mathpix(img, insert = TRUE, retry = FALSE)

Arguments

img

image to be converted to LaTeX

insert

Should the resulting LaTeX block be inserted into the document (default: TRUE)

retry

If Mathpix is not able to process the image, should we try again with a re-processed image?

Details

You must save your own API key in your environment (e.g. ⁠~/.Renviron⁠) with the identifiers MATHPIX_APP_ID and MATHPIX_APP_KEY. This can be tested with mathpix:::credentials().

Value

(invisibly) the rmarkdown LaTeX equation block

References

https://mathpix.com/


Convert a 'LaTeX' expression to an image (render)

Description

This calls tex_preview to render a 'LaTeX' expression into an image, either as a temporary file or saved to disk.

Usage

render_latex(latex, fileDir = NULL, ...)

Arguments

latex

'LaTeX' code to be evaluated. Surround in $ or $$.

fileDir

directory in which to save the image to (defaults to '/tmp/tempfile()').

...

other options to pass to tex_preview.

Value

NULL (invisibly)