static void finishEnvironment(otexstream & os, OutputParams const & runparams,
- TeXEnvironmentData const & data)
+ 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
+ if (!data.style->nextnoindent)
+ os << '\n';
}
if (argnr == 0)
return;
+ // Default and preset args are always output, so if they require
+ // other arguments, consider this.
+ Layout::LaTeXArgMap::const_iterator lit = latexargs.begin();
+ Layout::LaTeXArgMap::const_iterator const lend = latexargs.end();
+ for (; lit != lend; ++lit) {
+ Layout::latexarg arg = (*lit).second;
+ if ((!arg.presetarg.empty() || !arg.defaultarg.empty()) && !arg.requires.empty()) {
+ vector<string> req = getVectorFromString(arg.requires);
+ required.insert(required.end(), req.begin(), req.end());
+ }
+ }
+
for (unsigned int i = 1; i <= argnr; ++i) {
map<int, InsetArgument const *>::const_iterator lit = ilist.find(i);
bool inserted = false;
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()
switch (style.latextype) {
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
- if (nextpar
- && (par.params().depth() < nextpar->params().depth())
- && !par.isEnvSeparator(par.size() - 1))
+ if (nextpar && par.params().depth() < nextpar->params().depth())
pending_newline = true;
break;
case LATEX_ENVIRONMENT: {
// fall through possible
default:
// we don't need it for the last paragraph!!!
- // or if the last thing is an environment separator
- if (nextpar && !par.isEnvSeparator(par.size() - 1))
+ if (nextpar)
pending_newline = true;
}
if (closing_rtl_ltr_environment)
os << "}";
+ bool const last_was_separator =
+ par.size() > 0 && par.isEnvSeparator(par.size() - 1);
+
if (pending_newline) {
if (unskip_newline)
// prevent unwanted whitespace
os << '%';
- os << '\n';
+ if (!os.afterParbreak() && !last_was_separator)
+ os << '\n';
}
// if this is a CJK-paragraph and the next isn't, close CJK
// we don't need a newline for the last paragraph!!!
// Note from JMarc: we will re-add a \n explicitly in
// TeXEnvironment, because it is needed in this case
- if (nextpar && !par.isEnvSeparator(par.size() - 1)) {
+ if (nextpar && !os.afterParbreak() && !last_was_separator) {
// Make sure to start a new line
os << breakln;
Layout const & next_layout = nextpar->layout();
// unchanged, or (case 2) the following is a
// non-environment paragraph whose depth is increased
// but whose alignment is unchanged, or (case 3) the
+ // paragraph is not an environment and the next one is a
+ // non-itemize-like env at lower depth, or (case 4) 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 5) 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
|| (!next_layout.isEnvironment()
&& nextpar->getDepth() > par.getDepth()
&& nextpar->getAlign() == par.getAlign())
+ || (!style.isEnvironment()
+ && next_layout.latextype == LATEX_ENVIRONMENT
+ && nextpar->getDepth() < par.getDepth())
|| (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';
}
}