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.
#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
:
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.
You can build extensive documentation with doxygen
. See the doxyfile
in the docs/
folder. There are also some example programs in the examples
folder.
This project is released under the MIT License. For more information, see the LICENSE file.
Peter Goldsborough + cat ❤️