From 22c45bcdea73ffe28ab2eb271c1ba2ba641fad56 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 31 Jul 2022 08:17:45 +0200 Subject: [PATCH] JKQTMathText: added support for framed/shaded/snugshade-environments with linebreaks and framed --- doc/dox/whatsnew.dox | 1 + .../jkqtmathtext/jkqtmathtext_beginframed.png | Bin 0 -> 1792 bytes .../jkqtmathtext/jkqtmathtext_beginshaded.png | Bin 0 -> 1713 bytes .../jkqtmathtext/jkqtmathtext_beginsnugshade.png | Bin 0 -> 1708 bytes examples/jkqtmathtext_test/testform.cpp | 3 +++ lib/jkqtmathtext/jkqtmathtext.cpp | 11 +++++++++++ lib/jkqtmathtext/jkqtmathtext.h | 5 ++++- .../nodes/jkqtmathtextinstructionnode.cpp | 10 ++++++++++ 8 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 doc/images/jkqtmathtext/jkqtmathtext_beginframed.png create mode 100644 doc/images/jkqtmathtext/jkqtmathtext_beginshaded.png create mode 100644 doc/images/jkqtmathtext/jkqtmathtext_beginsnugshade.png 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 0000000000000000000000000000000000000000..eff77889bdee9042a21037227ed980c00cfbd8eb GIT binary patch literal 1792 zcmV+b2mknqP)Px#1ZP1_K>z@;j|==^1poj532;b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oi7bxd~<9{ z>bM>DSgJ$&-4$(lt{$)mW%^$DyC#OOv!MV zlHo8V!_iW5yWRdZ4(IFZD+)l85@Qfd$#9sG;V>nG@%{ZDA`#x7VS#as00000NkvXX Hu0mjfv7`uK literal 0 HcmV?d00001 diff --git a/doc/images/jkqtmathtext/jkqtmathtext_beginsnugshade.png b/doc/images/jkqtmathtext/jkqtmathtext_beginsnugshade.png new file mode 100644 index 0000000000000000000000000000000000000000..d0772b5dcc201af301a6808b637947ff99ecb95c GIT binary patch literal 1708 zcmV;d22=ToP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D01|XXSaefwW^{L9 za%BKVa%E+1b7*gLUR4MM000IfNkl9f*tDX7 zEOIA(?X+F{;8pqxD$_QgRvM)p;JIPUg!#2Em}EaRr9(7c?ndaB>H}_HGsQmIE>OD@ zJ4(-PUo+MI35V#vnB?{~ldpX%QGOnP$IA2qByjthNw51TR(cFQJRIiIVR-|%ea#5_ zpp7nZ@}J4VrCs!&_YK0J`4@2r8_-x9aK zCF|Nxul)WpUuE@cA2-15S8@AWGRr={uY3Sx~aQpqty!MmiqrAxRsXiX^ z^S#@zvWR_fn-5XB`pD(>tE^#P33vMgG}}+#5d^Z!s{N*GANzqch<*9ZASGU#hN@s>S|;`uZ3O4TLV%6&m||nEl5V z4{(M|VP9_GIpJl56Jt#k`Eg*Ot3sq|u>a+={2f(tHoKP6{zeG7H#C>{l`WO@m)s?A!c^PS+Q_Pm1 zi=kAuEvt=PEUH+39K^%EqA(N#DM)DM#MS8Ik^V-iLR3mPOoKcdd*a#BdWuwIul=(2 z$xy1aYTLFQee$igHYo3?E``kIPLb-dza!YC-( zmU5hXH0cDQIFr+)YPXLG#Tn*eY!+?XG2HBjSKO0!j{UxfJj2W}fvxtTWVO!OKj^m> z3M;1LZ71;&sD{d)QNL)W|QjA)Ak>J!~jEIt&Qjnl~44MeV6J) z;^Tv$+}J@7izsP83d**NxwbEV1pF>00fF3=PXM@)u;3&~MCs>vH0}RaQM}TVe7g+s6Wl z;Q`e%yoXYL4uc-pzX-+iuy!QRrAAt})f78e?R+NLS1r&Y8flh1hKQ4^FBF-u*o2gn zS`XVo^4T%6MgEzYZeOn&TV|2@k8L`l2V<;=ip?+{{>f+K0C~(!S;=Momsm4j_rZLG zRtobf6RnLJZSoJvqo_$7MocqyEcOf7MVa}!AKi#+AK@(#eK394ev5pWRFniK#6vp^ z8T@|FJ3g zXEVjV(Jh+#6IBeN7>KWlVOV|=Wg=_>S&%$t+CJND%^3T<`bs0Vj$QX_Xe13VB4@!! zT?@(2gB(C_mois`hC6&chgKf8lP{MR`}{o*0IR~~0#N}rz+UQ)NCR+(1VE;R5O#Uq(0voWhez%WQ zK97O^b>A@DelO9!U;7&Yk5MZ>E4lqX!ll3ZV~^XfBOid)!|hi&(>Ky?za(7u>tFVO z+qaza4>4|E5#DO;W#4t{-3O=bzr4Ksa~<5@?QVbmgBryB-Q7JMuE1&g*TKKP{Q%$W zSbqA8CY+Bew0}Xk{Vj3(TjKV&#O-g1+ux3lkN*L9NzBdi29R|C0000cmbTestset->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){