FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/issues/117">#117: Unnecessary printing of tilde symbol in math</a> (thanks to <a href="https://github.com/igormironchik">user:igormironchik</a> for reporting):<br/>Tilde was not recognized as a LaTeX instruction, now is interpreted as non-breaking whitespace

This commit is contained in:
jkriege2 2024-01-31 15:47:26 +01:00
parent f234f41540
commit c0bbe8f557
3 changed files with 10 additions and 0 deletions

View File

@ -129,6 +129,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>FIXED: symbol spacing in math mode (and text mode)</li>
<li>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</li>
<li>FIXED: \c \\sum and \c \\prod used the wrong symbol in XITS-mode</li>
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/issues/117">#117: Unnecessary printing of tilde symbol in math</a> (thanks to <a href="https://github.com/igormironchik">user:igormironchik</a> for reporting):<br/>Tilde was not recognized as a LaTeX instruction, now is interpreted as non-breaking whitespace</li>
<li>IMPROVED: high-dpr-support in JKQTMathText</li>
<li>IMPROVED: typesetting of sub-/supercripts, especially for large math operators and braces</li>
<li>MODIFIED: brace node now calculates the extension of the child height above or below the strikeoutPos, in order to center braces around the strikeoutPos</li>

View File

@ -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 "???";
}

View File

@ -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 */