0.1.0 • Published 9 years ago

make-latex v0.1.0

Weekly downloads
59
License
MIT
Repository
github
Last release
9 years ago

NPM version Build Status Coverage Status Dependencies

make-latex

create LaTeX tables from inside node.js

Install

Easily via npm:

$ npm install --save make-latex

Usage

var makeLatex = require('make-latex');

var mat = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
];

makeLatex(mat);
/*
returns:
\begin{table}
\centering
\begin{tabular}{ccc}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\
\end{tabular}
\end{table}
*/

API

makeLatex(obj , options)

Main function which takes a JavaScript object obj and converts it to LaTeX. The function returns a string which can be directly embedded in LaTeX. Currently, the following types of objects are supported:

  1. An array of arrays, or more specifically a square matrix (inner arrays must all have equal length).
  2. An array of objects.
  3. An object

The function accepts an optional options object which governs the created LaTeX output. The options object can have the following keys:

KeyDescriptionDefault Value
captionCaption of the created tablenone
labelLabel of the created tablenone
captionPlacementPosition of Caption, either "bottom" or "top""bottom"
colnamesIf supplied, first row in table prints names of columnsObject.keys() for Array of Objects, "Key", "Value" for Object
specSee Spec sectioncentered, no vertical lines
posSee Positions sectionnone

Spec

In LaTeX, the spec argument determines the alignment which is used in each column and where to insert vertical lines.

KeyDescription
lleft-justified column
ccentered column
rright-justified column
|vertical line
||double vertical line

Positions

KeyDescription
hallowed to be placed inline
tgo into top area
bgo into a bottom area
pgo on a float page or column area

Appending ! to either of those positions will force LaTeX to ignore restrictions related to number of floats that can be placed in an array or the size an array can occupy.

License

MIT © Philipp Burckhardt