Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing a mathematical series in JLabel

Tags:

java

html

swing

How can I show a mathemetical series in a JLabel?

Right now I do it like this by using a String with HTML tags.

String s = "<html>&Sigma;<sup>N</sup><sub>i = 0</sub> x <sub>i</sub></html>";

Result: enter image description here

Is there a nicer way to do this? Because the output is very ugly. Usually N should be above the sigma and i = 0 below.

like image 356
Steve Benett Avatar asked Nov 18 '25 08:11

Steve Benett


1 Answers

A nicer way to do this is using a third party library to render Latex code in Java.

There are several of them for example JLatexMath, here's a example tutorial.

For instance, using the program of that example your summatory could look like this:

example 1

Or like this:

example 2

like image 192
DSquare Avatar answered Nov 20 '25 21:11

DSquare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!