Factor out common code used to underline/strike out math

Also use the exact amount of vertical space TeX adds after a
math display (instead of 1ex) for vertically shifting the box.
We have to use \belowdisplayshortskip here, instead of
\belowdisplayskip, because the math formula is typeset by alone
in a box, and thus there is no following line.
This commit is contained in:
Enrico Forestieri 2016-10-25 00:49:26 +02:00
parent e832d2e90f
commit 696ea82b21

View File

@ -121,6 +121,37 @@ namespace {
} }
// writes a preamble for underlined or struck out math display
void writeMathdisplayPreamble(WriteStream & os)
{
if (os.strikeoutMath()) {
if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{-\\belowdisplayshortskip}{"
"\\lyxmathsout{\\parbox[b]{\\columnwidth}{";
else
os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{-\\belowdisplayshortskip}{"
"\\parbox[b]{\\columnwidth}{";
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
os << "\\parbox{\\columnwidth}{";
}
// writes a postamble for underlined or struck out math display
void writeMathdisplayPostamble(WriteStream & os)
{
if (os.strikeoutMath()) {
if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "}";
os << "}}\\\\\n";
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "}}\\\\\n";
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
os << "}\\\\\n";
}
} // end anon namespace } // end anon namespace
@ -1029,14 +1060,7 @@ void InsetMathHull::header_write(WriteStream & os) const
break; break;
case hullEquation: case hullEquation:
if (os.strikeoutMath()) { writeMathdisplayPreamble(os);
if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{1ex}{";
os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
os << "\\parbox{\\columnwidth}{";
os << "\n"; os << "\n";
os.startOuterRow(); os.startOuterRow();
if (n) if (n)
@ -1050,14 +1074,7 @@ void InsetMathHull::header_write(WriteStream & os) const
case hullFlAlign: case hullFlAlign:
case hullGather: case hullGather:
case hullMultline: case hullMultline:
if (os.strikeoutMath()) { writeMathdisplayPreamble(os);
if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{1ex}{";
os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
os << "\\parbox{\\columnwidth}{";
os << "\n"; os << "\n";
os.startOuterRow(); os.startOuterRow();
os << "\\begin{" << hullName(type_) << star(n) << "}\n"; os << "\\begin{" << hullName(type_) << star(n) << "}\n";
@ -1113,14 +1130,7 @@ void InsetMathHull::footer_write(WriteStream & os) const
os << "\\end{equation" << star(n) << "}\n"; os << "\\end{equation" << star(n) << "}\n";
else else
os << "\\]\n"; os << "\\]\n";
if (os.strikeoutMath()) { writeMathdisplayPostamble(os);
if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "}";
os << "}}\\\\\n";
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "}}\\\\\n";
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
os << "}\\\\\n";
break; break;
case hullEqnArray: case hullEqnArray:
@ -1131,14 +1141,7 @@ void InsetMathHull::footer_write(WriteStream & os) const
os << "\n"; os << "\n";
os.startOuterRow(); os.startOuterRow();
os << "\\end{" << hullName(type_) << star(n) << "}\n"; os << "\\end{" << hullName(type_) << star(n) << "}\n";
if (os.strikeoutMath()) { writeMathdisplayPostamble(os);
if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "}";
os << "}}\\\\\n";
} else if (os.ulemCmd() == WriteStream::UNDERLINE)
os << "}}\\\\\n";
else if (os.ulemCmd() == WriteStream::STRIKEOUT)
os << "}\\\\\n";
break; break;
case hullAlignAt: case hullAlignAt: