BufferParams const & bparams = buf.params();
Layout const & style = pit->forcePlainLayout() ?
- bparams.documentClass().emptyLayout() : pit->layout();
+ bparams.documentClass().plainLayout() : pit->layout();
ParagraphList const & paragraphs = text.paragraphs();
if (nextpit != paragraphs.end())
++nextpit;
- if (runparams_in.verbatim) {
+ OutputParams runparams = runparams_in;
+ runparams.isLastPar = nextpit == paragraphs.end();
+
+ if (runparams.verbatim) {
int const dist = distance(paragraphs.begin(), pit);
Font const outerfont = outerFont(dist, paragraphs);
}
/*bool need_par = */ pit->latex(bparams, outerfont,
- os, texrow, runparams_in);
+ os, texrow, runparams);
return nextpit;
}
Layout const style = pit->forcePlainLayout() ?
- bparams.documentClass().emptyLayout() : pit->layout();
+ bparams.documentClass().plainLayout() : pit->layout();
- OutputParams runparams = runparams_in;
runparams.moving_arg |= style.needprotect;
bool const maintext = text.isMainText(buf);
Language const * const par_language = pit->getParLanguage(bparams);
// The document's language
Language const * const doc_language = bparams.language;
- // The language that was in effect when the environment this paragraph is
+ // The language that was in effect when the environment this paragraph is
// inside of was opened
- Language const * const outer_language =
+ Language const * const outer_language =
(runparams.local_font != 0) ?
runparams.local_font->language() : doc_language;
// The previous language that was in effect is either the language of
texrow.newline();
}
- // We need to open a new language if we couldn't close the previous
+ // We need to open a new language if we couldn't close the previous
// one (because there's no language_command_end); and even if we closed
// the previous one, if the current language is different than the
// outer_language (which is currently in effect once the previous one
// are we in an inset?
runparams.local_font != 0 &&
// is the inset within an \L or \R?
- //
+ //
// FIXME: currently, we don't check this; this means that
- // we'll have unnnecessary \L and \R commands, but that
+ // we'll have unnnecessary \L and \R commands, but that
// doesn't seem to hurt (though latex will complain)
- //
+ //
// is this paragraph in the opposite direction?
runparams.local_font->isRightToLeft() !=
par_language->rightToLeft()
// Closing the language is needed for the last paragraph; it is also
// needed if we're within an \L or \R that we may have opened above (not
// necessarily in this paragraph) and are about to close.
- bool closing_rtl_ltr_environment =
+ bool closing_rtl_ltr_environment =
// not for ArabTeX
(par_language->lang() != "arabic_arabtex" &&
outer_language->lang() != "arabic_arabtex") &&
runparams.local_font->isRightToLeft() != par_language->rightToLeft() &&
// are we about to close the language?
((nextpit != paragraphs.end() &&
- par_language->babel() !=
+ par_language->babel() !=
(nextpit->getParLanguage(bparams))->babel()) ||
(nextpit == paragraphs.end() &&
par_language->babel() != outer_language->babel()));
if (nextpit == paragraphs.end() && !style.isEnvironment()) {
switch (open_encoding_) {
case CJK: {
+ // do nothing at the end of child documents
+ if (maintext && buf.masterBuffer() != &buf)
+ break;
// end of main text
if (maintext) {
os << '\n';
}
bool const maintext = text.isMainText(buf);
+ bool const is_child = buf.masterBuffer() != &buf;
// Open a CJK environment at the beginning of the main buffer
// if the document's language is a CJK language
- if (maintext && bparams.encoding().package() == Encoding::CJK) {
+ // (but not in child documents)
+ if (maintext && !is_child
+ && bparams.encoding().package() == Encoding::CJK) {
os << "\\begin{CJK}{" << from_ascii(bparams.encoding().latexName())
<< "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
texrow.newline();
while (par != endpar) {
lastpar = par;
Layout const & layout = par->forcePlainLayout() ?
- tclass.emptyLayout() :
+ tclass.plainLayout() :
par->layout();
if (layout.intitle) {
// If the last paragraph is an environment, we'll have to close
// CJK at the very end to do proper nesting.
- if (maintext && open_encoding_ == CJK) {
+ if (maintext && !is_child && open_encoding_ == CJK) {
os << "\\end{CJK}\n";
texrow.newline();
open_encoding_ = none;
pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
- OutputParams const & runparams, Encoding const & newEnc)
+ OutputParams const & runparams, Encoding const & newEnc,
+ bool force)
{
- Encoding const oldEnc = *runparams.encoding;
+ Encoding const & oldEnc = *runparams.encoding;
bool moving_arg = runparams.moving_arg;
- if ((bparams.inputenc != "auto" && bparams.inputenc != "default")
- || moving_arg)
+ if (!force && ((bparams.inputenc != "auto" && bparams.inputenc != "default")
+ || moving_arg))
return make_pair(false, 0);
// Do nothing if the encoding is unchanged.
docstring const inputenc_arg(from_ascii(newEnc.latexName()));
switch (newEnc.package()) {
case Encoding::none:
+ case Encoding::japanese:
// shouldn't ever reach here, see above
return make_pair(true, 0);
case Encoding::inputenc: {
open_encoding_ = none;
count += 7;
}
- if (runparams.local_font != 0 && oldEnc.package() == Encoding::CJK) {
- // within insets, \inputenc switches need to be
- // embraced within \bgroup ... \egroup; else CJK fails.
+ if (runparams.local_font != 0
+ && oldEnc.package() == Encoding::CJK) {
+ // within insets, \inputenc switches need
+ // to be embraced within \bgroup...\egroup;
+ // else CJK fails.
os << "\\bgroup";
count += 7;
open_encoding_ = inputenc;
}
+ // with the japanese option, inputenc is omitted.
+ if (runparams.use_japanese)
+ return make_pair(true, count);
os << "\\inputencoding{" << inputenc_arg << '}';
return make_pair(true, count + 16);
}
case Encoding::CJK: {
int count = inputenc_arg.length();
- if (oldEnc.package() == Encoding::CJK &&
+ if (oldEnc.package() == Encoding::CJK &&
open_encoding_ == CJK) {
os << "\\end{CJK}";
count += 9;
}
- if (oldEnc.package() == Encoding::inputenc &&
+ if (oldEnc.package() == Encoding::inputenc &&
open_encoding_ == inputenc) {
os << "\\egroup";
count += 7;