Skip to content

Commit cd9ddf9

Browse files
committed
修复getLaTeXstring的一些bug
1 parent a08d5d8 commit cd9ddf9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

mathS/src/MathObject.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::string mathS::Function::GetLaTeXString() const
3838
static std::unordered_map<std::string, std::string> str2LaTeXstr = {
3939
{"Exp", "\\exp"}, {"Sin", "\\sin"}, {"Cos", "\\cos"}, {"Tan", "\\tan"},
4040
{"Log", "\\log"}, {"Ln", "\\ln"}, {"Lg", "\\lg"}, {"Cot", "\\cot"}, {"Csc", "\\csc"},
41-
{"Sec", "\\sec"}, {"ASin", "\arcsin"}, {"ACos", "\arccos"}, {"ATan", "\\arctan"},
41+
{"Sec", "\\sec"}, {"ASin", "\\arcsin"}, {"ACos", "\\arccos"}, {"ATan", "\\arctan"},
4242
{"Sgn", "\\sgn"}, {"Det", "\\det"}, {"Sqrt", "\\sqrt"}
4343
};
4444
std::string funName = function->GetLaTeXString();
@@ -99,7 +99,7 @@ std::string mathS::Power::GetString() const
9999
std::string mathS::Power::GetLaTeXString() const
100100
{
101101
return
102-
(base->Level() < LEVEL_POWER ? base->GetLaTeXString() : "\\left(" + base->GetString() + "\\right)") + "^" +
102+
(base->Level() < LEVEL_FUNCTION ? base->GetLaTeXString() : "\\left(" + base->GetLaTeXString() + "\\right)") + "^" +
103103
("{" + exponent->GetLaTeXString() + "}");
104104
}
105105

@@ -200,13 +200,17 @@ std::string mathS::Item::GetLaTeXString() const
200200
else {
201201
if (braceflag)
202202
temp += factors[i]->GetLaTeXString();
203-
else
204-
temp += "\\," + factors[i]->GetLaTeXString();
203+
else {
204+
if (factors[i]->GetType()==Type::ATOM && Dynamic_cast<Atom>(factors[i])->AtomType()==Type::NUMBER)
205+
temp += "\\times " + factors[i]->GetLaTeXString();
206+
else
207+
temp += "\\, " + factors[i]->GetLaTeXString();
208+
}
205209
braceflag = 0;
206210
}
207211
}
208212
else {
209-
ret += temp + "\\cdot";
213+
ret += temp + "\\times ";
210214
temp = "";
211215
invflag = 0;
212216
if (factors[i]->Level() < LEVEL_ITEM) {
@@ -394,7 +398,7 @@ std::string mathS::Atom::GetString() const
394398
std::string mathS::Atom::GetLaTeXString() const
395399
{
396400
std::string LaTeXstr;
397-
if (str == "PI")
401+
if (str == "Pi")
398402
return "{\\pi}";
399403
if (str == "E")
400404
return "\\mathrm{e}";

0 commit comments

Comments
 (0)