# Katex Mathview

## General

Category
Free
Tag
Mathematics
Min SDK
Registered
Apr 13, 2017
Favorites
4
https://github.com/lingarajsankaravelu/Katex
MathJS Android
DiscreteMathToolkit
kotlin-math
MathFu
Calc

Language
JavaScript
Version
v_1.0.3 (Apr 23, 2020)
Created
Mar 29, 2017
Updated
May 19, 2020
Owner
HourGlass (lingarajsankaravelu)
Contributors
3
Activity
Generate
Source code
APK file

## Blurb

A KhanAcademy Katex based Library for Rendering math faster in various Android Devices. This a View which is created from extending webview. This view allows you to render latex in your android devices. It can load normal text, text with latex and latex alone. The only thing you have to make sure is your latex should be enclosed inside either $your latex formula$ or $$your latex formula$$. This will also allow you to beautify your formula text by setting color and text size.

### Accepted Inputs

$x=\frac{1+y}{1+2z^2}$


or

 $$x=\frac{1+y}{1+2z^2}$$


or

 sum of ratios =4+3=7 $=\frac{4}{7}\times560=320$


or

 Data Included inside HTML TAGS

<p>If <span class="latexEle" data-latex="x:35::48:60">$x:35::48:60$</span><span>  </span>, find the value of <span class="latexEle" data-latex="x">$x$</span><span>  </span>.</p>


### Setup

Dependencies
{
implementation 'in.hourglass.mathrender:katexmathview:1.0.3'
}


### Attributes supported

 setTextColor          -> Allows you to beautify your latex with specific color of your choice
setTextSize           -> Allows you to set text size of the latex displayed on screen
setViewBackgroudColor -> set the background color of the view.
setClickable
i.True     -> Setting this to true will allow KatexMathview to act as Textview and it will also intercept parent layout touchevent useful to register click
when this view is used with List,Recyclerview.
ii.False   -> Setting this to false will make katexMathvview act as an webview with zoom in controls etc.


    <katex.hourglass.in.mathlib.MathView
app:setTextColor="@color/primary"
app:setTextSize="14sp"
app:setClickable="true"
app:setText="@string/single_formula"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


    MathView mathView = new MathView(getApplicationContext());
mathView.setClickable(true);
mathView.setTextSize(14);
mathView.setTextColor(ContextCompat.getColor(getApplicationContext(),android.R.color.white));
mathView.setDisplayText(getResources().getString(R.string.runtime_formula));
mathView.setViewBackgroundColor(ContextCompat.getColor(getApplicationContext(),android.R.color.black));


### Demo

Sample code is available under the app module, in this same repo

 The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.