Code Monkey home page Code Monkey logo

json2latex's Introduction

Travis Status Documentation Status PyPI Version License

JSON to LaTeX

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

Installation

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

Usage

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 the data` 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 ??.

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.