diff --git a/lib/scripts/legacy_lyxpreview2ppm.py b/lib/scripts/legacy_lyxpreview2ppm.py index 77636e340e..71ec171a87 100644 --- a/lib/scripts/legacy_lyxpreview2ppm.py +++ b/lib/scripts/legacy_lyxpreview2ppm.py @@ -258,8 +258,13 @@ def legacy_latex_file(latex_file, fg_color, bg_color): tmp.write(b""" \\usepackage[%s,tightpage]{preview} \\makeatletter -\\g@addto@macro\\preview{\\leavevmode\\begingroup\\color{lyxbg}\\special{background \\current@color}\\special{ps::clippath fill}\\color{lyxfg}} -\\g@addto@macro\\endpreview{\\endgroup} +\\ifdefined\\AddToHook + \\AddToHook{env/preview/before}{\\leavevmode\\begingroup\\color{lyxbg}\\special{background \\current@color}\\special{ps::clippath fill}\\color{lyxfg}} + \\AddToHook{env/preview/after}{\\endgroup} +\\else + \\g@addto@macro\\preview{\\leavevmode\\begingroup\\color{lyxbg}\\special{background \\current@color}\\special{ps::clippath fill}\\color{lyxfg}} + \\g@addto@macro\\endpreview{\\endgroup} +\\fi \\let\\pr@set@pagerightoffset\\@empty \\ifx\\pagerightoffset\\@undefined\\else \\def\\pr@set@pagerightoffset{\\ifnum\\pagedirection=1 diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index efefb04fa0..4cc695334e 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -883,7 +883,8 @@ void InsetMathHull::preparePreview(DocIterator const & pos, if (lsize != "normalsize" && !prefixIs(lsize, "error")) setfont += from_ascii("\\" + lsize + '\n'); - docstring const snippet = macro_preamble + setfont + latexString(*this) + endfont; + docstring const snippet = macro_preamble + setfont + + trim(latexString(*this), "\n") + endfont; LYXERR(Debug::MACROS, "Preview snippet: " << snippet); preview_->addPreview(snippet, *buffer, forexport); }