added slanted fractions to JKQTMathText + improved documentation
@ -55,9 +55,11 @@ Changes, compared to \ref page_whatsnew_V2018_08 "v2018.08" include:
|
|||||||
</ul></li>
|
</ul></li>
|
||||||
<li> Updates to JKQTMathText:
|
<li> Updates to JKQTMathText:
|
||||||
<ul>
|
<ul>
|
||||||
|
<li> new: slanted fractions (<code>\sfrac{}{}</code>, <code>\stfrac{}{}</code>) </li>
|
||||||
<li> update/fix: several general improvements and bugfixes </li>
|
<li> update/fix: several general improvements and bugfixes </li>
|
||||||
<li> update/fix: improved error handling </li>
|
<li> update/fix: improved error handling </li>
|
||||||
<li> update: updated contained version of STIX fonts, better handling of different STIX versions </li>
|
<li> update: updated contained version of STIX fonts, better handling of different STIX versions </li>
|
||||||
|
<li> update: improved documentation</li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
BIN
doc/images/mathparser/MTDarrow.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
doc/images/mathparser/MTDbar.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
doc/images/mathparser/MTDddot.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
doc/images/mathparser/MTDdot.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
doc/images/mathparser/MTDdoubleoverline.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
doc/images/mathparser/MTDdoubleunderline.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
doc/images/mathparser/MTDhat.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
doc/images/mathparser/MTDoverline.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
doc/images/mathparser/MTDtilde.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
doc/images/mathparser/MTDunderline.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
doc/images/mathparser/MTDvec.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
doc/images/mathparser/MTFMdfrac.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
doc/images/mathparser/MTFMfrac.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
doc/images/mathparser/MTFMoverbrace.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
doc/images/mathparser/MTFMoverset.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
doc/images/mathparser/MTFMsfrac.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
doc/images/mathparser/MTFMstackrel.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
doc/images/mathparser/MTFMstfrac.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
doc/images/mathparser/MTFMtfrac.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
doc/images/mathparser/MTFMunderbrace.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
doc/images/mathparser/MTFMunderset.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
@ -69,6 +69,9 @@ TestForm::TestForm(QWidget *parent) :
|
|||||||
ui->cmbTestset->addItem("frac test", "$\\frac{a}{b}+\\frac{g}{a}-\\frac{a^2}{b^2}\\cdot\\frac{a^2}{b^{\\frac{1}{2}}}$");
|
ui->cmbTestset->addItem("frac test", "$\\frac{a}{b}+\\frac{g}{a}-\\frac{a^2}{b^2}\\cdot\\frac{a^2}{b^{\\frac{1}{2}}}$");
|
||||||
ui->cmbTestset->addItem("tfrac test", "$\\tfrac{a}{b}+\\tfrac{g}{a}-\\tfrac{a^2}{b^2}\\cdot\\tfrac{a^2}{b^{\\tfrac{1}{2}}}$");
|
ui->cmbTestset->addItem("tfrac test", "$\\tfrac{a}{b}+\\tfrac{g}{a}-\\tfrac{a^2}{b^2}\\cdot\\tfrac{a^2}{b^{\\tfrac{1}{2}}}$");
|
||||||
ui->cmbTestset->addItem("dfrac test", "$\\dfrac{a}{b}+\\dfrac{g}{a}-\\dfrac{a^2}{b^2}\\cdot\\dfrac{a^2}{b^{\\dfrac{1}{2}}}$");
|
ui->cmbTestset->addItem("dfrac test", "$\\dfrac{a}{b}+\\dfrac{g}{a}-\\dfrac{a^2}{b^2}\\cdot\\dfrac{a^2}{b^{\\dfrac{1}{2}}}$");
|
||||||
|
ui->cmbTestset->addItem("sfrac test", "$\\sfrac{a}{b}+\\sfrac{g}{a}-\\sfrac{a^2}{b^2}\\cdot\\sfrac{a^2}{b^{\\sfrac{1}{2}}}$");
|
||||||
|
ui->cmbTestset->addItem("stfrac test", "$\\stfrac{a}{b}+\\stfrac{g}{a}-\\stfrac{a^2}{b^2}\\cdot\\stfrac{a^2}{b^{\\stfrac{1}{2}}}$");
|
||||||
|
ui->cmbTestset->addItem("number fractions test", "frac: \\frac{1}{2}, \\frac{3}{4},\\ \\ \\ tfrac: \\tfrac{1}{2}, \\tfrac{3}{4},\\ \\ \\ sfrac: \\sfrac{1}{2}, \\sfrac{3}{4},\\ \\ \\ stfrac: \\stfrac{1}{2}, \\stfrac{3}{4},\\ \\ \\ ");
|
||||||
ui->cmbTestset->addItem("stackrel test", "$\\stackrel{a}{b}+\\stackrel{g}{a}-\\stackrel{a^2}{b^2}\\cdot\\stackrel{a^2}{b^{\\stackrel{1}{2}}}$");
|
ui->cmbTestset->addItem("stackrel test", "$\\stackrel{a}{b}+\\stackrel{g}{a}-\\stackrel{a^2}{b^2}\\cdot\\stackrel{a^2}{b^{\\stackrel{1}{2}}}$");
|
||||||
ui->cmbTestset->addItem("brace0 test", "\\langle\\langle -- $\\langle\\langle$");
|
ui->cmbTestset->addItem("brace0 test", "\\langle\\langle -- $\\langle\\langle$");
|
||||||
ui->cmbTestset->addItem("brace1 test", "\\langle\\langle r^{123} -- $\\langle\\langle r^{123}$");
|
ui->cmbTestset->addItem("brace1 test", "\\langle\\langle r^{123} -- $\\langle\\langle r^{123}$");
|
||||||
|
@ -742,10 +742,10 @@ void JKQTMathText::MTfracNode::getSizeInternal(QPainter& painter, JKQTMathText::
|
|||||||
ev2.fontSize=ev2.fontSize*parent->getUnderbraceFactor();
|
ev2.fontSize=ev2.fontSize*parent->getUnderbraceFactor();
|
||||||
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
||||||
ev2.fontSize=ev2.fontSize*parent->getUndersetFactor();
|
ev2.fontSize=ev2.fontSize*parent->getUndersetFactor();
|
||||||
} else if (mode==MTFMfrac) {
|
} else if (mode==MTFMfrac || mode==MTFMsfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor();
|
ev1.fontSize=ev1.fontSize*parent->getFracFactor();
|
||||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor();
|
ev2.fontSize=ev2.fontSize*parent->getFracFactor();
|
||||||
} else if (mode==MTFMtfrac) {
|
} else if (mode==MTFMtfrac || mode==MTFMstfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor()*0.7;
|
ev1.fontSize=ev1.fontSize*parent->getFracFactor()*0.7;
|
||||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor()*0.7;
|
ev2.fontSize=ev2.fontSize*parent->getFracFactor()*0.7;
|
||||||
}
|
}
|
||||||
@ -770,6 +770,11 @@ void JKQTMathText::MTfracNode::getSizeInternal(QPainter& painter, JKQTMathText::
|
|||||||
//std::cout<<"=> baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight<<std::endl;
|
//std::cout<<"=> baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight<<std::endl;
|
||||||
width=qMax(width1, width2)+ xw;
|
width=qMax(width1, width2)+ xw;
|
||||||
strikeoutPos=sp;
|
strikeoutPos=sp;
|
||||||
|
} else if (mode==MTFMstfrac || mode==MTFMsfrac) {
|
||||||
|
overallHeight=2.0*qMax(overallHeight1, overallHeight2)+sp*(2.0*parent->getFracShiftFactor());
|
||||||
|
baselineHeight=qMax(overallHeight1, overallHeight2)+xh*(2.0*parent->getFracShiftFactor());
|
||||||
|
width=width1+width2+xw;
|
||||||
|
strikeoutPos=sp;
|
||||||
} else if (mode==MTFMstackrel) {
|
} else if (mode==MTFMstackrel) {
|
||||||
//overallHeight=overallHeight1+overallHeight2+sp*(2.0*parent->getFracShiftFactor());
|
//overallHeight=overallHeight1+overallHeight2+sp*(2.0*parent->getFracShiftFactor());
|
||||||
//baselineHeight=overallHeight1+xh*(2.0*parent->getFracShiftFactor());
|
//baselineHeight=overallHeight1+xh*(2.0*parent->getFracShiftFactor());
|
||||||
@ -818,14 +823,15 @@ double JKQTMathText::MTfracNode::draw(QPainter& painter, double x, double y, JKQ
|
|||||||
ev2.fontSize=ev2.fontSize*parent->getUnderbraceFactor();
|
ev2.fontSize=ev2.fontSize*parent->getUnderbraceFactor();
|
||||||
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
} else if (mode==MTFMunderset || mode==MTFMoverset) {
|
||||||
ev2.fontSize=ev2.fontSize*parent->getUndersetFactor();
|
ev2.fontSize=ev2.fontSize*parent->getUndersetFactor();
|
||||||
} else if (mode==MTFMfrac) {
|
} else if (mode==MTFMfrac || mode==MTFMsfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor();
|
ev1.fontSize=ev1.fontSize*parent->getFracFactor();
|
||||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor();
|
ev2.fontSize=ev2.fontSize*parent->getFracFactor();
|
||||||
} else if (mode==MTFMtfrac) {
|
} else if (mode==MTFMtfrac || mode==MTFMstfrac) {
|
||||||
ev1.fontSize=ev1.fontSize*parent->getFracFactor()*0.7;
|
ev1.fontSize=ev1.fontSize*parent->getFracFactor()*0.7;
|
||||||
ev2.fontSize=ev2.fontSize*parent->getFracFactor()*0.7;
|
ev2.fontSize=ev2.fontSize*parent->getFracFactor()*0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double width1=0, baselineHeight1=0, overallHeight1=0;//, strikeoutPos1=0;
|
double width1=0, baselineHeight1=0, overallHeight1=0;//, strikeoutPos1=0;
|
||||||
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos=0;
|
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos=0;
|
||||||
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos);
|
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos);
|
||||||
@ -853,6 +859,11 @@ double JKQTMathText::MTfracNode::draw(QPainter& painter, double x, double y, JKQ
|
|||||||
if (l.length()>0) painter.drawLine(l);
|
if (l.length()>0) painter.drawLine(l);
|
||||||
child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->getFracShiftFactor())-descent1, ev1);
|
child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->getFracShiftFactor())-descent1, ev1);
|
||||||
child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->getFracShiftFactor())+ascent2, ev2);
|
child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->getFracShiftFactor())+ascent2, ev2);
|
||||||
|
} else if (mode==MTFMstfrac || mode==MTFMsfrac) {
|
||||||
|
child1->draw(painter, x, yline-descent1, ev1);
|
||||||
|
child2->draw(painter, x+width+xw, yline+ascent2, ev2);
|
||||||
|
QLineF l(x+width+1.2*xw, yline-descent1-ascent1, x+width-0.2*xw, yline+ascent1+descent1);
|
||||||
|
if (l.length()>0) painter.drawLine(l);
|
||||||
} else if (mode==MTFMstackrel) {
|
} else if (mode==MTFMstackrel) {
|
||||||
child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->getFracShiftFactor())-descent1, ev1);
|
child1->draw(painter, x+xw/2.0+(width-width1)/2.0, yline-xh*(parent->getFracShiftFactor())-descent1, ev1);
|
||||||
child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->getFracShiftFactor())+ascent2, ev2);
|
child2->draw(painter, x+xw/2.0+(width-width2)/2.0, yline+xh*(parent->getFracShiftFactor())+ascent2, ev2);
|
||||||
@ -886,7 +897,8 @@ double JKQTMathText::MTfracNode::draw(QPainter& painter, double x, double y, JKQ
|
|||||||
|
|
||||||
|
|
||||||
if (mode==MTFMstackrel) return x+width+ xw;
|
if (mode==MTFMstackrel) return x+width+ xw;
|
||||||
return x+width+xw;
|
else if (mode==MTFMstfrac || mode==MTFMsfrac) return x+width+width2+xw;
|
||||||
|
else return x+width+xw;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3730,6 +3742,18 @@ JKQTMathText::MTnode* JKQTMathText::parseLatexString(bool get, const QString& qu
|
|||||||
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMdfrac));
|
if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMdfrac));
|
||||||
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
|
} else if (name=="sfrac" || name=="slantfrac" || name=="xfrac") {
|
||||||
|
MTnode* n1=parseLatexString(true);
|
||||||
|
MTnode* n2=nullptr;
|
||||||
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
|
if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMsfrac));
|
||||||
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
|
} else if (name=="stfrac" || name=="nicefrac" || name=="slanttextfrac" || name=="xtfrac") {
|
||||||
|
MTnode* n1=parseLatexString(true);
|
||||||
|
MTnode* n2=nullptr;
|
||||||
|
if (getToken()==MTTopenbrace) n2=parseLatexString(true);
|
||||||
|
if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMstfrac));
|
||||||
|
else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name));
|
||||||
} else if (name=="tfrac") {
|
} else if (name=="tfrac") {
|
||||||
MTnode* n1=parseLatexString(true);
|
MTnode* n1=parseLatexString(true);
|
||||||
MTnode* n2=nullptr;
|
MTnode* n2=nullptr;
|
||||||
@ -4257,6 +4281,10 @@ QString JKQTMathText::fracModeToString(JKQTMathText::MTfracMode mode)
|
|||||||
return "frac";
|
return "frac";
|
||||||
case MTFMdfrac:
|
case MTFMdfrac:
|
||||||
return "dfrac";
|
return "dfrac";
|
||||||
|
case MTFMsfrac:
|
||||||
|
return "sfrac";
|
||||||
|
case MTFMstfrac:
|
||||||
|
return "stfrac";
|
||||||
case MTFMtfrac:
|
case MTFMtfrac:
|
||||||
return "tfrac";
|
return "tfrac";
|
||||||
case MTFMunderbrace:
|
case MTFMunderbrace:
|
||||||
|
@ -167,6 +167,8 @@ JKQTP_LIB_EXPORT void initJKQTMathTextResources();
|
|||||||
\subsection JKQTMathTextSuppoertedLaTeXMatrix Matrix/Array Type Instructions
|
\subsection JKQTMathTextSuppoertedLaTeXMatrix Matrix/Array Type Instructions
|
||||||
Several Matrix/Array-typed LaTeX instructions are supported:
|
Several Matrix/Array-typed LaTeX instructions are supported:
|
||||||
- <code>$\frac{...}{...}$</code>, <code>$\tfrac{...}{...}$</code> (70% smaller font), <code>$\dfrac{...}{...}$</code> \image html jkqtmathtext_brace_frac.png
|
- <code>$\frac{...}{...}$</code>, <code>$\tfrac{...}{...}$</code> (70% smaller font), <code>$\dfrac{...}{...}$</code> \image html jkqtmathtext_brace_frac.png
|
||||||
|
- <code>$\sfrac{...}{...}$</code> \image html mathparser/MTFMsfrac.png
|
||||||
|
- <code>$\stfrac{...}{...}$</code> (70% smaller font) \image html mathparser/MTFMstfrac.png
|
||||||
- <code>$\stackrel{...}{...}$ $\binom{...}{...}$</code> \image html jkqtmathtext_brace_stackrel.png
|
- <code>$\stackrel{...}{...}$ $\binom{...}{...}$</code> \image html jkqtmathtext_brace_stackrel.png
|
||||||
- <code>$\begin{cases} ... & ... \\ ... & ... \end{cases}$</code> \image html jkqtmathtext_brace_begincases.png
|
- <code>$\begin{cases} ... & ... \\ ... & ... \end{cases}$</code> \image html jkqtmathtext_brace_begincases.png
|
||||||
- <code>$\begin{array} a & b & ...\\ c & d & ...\end{array}$</code> <code>$\begin{matrix} a & b & ...\\ c & d & ...\end{matrix}$</code> \image html jkqtmathtext_array.png
|
- <code>$\begin{array} a & b & ...\\ c & d & ...\end{array}$</code> <code>$\begin{matrix} a & b & ...\\ c & d & ...\end{matrix}$</code> \image html jkqtmathtext_array.png
|
||||||
@ -1082,14 +1084,16 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum MTfracMode {
|
enum MTfracMode {
|
||||||
MTFMfrac,
|
MTFMfrac, /*!< \brief normal fraction \image html mathparser/MTFMfrac.png */
|
||||||
MTFMdfrac,
|
MTFMdfrac, /*!< \brief normal fraction, without scaling of under/over text \image html mathparser/MTFMdfrac.png */
|
||||||
MTFMtfrac,
|
MTFMtfrac, /*!< \brief text fraction (smaller than MTFMfrac) \image html mathparser/MTFMtfrac.png */
|
||||||
MTFMunderbrace,
|
MTFMsfrac, /*!< \brief slanted fraction \image html mathparser/MTFMsfrac.png */
|
||||||
MTFMoverbrace,
|
MTFMstfrac, /*!< \brief slanted text fraction \image html mathparser/MTFMstfrac.png */
|
||||||
MTFMstackrel,
|
MTFMunderbrace, /*!< \brief curly underbrace \image html mathparser/MTFMunderbrace.png */
|
||||||
MTFMunderset,
|
MTFMoverbrace, /*!< \brief curly overbrace \image html mathparser/MTFMoverbrace.png */
|
||||||
MTFMoverset
|
MTFMstackrel, /*!< \brief binom/fraction without line \image html mathparser/MTFMstackrel.png */
|
||||||
|
MTFMunderset, /*!< \brief underset text \image html mathparser/MTFMunderset.png */
|
||||||
|
MTFMoverset /*!< \brief overset text \image html mathparser/MTFMoverset.png */
|
||||||
};
|
};
|
||||||
|
|
||||||
static QString fracModeToString(MTfracMode mode);
|
static QString fracModeToString(MTfracMode mode);
|
||||||
@ -1165,17 +1169,17 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
|
|||||||
|
|
||||||
|
|
||||||
enum MTdecoration {
|
enum MTdecoration {
|
||||||
MTDvec,
|
MTDvec, /*!< \brief vector arrow over block \image html mathparser/MTDvec.png */
|
||||||
MTDhat,
|
MTDhat, /*!< \brief hat over block \image html mathparser/MTDhat.png */
|
||||||
MTDdot,
|
MTDdot, /*!< \brief single dot over block \image html mathparser/MTDvec.png */
|
||||||
MTDddot,
|
MTDddot, /*!< \brief double dot over block \image html mathparser/MTDddot.png */
|
||||||
MTDbar,
|
MTDbar, /*!< \brief bar over block \image html mathparser/MTDbar.png */
|
||||||
MTDarrow,
|
MTDarrow, /*!< \brief arrow over block \image html mathparser/MTDarrow.png */
|
||||||
MTDoverline,
|
MTDoverline, /*!< \brief overline over block \image html mathparser/MTDoverline.png */
|
||||||
MTDdoubleoverline,
|
MTDdoubleoverline, /*!< \brief double overline over block \image html mathparser/MTDdoubleoverline.png */
|
||||||
MTDunderline,
|
MTDunderline, /*!< \brief underline under block \image html mathparser/MTDunderline.png */
|
||||||
MTDdoubleunderline,
|
MTDdoubleunderline, /*!< \brief double underline under block \image html mathparser/MTDdoubleunderline.png */
|
||||||
MTDtilde
|
MTDtilde /*!< \brief tilde over block \image html mathparser/MTDtilde.png */
|
||||||
};
|
};
|
||||||
static QString decorationToString(MTdecoration mode);
|
static QString decorationToString(MTdecoration mode);
|
||||||
|
|
||||||
|