All Projects → goldsborough → latexpp

goldsborough / latexpp

Licence: MIT license
A C++ LaTeX generator

Programming Languages

C++
36643 projects - #6 most used programming language

latexpp

GitHub license

latexpp is a first-of-its kind C++ library for generating LaTeX equations via C++. It supports conversion of LaTeX equations to HTML as well as JPG, PNG and SVG image formats.

Usage

#include "latex.hpp"

int main(int argc, const char* argv[])
{
	// Single class
	Latex latex;

	const std::string equation = "\\sum_{i=1}^{n} i = \\frac{n(n + 1)}{2}";

	// Convert to PNG, store in 'equation.png'
	latex.to_png(equation, "equation.png");

	// Convert to HTML, returns a HTML snippet
	std::string html = latex.to_html(equation);
}

equation.png:

equation.png

Implementation Overview

latexpp uses KaTeX to render LaTeX to HTML. Because KaTeX is a JavaScript library, latexpp uses Google's V8 engine to write JavaScript from C++. Image output is enabled by the wkhtmltox C library.

To build this project, you will need:

  • The Google V8 engine to compile JavaScript.
  • The wkhtmltox library for image output.
  • Boost for some cross-platform directory operations (can be dropped as a dependency if platform-indpendence is not required, or when the C++ standard committee decides to roll out boost's filesystem library in the C++ standard library.)

KaTeX is not a dependency as it is entirely contained in the katex folder.

Documentation

You can build extensive documentation with doxygen. See the doxyfile in the docs/ folder. There are also some example programs in the examples folder.

LICENSE

This project is released under the MIT License. For more information, see the LICENSE file.

Authors

Peter Goldsborough + cat ❤️

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].