When setting halfline parskip with parskip provided, we still need
to set this explicitly, as we don't know the current \parskip value.

Also improve code readability.
This commit is contained in:
Juergen Spitzmueller 2023-10-30 12:17:14 +01:00
parent 9de9ec1e88
commit 6c5dc39cd5

View File

@ -2153,6 +2153,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
if (paragraph_separation) { if (paragraph_separation) {
// when skip separation // when skip separation
string psopt; string psopt;
bool default_skip = false;
switch (getDefSkip().kind()) { switch (getDefSkip().kind()) {
case VSpace::SMALLSKIP: case VSpace::SMALLSKIP:
psopt = "\\smallskipamount"; psopt = "\\smallskipamount";
@ -2165,6 +2166,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
break; break;
case VSpace::HALFLINE: case VSpace::HALFLINE:
// default (no option) // default (no option)
default_skip = true;
break; break;
case VSpace::FULLLINE: case VSpace::FULLLINE:
psopt = "\\baselineskip"; psopt = "\\baselineskip";
@ -2175,12 +2177,20 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
default: default:
break; break;
} }
if (!features.isProvided("parskip")) { if (features.isProvided("parskip")) {
// package already loaded (with arbitrary options)
// change parskip value only
if (!psopt.empty())
os << "\\setlength{\\parskip}{" + psopt + "}\n";
else if (default_skip)
// explicitly reset default (might have been changed
// in a class or package)
os << "\\parskip=.5\\baselineskip plus 2pt\\relax\n";
} else {
// load parskip package with required option
if (!psopt.empty()) if (!psopt.empty())
psopt = "[skip=" + psopt + "]"; psopt = "[skip=" + psopt + "]";
os << "\\usepackage" + psopt + "{parskip}\n"; os << "\\usepackage" + psopt + "{parskip}\n";
} else if (!psopt.empty()) {
os << "\\setlength{\\parskip}{" + psopt + "}\n";
} }
} else { } else {
// when separation by indentation // when separation by indentation