}
-static void finishEnvironment(otexstream & os, OutputParams const & runparams,
- TeXEnvironmentData const & data)
+static void finishEnvironment(Buffer const & buf, Text const & text,
+ pit_type nextpit, otexstream & os,
+ OutputParams const & runparams,
+ TeXEnvironmentData const & data)
{
if (open_encoding_ == CJK && data.cjk_nested) {
// We need to close the encoding even if it does not change
os << setEncoding(data.prev_encoding->iconvName());
}
}
+
+ // Check whether we should output a blank line after the environment
+ DocumentClass const & tclass = buf.params().documentClass();
+ ParagraphList const & pars = text.paragraphs();
+ bool next_style_is_default = (nextpit >= runparams.par_end) ? false
+ : tclass.isDefaultLayout(pars.constIterator(nextpit)->layout());
+ if (!data.style->nextnoindent && next_style_is_default)
+ os << '\n';
}
prepareEnvironment(buf, text, par, os, runparams);
// Recursive call to TeXEnvironment!
TeXEnvironment(buf, text, runparams, pit, os);
- finishEnvironment(os, runparams, data);
+ finishEnvironment(buf, text, pit + 1, os, runparams, data);
}
if (pit != runparams.par_end)
bool const useSetSpace = bparams.documentClass().provides("SetSpace");
if (par.allowParagraphCustomization()) {
if (par.params().startOfAppendix()) {
- os << "\\appendix\n";
+ os << "\n\\appendix\n";
}
if (!par.params().spacing().isDefault()
// but whose alignment is unchanged, or (case 3) the
// paragraph is a command not followed by an environment
// and the alignment of the current and next paragraph
- // is unchanged.
+ // is unchanged, or (case 4) the current alignment is
+ // changed and a standard paragraph follows.
+ DocumentClass const & tclass = bparams.documentClass();
if ((style == next_layout
&& !style.parbreak_is_newline
&& style.latextype != LATEX_ITEM_ENVIRONMENT
|| (style.isCommand()
&& !next_layout.isEnvironment()
&& style.align == par.getAlign()
- && next_layout.align == nextpar->getAlign())) {
+ && next_layout.align == nextpar->getAlign())
+ || (style.align != par.getAlign()
+ && tclass.isDefaultLayout(next_layout))) {
os << '\n';
}
}
prepareEnvironment(buf, text, par, os, runparams);
// pit can be changed in TeXEnvironment.
TeXEnvironment(buf, text, runparams, pit, os);
- finishEnvironment(os, runparams, data);
+ finishEnvironment(buf, text, pit + 1, os, runparams, data);
}
if (pit == runparams.par_end) {