mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
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:
parent
e832d2e90f
commit
696ea82b21
@ -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
|
||||
|
||||
|
||||
@ -1029,14 +1060,7 @@ void InsetMathHull::header_write(WriteStream & os) const
|
||||
break;
|
||||
|
||||
case hullEquation:
|
||||
if (os.strikeoutMath()) {
|
||||
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}{";
|
||||
writeMathdisplayPreamble(os);
|
||||
os << "\n";
|
||||
os.startOuterRow();
|
||||
if (n)
|
||||
@ -1050,14 +1074,7 @@ void InsetMathHull::header_write(WriteStream & os) const
|
||||
case hullFlAlign:
|
||||
case hullGather:
|
||||
case hullMultline:
|
||||
if (os.strikeoutMath()) {
|
||||
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}{";
|
||||
writeMathdisplayPreamble(os);
|
||||
os << "\n";
|
||||
os.startOuterRow();
|
||||
os << "\\begin{" << hullName(type_) << star(n) << "}\n";
|
||||
@ -1113,14 +1130,7 @@ void InsetMathHull::footer_write(WriteStream & os) const
|
||||
os << "\\end{equation" << star(n) << "}\n";
|
||||
else
|
||||
os << "\\]\n";
|
||||
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";
|
||||
writeMathdisplayPostamble(os);
|
||||
break;
|
||||
|
||||
case hullEqnArray:
|
||||
@ -1131,14 +1141,7 @@ void InsetMathHull::footer_write(WriteStream & os) const
|
||||
os << "\n";
|
||||
os.startOuterRow();
|
||||
os << "\\end{" << hullName(type_) << star(n) << "}\n";
|
||||
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";
|
||||
writeMathdisplayPostamble(os);
|
||||
break;
|
||||
|
||||
case hullAlignAt:
|
||||
|
Loading…
Reference in New Issue
Block a user