我想在android中顯示數學方程,我發現這個https://github.com/kexanie/MathView這是工作得很好,但在這個代碼從哪裏可以得到方程的字符串tex。我試圖將一個方程轉換爲使用單詞16的乳膠格式,但是當我將轉換的乳膠字符串替換爲原始字符串(MainActivity中的字符串tex)時,而不是顯示的公式顯示時,乳膠字符串會按原樣顯示。在android中顯示數學方程
第一MainActivity代碼顯示公式完全
public class MainActivity extends AppCompatActivity {
MathView formula_two;
String tex = "This come from string. You can insert inline formula:" +
" \\(ax^2 + bx + c = 0\\) " +
"or displayed formula: $$\\sum_{i=0}^n i^2 = \\frac{(n^2+n)(2n+1)}{6}$$";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
formula_two = (MathView) findViewById(R.id.formula_two);
formula_two.setText(tex);
}
}
這是MainActivity中,我更換了TEX字符串我的字符串
public class MainActivity extends AppCompatActivity {
MathView formula_two;
String tex = "\\begin{document}\n" +
"\n" +
"%\\selectlanguage{english} %%% remove comment delimiter ('%') and select language if required\n" +
"\n" +
"\n" +
"\\noindent ${\\left(x+a\\right)}^n=\\int^n_{k=0}{\\left(\\genfrac{}{}{0pt}{}{n}{k}\\right)x^ka^{n-k}}$ this is a test to check latex format ${\\left(1+x\\right)}^n=1+\\frac{nx}{1!}+\\frac{n\\left(n-1\\right)x^2}{2!}+\\dots $\n" +
"\n" +
"\\noindent \n" +
"\n" +
"\n" +
"\\end{document}";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
formula_two = (MathView) findViewById(R.id.formula_two);
formula_two.setText(tex);
}
}
我肯定做錯了什麼的將數學公式轉換成tex格式。如何可以完美地轉換它我試圖 搜索一個很好的教程,但沒有找到任何。任何幫助將 讚賞