Fix issue with change-tracked deleted display math

- If a display math not starting a new paragraph is deleted, the
  current \lyxdeleted macro (if any) must be closed and a new one
  started, otherwise the display math will be shifted up.

- Use \linewidth instead of \columnwidth because the former will adapt
  to the reduced horizontal width in list environments, avoiding shifting
  to the right the diplay math.
This commit is contained in:
Enrico Forestieri 2017-10-22 13:12:33 +02:00
parent e5d4ba8529
commit 7f23ca912c
3 changed files with 35 additions and 13 deletions

View File

@ -394,11 +394,16 @@ int Changes::latexMarkChange(otexstream & os, BufferParams const & bparams,
int column = 0;
bool const dvipost = LaTeXFeatures::isAvailable("dvipost") &&
(runparams.flavor == OutputParams::LATEX
|| runparams.flavor == OutputParams::DVILUATEX);
if (oldChange.type != Change::UNCHANGED) {
// close \lyxadded or \lyxdeleted
os << '}';
column++;
if (oldChange.type == Change::DELETED && !runparams.wasDisplayMath)
if (oldChange.type == Change::DELETED
&& !runparams.wasDisplayMath && !dvipost)
--runparams.inulemcmd;
}
@ -410,7 +415,7 @@ int Changes::latexMarkChange(otexstream & os, BufferParams const & bparams,
docstring macro_beg;
if (change.type == Change::DELETED) {
macro_beg = from_ascii("\\lyxdeleted{");
if (!runparams.inDisplayMath)
if (!runparams.inDisplayMath && !dvipost)
++runparams.inulemcmd;
}
else if (change.type == Change::INSERTED)
@ -422,9 +427,7 @@ int Changes::latexMarkChange(otexstream & os, BufferParams const & bparams,
// signature needed by \lyxsout to correctly strike out display math
if (change.type == Change::DELETED && runparams.inDisplayMath
&& (!LaTeXFeatures::isAvailable("dvipost")
|| (runparams.flavor != OutputParams::LATEX
&& runparams.flavor != OutputParams::DVILUATEX))) {
&& !dvipost) {
if (os.afterParbreak())
str += from_ascii("\\\\\\noindent\n");
else

View File

@ -2454,6 +2454,8 @@ void Paragraph::latex(BufferParams const & bparams,
runparams.wasDisplayMath = runparams.inDisplayMath;
runparams.inDisplayMath = false;
bool deleted_display_math = false;
Change const & change = runparams.inDeletedInset
? runparams.changeOfDeletedInset : lookupChange(i);
// Check whether a display math inset follows
if (d->text_[i] == META_INSET
@ -2468,11 +2470,28 @@ void Paragraph::latex(BufferParams const & bparams,
// cannot set it here because it is a counter.
deleted_display_math = isDeleted(i);
}
if (bparams.output_changes && deleted_display_math
&& runningChange == change
&& change.type == Change::DELETED
&& !os.afterParbreak()) {
// A display math in the same paragraph follows.
// We have to close and then reopen \lyxdeleted,
// otherwise the math will be shifted up.
OutputParams rp = runparams;
if (open_font) {
bool needPar = false;
column += running_font.latexWriteEndChanges(
os, bparams, rp, basefont,
basefont, needPar);
open_font = false;
}
basefont = getLayoutFont(bparams, outerfont);
running_font = basefont;
column += Changes::latexMarkChange(os, bparams,
Change(Change::INSERTED), change, rp);
}
}
Change const & change = runparams.inDeletedInset
? runparams.changeOfDeletedInset : lookupChange(i);
if (bparams.output_changes && runningChange != change) {
if (open_font) {
bool needPar = false;
@ -2549,7 +2568,7 @@ void Paragraph::latex(BufferParams const & bparams,
char_type const c = d->text_[i];
// A display math inset inside an ulem command will be output
// as a box of width \columnwidth, so we have to either disable
// as a box of width \linewidth, so we have to either disable
// indentation if the inset starts a paragraph, or start a new
// line to accommodate such box. This has to be done before
// writing any font changing commands.

View File

@ -126,14 +126,14 @@ namespace {
if (os.strikeoutMath()) {
if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{-\\belowdisplayshortskip}{"
"\\lyxmathsout{\\parbox[b]{\\columnwidth}{";
"\\lyxmathsout{\\parbox[b]{\\linewidth}{";
else
os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
os << "\\lyxmathsout{\\parbox{\\linewidth}{";
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{-\\belowdisplayshortskip}{"
"\\parbox[b]{\\columnwidth}{";
"\\parbox[b]{\\linewidth}{";
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
os << "\\parbox{\\columnwidth}{";
os << "\\parbox{\\linewidth}{";
}