Search code examples
javascriptandroidalignmentruntimejqmath

jqmath align left in webView android


How can i left aline my equation using jqmath in android by default all the equation is shown in center allign. i want to show the equation startup from left side.althought webview is left align but jqmath is always start written from center. if any text is written other than jqmath then it is left align but any text written with like $$ 5x=4 $$ then it is center align how can i fix it.

    stepStrHtml = "<html><head>"
            + "<link rel='stylesheet' href='file:///android_asset   /mathscribe/jqmath-0.4.3.css'>"
            + "<script src = 'file:///android_asset/mathscribe/jquery-1.4.3.min.js'></script>"
            + "<script src = 'file:///android_asset/mathscribe/jqmath-etc-0.4.3.min.js'></script>"
            + "</head><body><FONT COLOR=\"#800080\">";

     step = "$$" + getIntent().getExtras().getString("equation");
     step = step + "$$"+"</FONT>" ;

    stepStrHtml=stepStrHtml+ step;

     stepStrHtml=stepStrHtml+"$$3x=5/9$$"

         stepStrHtml = stepStrHtml + "</body></html>";
    stepWebView.loadDataWithBaseURL("", stepStrHtml, "text/html", "UTF-8", "");

Solution

  • There are a few ways.

    1. Change $$ to $: $3x=5/9$ instead of $$3x=5/9$$. This will also make the fraction smaller though.

    2. Wrap $$3x=5/9$$ in an inline-block:

      "<span style='display: inline-block; color: #800080'>$$3x=5/9$$</span>"
      

    You can also use css to style parts of the mathematics. See jqMath highlight box like bbox in MathJax/MathJs and How to left align elements in a jqmath table.