JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
|
JKQTMathText parses an input string of mathematical markup (i.e. LaTeX) and in a first step generates a memory representation of the it (cf. Render-Tree Items for JKQTMathText ). Then this memory representation is used to draw the represented math using the renndering API of QPainter.
As an example, we look at the following LaTeX markup, representing the solution to a quadratic equation:
LaTeX itself would render this as follows:
JKQTMathText produces this output:
The memory representation of the expression above looks like this:
You can see that each node corresponds to a box, if these are overlayed over the rendering:
The box, representing each node, is characterized by its width and height, as well as the ascent (or "baseline-height"):
As described above, JKQTMathText represents the mathematicl markup as a tree of boxes. When calling JKQTMathText::parse() without any additional parameters, the base-node is a JKQTMathTextVerticalListNode that can represent several lines of text. A new line is started when a \\
or \newline
command is found. Automatic line breaking is not performed, i.e. each line can possibly become very long, also longer than the available space for drawing! Also lineabreaks are only allowed directly in the current context. You cannot write
but have to write
With environment-altering instructions like \bfserie
or \it
this can be overcome: If you write
both lines are typeset in bold face!