Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing fractional numbers in Java or Android

Tags:

java

android

I am rendering the HTML into my project to create this type of image as follows:

desired output

So i write this code as below:

<big>1</big>
<sup>
  <sup>
    <small>
      <small>1</small>
    </small>
  </sup>
</sup>
  /
<sub>
  <small>3</small>
</sub>

But the output looks like this:

actual output

You can see the gap between the number 1 and '/' and also between '/' and 3. any idea how to remove it?

Solution:

Just number values changes

<big>1</big><sup>1</sup>&frasl;<sub>10</sub>

which will look like this as in figure. enter image description here

Hope this will help someone.Thanks guys for your support.

like image 604
Android Killer Avatar asked Oct 24 '22 21:10

Android Killer


1 Answers

The reason you're seeing gaps in between the numerator, separator, and denominator is because you're trying to render three different characters in a plain text string, one after another:

enter image description here

Since you want the fractional elements to behave a little bit differently than standard text behaves, you'll have to look at using something designed especially for displaying these types of symbols. You might want to look at MathML (specifically, the portion dealing with bevelled elements in fractions, and something like JEuclid to do the actual rendering.

like image 118
matt Avatar answered Oct 27 '22 11:10

matt