From c0bbe8f55719b01c23d29a94592f29a3722a0aba Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Wed, 31 Jan 2024 15:47:26 +0100 Subject: [PATCH] FIXED issue #117: Unnecessary printing of tilde symbol in math (thanks to user:igormironchik for reporting):
Tilde was not recognized as a LaTeX instruction, now is interpreted as non-breaking whitespace --- doc/dox/whatsnew.dox | 1 + lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.cpp | 8 ++++++++ lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.h | 1 + 3 files changed, 10 insertions(+) diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index 7ac8e09c6b..35a7ca9cb4 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -129,6 +129,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
  • FIXED: symbol spacing in math mode (and text mode)
  • FIXED/IMPROVED: JKQTMathText renders several LaTeX strings better (simple braces in math mode, \c +-*... as symbols with proper sizes in math mode, added some missing instruction aliases, improved size of \\vec and \\hat, corrrected fonts usage for \\mathrm
  • FIXED: \c \\sum and \c \\prod used the wrong symbol in XITS-mode
  • +
  • FIXED issue #117: Unnecessary printing of tilde symbol in math (thanks to user:igormironchik for reporting):
    Tilde was not recognized as a LaTeX instruction, now is interpreted as non-breaking whitespace
  • IMPROVED: high-dpr-support in JKQTMathText
  • IMPROVED: typesetting of sub-/supercripts, especially for large math operators and braces
  • MODIFIED: brace node now calculates the extension of the child height above or below the strikeoutPos, in order to center braces around the strikeoutPos
  • diff --git a/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.cpp b/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.cpp index d5982769da..b26626466a 100644 --- a/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.cpp +++ b/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.cpp @@ -561,6 +561,11 @@ JKQTMathTextLatexParser::tokenType JKQTMathTextLatexParser::getToken() { //std::cout<<"found ampersand\n"; return currentToken=MTTampersand; //---------------------------------------------------------- + // check for ~ character + } else if (c=='~') { + //std::cout<<"found tilde\n"; + return currentToken=MTTtilde; + //---------------------------------------------------------- // check for { character } else if (c=='{') { //---------------------------------------------------------- @@ -703,6 +708,8 @@ JKQTMathTextNode* JKQTMathTextLatexParser::parseLatexString(bool get, JKQTMathTe break; } else if (currentToken==MTTwhitespace) { if (!parsingMathEnvironment) nl->addChild(new JKQTMathTextWhitespaceNode(parentMathText)); + } else if (currentToken==MTTtilde) { + nl->addChild(new JKQTMathTextWhitespaceNode(JKQTMathTextWhitespaceNode::WSTNonbreaking, parentMathText)); } else if (currentToken==MTTendash) { nl->addChild(new JKQTMathTextSymbolNode(parentMathText, "endash")); } else if (currentToken==MTTemdash) { @@ -1337,6 +1344,7 @@ QString JKQTMathTextLatexParser::tokenType2String(tokenType type) case MTTinstructionVerbatimVisibleSpace: return "MTTinstructionVerbatimVisibleSpace"; case MTTinstructionBegin: return "MTTinstructionBegin"; case MTTinstructionEnd: return "MTTinstructionEnd"; + case MTTtilde: return "MTTtilde"; } return "???"; } diff --git a/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.h b/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.h index 8ebd17b8f7..02c8c05715 100644 --- a/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.h +++ b/lib/jkqtmathtext/parsers/jkqtmathtextlatexparser.h @@ -92,6 +92,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextLatexParser : public JKQTMathTextParse MTThyphen, /*!< \brief the single hyphen character \c "-" in text-mode \note MTTendash and MTTemdash take precedence over MTThypen */ MTTendash, /*!< \brief the en-dash character sequence \c "--" in text-mode */ MTTemdash, /*!< \brief the em-dash character sequence \c "---" in text-mode */ + MTTtilde, /*!< \brief the tilde character \c "~" */ }; /** \brief convert a tokenType into a string, e.g. for debugging output */