#include "output_latex.h"
+#include "BiblioInfo.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "Encoding.h"
// in multilingual environments, the CJK tags have to be nested properly
data.cjk_nested = false;
- if (data.par_language->encoding()->package() == Encoding::CJK &&
- state->open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
+ if (!bparams.useNonTeXFonts
+ && (bparams.inputenc == "auto-legacy"
+ || bparams.inputenc == "auto-legacy-plain")
+ && data.par_language->encoding()->package() == Encoding::CJK
+ && state->open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
if (prev_par_language->encoding()->package() == Encoding::CJK) {
os << "\\begin{CJK}{"
<< from_ascii(data.par_language->encoding()->latexName())
OutputParams runparams = runparams_in;
runparams.isLastPar = (pit == pit_type(paragraphs.size() - 1));
- // We reinitialze par begin and end to be on the safe side
+ // We reinitialize par begin and end to be on the safe side
// with embedded inset as we don't know if they set those
// value correctly.
runparams.par_begin = 0;
if (runparams.encoding->package() == Encoding::CJK
&& par_lang != openLanguageName(state)
&& !par_lang.empty()) {
- string bc = use_polyglossia ?
- getPolyglossiaBegin(lang_begin_command, par_lang,
- par_language->polyglossiaOpts(),
- localswitch)
- : subst(lang_begin_command, "$$lang", par_lang);
- os << bc
+ os << subst(lang_begin_command, "$$lang", par_lang)
<< lang_command_termination;
if (using_begin_end)
pushLanguageName(par_lang, localswitch);
if (localswitch_needed
|| (intitle_command && using_begin_end)
|| closing_rtl_ltr_environment
- || ((runparams.isLastPar || close_lang_switch)
+ || (((runparams.isLastPar && !runparams.inbranch) || close_lang_switch)
&& (par_lang != outer_lang || (using_begin_end
&& style.isEnvironment()
&& par_lang != nextpar_lang)))) {
break;
}
case inputenc: {
+ // FIXME: If we are in an inset and the switch happened outside this inset,
+ // do not switch back at the end of the inset (bug #8479)
+ // The following attempt does not help with listings-caption in a CJK document:
+ // if (runparams_in.local_font != 0
+ // && runparams_in.encoding == runparams_in.local_font->language()->encoding())
+ // break;
os << "\\egroup";
state->open_encoding_ = none;
break;
if (multibib_child && mparams.useBiblatex())
os << "\\newrefsection";
- else if (multibib_child && mparams.useBibtopic()) {
+ else if (multibib_child && mparams.useBibtopic()
+ && !buf.masterBibInfo().empty()) {
os << "\\begin{btUnit}\n";
runparams.openbtUnit = true;
}
&& layout.latexname() == bparams.multibib) {
if (runparams.openbtUnit)
os << "\\end{btUnit}\n";
- if (!bparams.useBiblatex()) {
+ if (!bparams.useBiblatex()
+ && !buf.masterBibInfo().empty()) {
os << '\n' << "\\begin{btUnit}\n";
runparams.openbtUnit = true;
}
state->open_encoding_ = none;
}
// Likewise for polyglossia or when using begin/end commands
+ // or after an active branch inset with a language switch
+ Language const * const outer_language = (runparams.local_font != 0)
+ ? runparams.local_font->language() : bparams.language;
+ string const & prev_lang = runparams.use_polyglossia
+ ? getPolyglossiaEnvName(outer_language)
+ : outer_language->babel();
string const & cur_lang = openLanguageName(state);
- if (maintext && !is_child && !cur_lang.empty()) {
+ if (((runparams.inbranch && langOpenedAtThisLevel(state) && prev_lang != cur_lang)
+ || (maintext && !is_child)) && !cur_lang.empty()) {
os << from_utf8(subst(lang_end_command,
"$$lang",
cur_lang))
<< '\n';
if (using_begin_end)
popLanguageName();
+ } else if (runparams.inbranch && !using_begin_end && prev_lang != cur_lang) {
+ os << subst(lang_begin_command, "$$lang", prev_lang) << '\n';
}
// reset inherited encoding