From 7261fa94482916cb9bf2ba0d21c4df390ea58320 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 26 Jul 2022 00:45:57 +0200 Subject: [PATCH] Revert "Reimplement support for numbering of equation previews" This reverts commit f4da29306fc8acc0cca2ac6fe36f7dfcb58c2563. --- src/mathed/InsetMathHull.cpp | 39 +++++++++++++++++++++++++++++++----- src/mathed/InsetMathHull.h | 4 ++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 8ea552dd29..8ede260632 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -253,9 +253,20 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype, bool Counters & cnts = buffer_->masterBuffer()->params().documentClass().counters(); + // right now, we only need to do this at export time + if (utype == OutputUpdate) { + for (size_t i = 0; i < numcnts; ++i) { + docstring const cnt = from_ascii(counters_to_save[i]); + if (cnts.hasCounter(cnt)) + counter_map[cnt] = cnts.value(cnt); + } + } + // this has to be done separately docstring const eqstr = from_ascii("equation"); if (cnts.hasCounter(eqstr)) { + if (utype == OutputUpdate) + counter_map[eqstr] = cnts.value(eqstr); for (size_t i = 0; i != label_.size(); ++i) { if (numbered(i)) { Paragraph const & par = it.paragraph(); @@ -826,7 +837,29 @@ 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 setcnt; + if (forexport && haveNumbers()) { + docstring eqstr = from_ascii("equation"); + CounterMap::const_iterator it = counter_map.find(eqstr); + if (it != counter_map.end()) { + int num = it->second; + if (num >= 0) + setcnt += from_ascii("\\setcounter{") + eqstr + '}' + + '{' + convert(num) + '}' + '\n'; + } + for (size_t i = 0; i != numcnts; ++i) { + docstring cnt = from_ascii(counters_to_save[i]); + it = counter_map.find(cnt); + if (it == counter_map.end()) + continue; + int num = it->second; + if (num > 0) + setcnt += from_ascii("\\setcounter{") + cnt + '}' + + '{' + convert(num) + '}'; + } + } + docstring const snippet = macro_preamble + setfont + setcnt + + latexString(*this) + endfont; LYXERR(Debug::MACROS, "Preview snippet: " << snippet); preview_->addPreview(snippet, *buffer, forexport); } @@ -1663,10 +1696,6 @@ void InsetMathHull::eol(TeXMathStream & os, row_type row, bool fragile, bool lat else if (numbered_[row] == NOTAG) os<< "\\notag "; } - if (os.output() == TeXMathStream::wsPreview && !numbers_[row].empty()) { - os << "\\global\\def\\theequation{" << numbers_[row] << "}\n"; - } - } // Never add \\ on the last empty line of eqnarray and friends last_eoln = false; diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 92903c5e42..52e8177631 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -270,6 +270,10 @@ private: unique_ptr preview_; /// DocIterator docit_; + /// + typedef std::map CounterMap; + /// used to store current values of important counters + CounterMap counter_map; // // Incorporate me // -- 2.39.5