Coder Social home page Coder Social logo

qtmathjax's Introduction

Overview

QtMathJax is a .pri file that lets you easily add beautiful math typesetting into any Qt application.

MathJax is the de facto standard for mathematical typesetting on the web, using a JavaScript-based typesetting engine. QtMathJax imports just the necessary parts of that project into your Qt project, runs them in a hidden QWebView, and provides you a one-function API for turning a string of TeX code into a string of SVG code that can be used to render it anywhere, in your Qt app or outside it.

Obtaining

Just clone this git repo, or use it as a submodule in your project. In fact, it uses MathJax as a submodule itself.

Usage

To use QtMathJax, follow these steps.

  1. In your .pro file, import QtMathJax by adding the following line.
    include(/path/to/qtmathjax.pri)
    
  2. In the source file where you need to use it, include the one class you need, TeXEngine, via #include "texengine.h".
  3. Create an instance of the class and call the TeX2SVG() method in it.
TeXEngine engine;  
// ...  
QString svgCode = engine.TeX2SVG( "ax^2+bx+c=0" );

That's it! You can then render that SVG in any of the ways Qt provides, or do something else with it, such as saving it to a file for use outside your app. Example:

myQSvgWidget->load( svgCode.toUtf8() );

See below for an example app.

Asynchronous

There is also an API for asynchronous computation, not yet thoroughly documented here. One calls engine.asyncTeX2SVG() to enqueue an expression for typesetting, then later checks back using engine.hasComputed() to see if the typesetting is complete. If so, then a call to engine.TeX2SVG() will not spin the event loop at all, but return immediately with a value stored in cache from the asynchronous computation. See the source for details.

Example

The repository comes with a sample app in the example subfolder. If using Qt 5, you should be able to compile and run that app without any changes needed. It looks like this:

Screenshot

License

This project is released under the GPLv3 and LGPLv3. It is my understanding that these are both compatible with the Apache license under which MathJax is released.

qtmathjax's People

Contributors

minoru avatar nathancarter avatar

Watchers

 avatar  avatar

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.