summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a42f7ea)
This patch simplifies and fixes the generation of previews with
numbering. Instead of saving the counter values (which is complicated
and error prone), the \thequation macro is set to the numbers_ string
which has been computed by updateBuffer for screen display.
Harcoding the number in the formula means that two equations with
different numbers have different previews, which is the subject of the
bug.
The special code for saving counters in updateBuffer and outputing
them in preparePreview from
645f9fdf (ticket #6894) is removed and
replaced by this simpler approach.
This fixes ticket #11535.
Counters & cnts =
buffer_->masterBuffer()->params().documentClass().counters();
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)) {
// 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();
for (size_t i = 0; i != label_.size(); ++i) {
if (numbered(i)) {
Paragraph const & par = it.paragraph();
if (lsize != "normalsize" && !prefixIs(lsize, "error"))
setfont += from_ascii("\\" + lsize + '\n');
if (lsize != "normalsize" && !prefixIs(lsize, "error"))
setfont += from_ascii("\\" + lsize + '\n');
- 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<docstring>(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<docstring>(num) + '}';
- }
- }
- docstring const snippet = macro_preamble + setfont + setcnt
- + latexString(*this) + endfont;
+ docstring const snippet = macro_preamble + setfont + latexString(*this) + endfont;
LYXERR(Debug::MACROS, "Preview snippet: " << snippet);
preview_->addPreview(snippet, *buffer, forexport);
}
LYXERR(Debug::MACROS, "Preview snippet: " << snippet);
preview_->addPreview(snippet, *buffer, forexport);
}
else if (numbered_[row] == NOTAG)
os<< "\\notag ";
}
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;
}
// Never add \\ on the last empty line of eqnarray and friends
last_eoln = false;
unique_ptr<RenderPreview> preview_;
///
DocIterator docit_;
unique_ptr<RenderPreview> preview_;
///
DocIterator docit_;
- ///
- typedef std::map<docstring, int> CounterMap;
- /// used to store current values of important counters
- CounterMap counter_map;