Skip to main content

A package for converting JSON and other similar structures to a format accessible using LaTeX.

Project description

Travis Status Documentation Status PyPI Version License


json2latex is a library for converting a nested Python structure to a format accessible in LaTeX.


JSON to LaTeX can be installed using pip by running pip install json2latex,


Full documentation of JSON to LaTeX is provided here. The basic usage is as follows.

The following Python code saves a file, `out.tex which includes the necessary LaTeX commands to access the data in LaTeX.

import json2latex

data = dict(a="test", b=[1, 2])

with open('out.tex', 'w') as f:
    json2latex.dump('data', data, f)

The same result can be accomplished by running,

json2latex example.json data out.tex

where example.json is a JSON file containing the same data is thedata` dictionary in the Python example.

The code output by JSON to LaTeX can be used as follows. First the file needs to be imported in LaTeX using \input{out.tex}. Then, the following commands can be used to access the data:

  • \data will expand to the full JSON representation of the input, {"a": "test", "b": [1, 2]}.
  • \data[a] will expand to test.
  • \data[b] will expand to [1, 2].
  • \data[b][0] will expand to 1.
  • \data[b][1] will expand to 2.
  • \data[b][2], and all other undefined values, will expand to ??.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for json2latex, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size json2latex-0.0.2-py3-none-any.whl (6.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size json2latex-0.0.2.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page