diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index f9dca116c4..10274d6cc8 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -71,6 +71,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
NEW: JKQTMathTextVerticalListNode allows to typeset a vertical list of lines
NEW: added \c \\substack[lcr]{...\\\\...} , \c \\lsubstack{...\\\\...} , \c \\rsubstack{...\\\\...} instructions
NEW: added support for flushleft/flushright/center-environments with linebreaks
+ NEW: added support for framed/shaded/snugshade-environments with linebreaks and framed
diff --git a/doc/images/jkqtmathtext/jkqtmathtext_beginframed.png b/doc/images/jkqtmathtext/jkqtmathtext_beginframed.png
new file mode 100644
index 0000000000..eff77889bd
Binary files /dev/null and b/doc/images/jkqtmathtext/jkqtmathtext_beginframed.png differ
diff --git a/doc/images/jkqtmathtext/jkqtmathtext_beginshaded.png b/doc/images/jkqtmathtext/jkqtmathtext_beginshaded.png
new file mode 100644
index 0000000000..657e6b97a5
Binary files /dev/null and b/doc/images/jkqtmathtext/jkqtmathtext_beginshaded.png differ
diff --git a/doc/images/jkqtmathtext/jkqtmathtext_beginsnugshade.png b/doc/images/jkqtmathtext/jkqtmathtext_beginsnugshade.png
new file mode 100644
index 0000000000..d0772b5dcc
Binary files /dev/null and b/doc/images/jkqtmathtext/jkqtmathtext_beginsnugshade.png differ
diff --git a/examples/jkqtmathtext_test/testform.cpp b/examples/jkqtmathtext_test/testform.cpp
index d02389b5e5..a927e45b97 100644
--- a/examples/jkqtmathtext_test/testform.cpp
+++ b/examples/jkqtmathtext_test/testform.cpp
@@ -75,6 +75,9 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbTestset->addItem("text: flushleft", "\\begin{flushleft}text\\\\\\textbf{2^{nd} line of text}\\\\last \\textit{line!} $\\frac{1}{2}$\\end{flushleft}");
ui->cmbTestset->addItem("text: flushright", "\\begin{flushright}text\\\\\\textbf{2^{nd} line of text}\\\\last \\textit{line!} $\\frac{1}{2}$\\end{flushright}");
ui->cmbTestset->addItem("text: center", "\\begin{center}text\\\\\\textbf{2^{nd} line of text}\\\\last \\textit{line!} $\\frac{1}{2}$\\end{center}");
+ ui->cmbTestset->addItem("text: framed", "\\begin{framed}text\\\\\\textbf{2^{nd} line of text}\\\\last \\textit{line!} $\\frac{1}{2}$\\end{framed}");
+ ui->cmbTestset->addItem("text: shaded", "\\begin{shaded}text\\\\\\textbf{2^{nd} line of text}\\\\last \\textit{line!} $\\frac{1}{2}$\\end{shaded}");
+ ui->cmbTestset->addItem("text: snugshade", "\\begin{snugshade}text\\\\\\textbf{2^{nd} line of text}\\\\last \\textit{line!} $\\frac{1}{2}$\\end{snugshade}");
ui->cmbTestset->addItem("mathtest", "This is normal text: $this is math:\\langle r^2(\\tau)\\rangle=\\left\\langle (\\vec{r}(t)-\\vec{r}(t+\\tau) )^2\\right\\rangle\\ \\ \\ g(\\tau)=\\frac{1}{N}\\cdot\\left(1+\\frac{2}{3}\\frac{\\langle r^2(\\tau)\\rangle}{w_{xy}^2}\\right)^{-1} \\lfloor\\rfloor\\lceil\\rceil\\langle\\rangle\\left\\{\\vec{a}\\left|\\|\\vec{a}\\|_2\\geq2\\right.\\right\\} \\vec{r}\\vec{R}\\frac{\\sqrt{\\sqrt{\\sqrt{\\sum_{i=0}^\\infty \\hat{i}^2}+y^\\alpha}+1}}{\\dot{v}\\equiv\\ddot{r}}\\argmin_{\\vec{k}}\\sum_{\\sqrt{i}=0}^{N}\\int_{x_0}^{x_1}\\left(\\left(\\left(x\\right)\\right)\\right)\\underbrace{\\left[\\left\\{\\frac{\\partial f}{\\partial x}\\right\\}\\cdot\\frac{1}{2}\\right]}{\\text{underbraced text \\hbar}}\\cdots\\frac{\\sqrt{\\sum_{i=0}^2 \\hat{i}^2}+y^\\alpha}{\\dot{v}\\equiv\\ddot{r}}, \\hat{t}\\hat{T} \\overbrace{\\left|\\sqrt{x\\cdot Y}\\right|}{\\propto\\bbN\\circ\\bbZ} \\left<\\arrow{x(\\tau)}\\cdot\\vec{R}(t+\\bar{\\tau})\\right> \\alpha\\beta\\gamma\\delta\\epsilon\\Gamma\\Delta\\Theta\\Omega \\left\\_\\left~\\cbrt{\\hbar\\omega}\\right~\\right\\_$");
ui->cmbTestset->addItem("math: upper/lower parantheses test:", "$\\text{bblabla} \\frac{1}{2}\\cdot\\left(\\frac{1}{\\mathrm{e}^x+\\mathrm{e}^{-x}}\\right)\\cdot\\left(\\frac{1}{\\frac{1+2}{5+x}}\\right)\\cdot\\left(\\frac{1}{\\exp\\left[-\\frac{y^2}{\\sqrt{x}}\\right]\\cdot\\exp\\left[-\\frac{1}{\\frac{1}{2}}\\right]}\\right) $");
ui->cmbTestset->addItem("math: ACF test", "$g_{rg}^{ab}(\\tau)=\\frac{1}{N}\\cdot\\left(1+\\frac{2}{3}\\frac{\\langle r^2(\\tau)\\rangle}{w_{xy}^2}\\right)^{-1}\\cdot\\left(1+\\frac{2}{3}\\frac{\\langle r^2(\\tau)\\rangle}{w_{xy}^2}\\right)^{-\\frac{1}{2}}$");
diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp
index 9bc550deca..adcc7b8ec9 100644
--- a/lib/jkqtmathtext/jkqtmathtext.cpp
+++ b/lib/jkqtmathtext/jkqtmathtext.cpp
@@ -1534,6 +1534,17 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, JKQTMathTextBraceType
vlist->addChild(parseLatexString(true, MTBTAny, envname));
first=false;
}
+ } else if (envname=="framed" || envname=="shaded" || envname=="snugshade") {
+ JKQTMathTextHorizontalAlignment alignment=MTHALeft;
+ JKQTMathTextVerticalListNode* vlist = new JKQTMathTextVerticalListNode(this, alignment, 1.0, JKQTMathTextVerticalListNode::SMDefault, MTVOFirstLine );
+ QStringList color;
+ color<addChild(new JKQTMathTextBoxInstructionNode(this, envname, vlist, color));
+ bool first=true;
+ while (first || currentToken==MTTinstructionNewline) {
+ vlist->addChild(parseLatexString(true, MTBTAny, envname));
+ first=false;
+ }
} else {
error_list.append(tr("error @ ch. %1: unknown environment '%2'").arg(currentTokenID).arg(envname));
}
diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h
index d147d1b96f..731d367e52 100644
--- a/lib/jkqtmathtext/jkqtmathtext.h
+++ b/lib/jkqtmathtext/jkqtmathtext.h
@@ -202,12 +202,15 @@ class JKQTMathTextNode; // forward
- $\\rsubstack{...\\\\...}$
\image html jkqtmathtext/jkqtmathtext_rsubstack.png
.
- \subsection JKQTMathTextSuppoertedLaTeXTextAlignment Environments with Multi-line text
+ \subsection JKQTMathTextSuppoertedLaTeXTextAlignment Environments for Multi-line text
Several environments are supported that allow to layout text with linebreaks and different alignemnts:
- $\\begin{document} ... \\\\ ... \\end{document}$
\image html jkqtmathtext/jkqtmathtext_beginflushleft.png
- $\\begin{flushleft} ... \\\\ ... \\end{flushleft}$
\image html jkqtmathtext/jkqtmathtext_beginflushleft.png
- $\\begin{flushright} ... \\\\ ... \\end{flushright}$
\image html jkqtmathtext/jkqtmathtext_beginflushright.png
- $\\begin{center} ... \\\\ ... \\end{center}$
\image html jkqtmathtext/jkqtmathtext_begincenter.png
+ - $\\begin{framed} ... \\\\ ... \\end{framed}$
\image html jkqtmathtext/jkqtmathtext_beginframed.png
+ - $\\begin{shaded} ... \\\\ ... \\end{shaded}$
\image html jkqtmathtext/jkqtmathtext_beginshaded.png
+ - $\\begin{snugshade} ... \\\\ ... \\end{snugshade}$
\image html jkqtmathtext/jkqtmathtext_beginsnugshade.png
.
\section JKQTMathTextSuppoertedFonts Font Handling
diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp
index 412fdc55d7..62fe27060a 100644
--- a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp
+++ b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp
@@ -798,6 +798,16 @@ void JKQTMathTextBoxInstructionNode::fillInstructions()
/*Nparams=*/1);
instructions["shaded"] = i;
}
+ {
+ InstructionProperties i(InstructionProperties::NoModification,
+ InstructionProperties::NoPen,
+ [](JKQTMathTextEnvironment& /*ev*/, const QStringList& parameters, JKQTMathText* /*parent*/){
+ return QBrush(jkqtp_String2QColor(parameters.value(0, QColor(Qt::transparent).name())), Qt::SolidPattern);
+ },
+ 0,
+ /*Nparams=*/1);
+ instructions["snugshade"] = i;
+ }
{
InstructionProperties i(InstructionProperties::NoModification,
[](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){