diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index 65fb766966..c686ded028 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -17,6 +17,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
fixed issue described in #62: Fix custom labels draw, because giving exactly two label-strings did not display all of them, thanks to user:FalsinSoft
fixed issue #70: Typo in jkqtplotter/CMakeLists.txt, thanks to user:tedlinlab
fixed: styling was not properly applied to coordinate axes of colorbars outside the plot
+ fixed: JKQTMathText added a little whitespace before and after the LaTeX-string. This was removed as it disturbed the layout of text in plots
improved: high-dpr-support in JKQTMathText
improved: QT6-compatibility by removing deprecated warnings
NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request #68 Wiggle Plots from user:xichaoqiang
diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp
index ec52668d61..effdce4047 100644
--- a/lib/jkqtmathtext/jkqtmathtext.cpp
+++ b/lib/jkqtmathtext/jkqtmathtext.cpp
@@ -4538,8 +4538,10 @@ QRectF JKQTMathText::getTightBoundingRect(const QFont &fm, const QString &text,
-bool JKQTMathText::parse(QString text){
- QString ntext=QString("\\;")+text+QString("\\;");
+bool JKQTMathText::parse(const QString& text, bool addSpaceBeforeAndAfter){
+ QString ntext;
+ if (addSpaceBeforeAndAfter) ntext=QString("\\;")+text+QString("\\;");
+ else ntext=text;
ntext=ntext.remove("\\limits");
if (parsedNode && parseString==ntext) return true;
diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h
index 5e76ae4b41..221f89aa8a 100644
--- a/lib/jkqtmathtext/jkqtmathtext.h
+++ b/lib/jkqtmathtext/jkqtmathtext.h
@@ -303,8 +303,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
void loadSettings(const QSettings& settings, const QString& group=QString("mathtext/"));
/** \brief store the object settings to the given QSettings object with the given name prefix */
void saveSettings(QSettings& settings, const QString& group=QString("mathtext/")) const;
- /** \brief parse the given enhanced string. Returns \c true on success. */
- bool parse(QString text);
+ /** \brief parse the given enhanced string. If \c addSpaceBeforeAndAfter==true a little bit of space is added before and after the text. Returns \c true on success. */
+ bool parse(const QString &text, bool addSpaceBeforeAndAfter=false);
/** \brief get the size of the drawn representation. returns an invalid size if no text has been parsed. */
QSizeF getSize(QPainter& painter);
/** \brief return the descent, i.e. the distance from the baseline to the lowest part of the representation */
diff --git a/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp b/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp
index 1c37f4595b..fd24775026 100644
--- a/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpgeoannotations.cpp
@@ -129,7 +129,7 @@ void JKQTPGeoText::draw(JKQTPEnhancedPainter& painter) {
parent->getMathText()->setFontRomanOrSpecial(getTextFontName());
parent->getMathText()->setFontSize(getTextFontSize()*parent->getFontSizeMultiplier());
parent->getMathText()->setFontColor(getTextColor());
- parent->getMathText()->parse(text);
+ parent->getMathText()->parse("\\;"+text);
parent->getMathText()->draw(painter, transformX(x), transformY(y), parent->getCurrentPlotterStyle().debugShowTextBoxes);
}