Fix erroneous whitespace before and after math preview (#13127)

This commit is contained in:
Juergen Spitzmueller 2024-12-15 09:49:36 +01:00
parent 0c004a7566
commit 40dd37089d
2 changed files with 9 additions and 3 deletions

View File

@ -258,8 +258,13 @@ def legacy_latex_file(latex_file, fg_color, bg_color):
tmp.write(b""" tmp.write(b"""
\\usepackage[%s,tightpage]{preview} \\usepackage[%s,tightpage]{preview}
\\makeatletter \\makeatletter
\\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\\preview{\\leavevmode\\begingroup\\color{lyxbg}\\special{background \\current@color}\\special{ps::clippath fill}\\color{lyxfg}}
\\g@addto@macro\\endpreview{\\endgroup} \\g@addto@macro\\endpreview{\\endgroup}
\\fi
\\let\\pr@set@pagerightoffset\\@empty \\let\\pr@set@pagerightoffset\\@empty
\\ifx\\pagerightoffset\\@undefined\\else \\ifx\\pagerightoffset\\@undefined\\else
\\def\\pr@set@pagerightoffset{\\ifnum\\pagedirection=1 \\def\\pr@set@pagerightoffset{\\ifnum\\pagedirection=1

View File

@ -883,7 +883,8 @@ void InsetMathHull::preparePreview(DocIterator const & pos,
if (lsize != "normalsize" && !prefixIs(lsize, "error")) if (lsize != "normalsize" && !prefixIs(lsize, "error"))
setfont += from_ascii("\\" + lsize + '\n'); 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); LYXERR(Debug::MACROS, "Preview snippet: " << snippet);
preview_->addPreview(snippet, *buffer, forexport); preview_->addPreview(snippet, *buffer, forexport);
} }