#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())
}
}
- // Switch file encoding if necessary; no need to do this for "default"
+ // Switch file encoding if necessary; no need to do this for "auto-legacy-plain"
// encoding, since this only affects the position of the outputted
// \inputencoding command; the encoding switch will occur when necessary
- if (bparams.inputenc == "auto"
+ if (bparams.inputenc == "auto-legacy"
&& !runparams.isFullUnicode() // Xe/LuaTeX use one document-wide encoding (see also switchEncoding())
&& runparams.encoding->package() != Encoding::japanese
&& runparams.encoding->package() != Encoding::none) {
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)))) {
// Information about local language is stored as a font feature.
// If this is the last paragraph of the inset and a local_font was set upon entering
- // and we are mixing encodings ("auto" or "default" and no XeTeX or LuaTeX),
+ // and we are mixing encodings ("auto-legacy" or "auto-legacy-plain" and no XeTeX or LuaTeX),
// ensure the encoding is set back to the default encoding of the local language.
if (runparams.isLastPar && runparams_in.local_font != 0
&& runparams_in.encoding != runparams_in.local_font->language()->encoding()
- && (bparams.inputenc == "auto" || bparams.inputenc == "default")
+ && (bparams.inputenc == "auto-legacy" || bparams.inputenc == "auto-legacy-plain")
&& !runparams.isFullUnicode()
) {
runparams_in.encoding = runparams_in.local_font->language()->encoding();
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
return make_pair(false, 0);
// Only switch for auto-selected legacy encodings (inputenc setting
- // "auto" or "default").
+ // "auto-legacy" or "auto-legacy-plain").
// The "listings" environment can force a switch also with other
// encoding settings (it does not support variable width encodings
// (utf8, jis, ...) under 8-bit latex engines).
- if (!force && ((bparams.inputenc != "auto" && bparams.inputenc != "default")
+ if (!force && ((bparams.inputenc != "auto-legacy" && bparams.inputenc != "auto-legacy-plain")
|| runparams.moving_arg))
return make_pair(false, 0);
if (oldEnc.name() == newEnc.name()
|| oldEnc.package() == Encoding::japanese
|| oldEnc.package() == Encoding::none
- || newEnc.package() == Encoding::none)
+ || newEnc.package() == Encoding::none
+ || runparams.for_search)
return make_pair(false, 0);
// FIXME We ignore encoding switches from/to encodings that do
// neither support the inputenc package nor the CJK package here.
LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
<< oldEnc.name() << " to " << newEnc.name());
os << setEncoding(newEnc.iconvName());
- if (bparams.inputenc == "default")
+ if (bparams.inputenc == "auto-legacy-plain")
return make_pair(true, 0);
docstring const inputenc_arg(from_ascii(newEnc.latexName()));