mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
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:
parent
e5d4ba8529
commit
7f23ca912c
@ -394,11 +394,16 @@ int Changes::latexMarkChange(otexstream & os, BufferParams const & bparams,
|
|||||||
|
|
||||||
int column = 0;
|
int column = 0;
|
||||||
|
|
||||||
|
bool const dvipost = LaTeXFeatures::isAvailable("dvipost") &&
|
||||||
|
(runparams.flavor == OutputParams::LATEX
|
||||||
|
|| runparams.flavor == OutputParams::DVILUATEX);
|
||||||
|
|
||||||
if (oldChange.type != Change::UNCHANGED) {
|
if (oldChange.type != Change::UNCHANGED) {
|
||||||
// close \lyxadded or \lyxdeleted
|
// close \lyxadded or \lyxdeleted
|
||||||
os << '}';
|
os << '}';
|
||||||
column++;
|
column++;
|
||||||
if (oldChange.type == Change::DELETED && !runparams.wasDisplayMath)
|
if (oldChange.type == Change::DELETED
|
||||||
|
&& !runparams.wasDisplayMath && !dvipost)
|
||||||
--runparams.inulemcmd;
|
--runparams.inulemcmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +415,7 @@ int Changes::latexMarkChange(otexstream & os, BufferParams const & bparams,
|
|||||||
docstring macro_beg;
|
docstring macro_beg;
|
||||||
if (change.type == Change::DELETED) {
|
if (change.type == Change::DELETED) {
|
||||||
macro_beg = from_ascii("\\lyxdeleted{");
|
macro_beg = from_ascii("\\lyxdeleted{");
|
||||||
if (!runparams.inDisplayMath)
|
if (!runparams.inDisplayMath && !dvipost)
|
||||||
++runparams.inulemcmd;
|
++runparams.inulemcmd;
|
||||||
}
|
}
|
||||||
else if (change.type == Change::INSERTED)
|
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
|
// signature needed by \lyxsout to correctly strike out display math
|
||||||
if (change.type == Change::DELETED && runparams.inDisplayMath
|
if (change.type == Change::DELETED && runparams.inDisplayMath
|
||||||
&& (!LaTeXFeatures::isAvailable("dvipost")
|
&& !dvipost) {
|
||||||
|| (runparams.flavor != OutputParams::LATEX
|
|
||||||
&& runparams.flavor != OutputParams::DVILUATEX))) {
|
|
||||||
if (os.afterParbreak())
|
if (os.afterParbreak())
|
||||||
str += from_ascii("\\\\\\noindent\n");
|
str += from_ascii("\\\\\\noindent\n");
|
||||||
else
|
else
|
||||||
|
@ -2454,6 +2454,8 @@ void Paragraph::latex(BufferParams const & bparams,
|
|||||||
runparams.wasDisplayMath = runparams.inDisplayMath;
|
runparams.wasDisplayMath = runparams.inDisplayMath;
|
||||||
runparams.inDisplayMath = false;
|
runparams.inDisplayMath = false;
|
||||||
bool deleted_display_math = false;
|
bool deleted_display_math = false;
|
||||||
|
Change const & change = runparams.inDeletedInset
|
||||||
|
? runparams.changeOfDeletedInset : lookupChange(i);
|
||||||
|
|
||||||
// Check whether a display math inset follows
|
// Check whether a display math inset follows
|
||||||
if (d->text_[i] == META_INSET
|
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.
|
// cannot set it here because it is a counter.
|
||||||
deleted_display_math = isDeleted(i);
|
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 (bparams.output_changes && runningChange != change) {
|
||||||
if (open_font) {
|
if (open_font) {
|
||||||
bool needPar = false;
|
bool needPar = false;
|
||||||
@ -2549,7 +2568,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
|||||||
char_type const c = d->text_[i];
|
char_type const c = d->text_[i];
|
||||||
|
|
||||||
// A display math inset inside an ulem command will be output
|
// 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
|
// indentation if the inset starts a paragraph, or start a new
|
||||||
// line to accommodate such box. This has to be done before
|
// line to accommodate such box. This has to be done before
|
||||||
// writing any font changing commands.
|
// writing any font changing commands.
|
||||||
|
@ -126,14 +126,14 @@ namespace {
|
|||||||
if (os.strikeoutMath()) {
|
if (os.strikeoutMath()) {
|
||||||
if (os.ulemCmd() == WriteStream::UNDERLINE)
|
if (os.ulemCmd() == WriteStream::UNDERLINE)
|
||||||
os << "\\raisebox{-\\belowdisplayshortskip}{"
|
os << "\\raisebox{-\\belowdisplayshortskip}{"
|
||||||
"\\lyxmathsout{\\parbox[b]{\\columnwidth}{";
|
"\\lyxmathsout{\\parbox[b]{\\linewidth}{";
|
||||||
else
|
else
|
||||||
os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
|
os << "\\lyxmathsout{\\parbox{\\linewidth}{";
|
||||||
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
|
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
|
||||||
os << "\\raisebox{-\\belowdisplayshortskip}{"
|
os << "\\raisebox{-\\belowdisplayshortskip}{"
|
||||||
"\\parbox[b]{\\columnwidth}{";
|
"\\parbox[b]{\\linewidth}{";
|
||||||
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
|
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
|
||||||
os << "\\parbox{\\columnwidth}{";
|
os << "\\parbox{\\linewidth}{";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user