if (data.par_language->encoding()->package() == Encoding::CJK &&
state->open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
if (prev_par_language->encoding()->package() == Encoding::CJK) {
- docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk"
- && LaTeXFeatures::isAvailable("CJKutf8")) ?
- from_ascii("UTF8")
- : from_ascii(data.par_language->encoding()->latexName());
- os << "\\begin{CJK}{" << cjkenc
+ os << "\\begin{CJK}{"
+ << from_ascii(data.par_language->encoding()->latexName())
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
}
state->open_encoding_ = CJK;
}
}
}
+ if (runparams.for_search) {
+ // Mark end of arguments for findadv() only
+ os << "\\endarguments{}";
+ }
}
os << " ";
}
break;
+ case LATEX_ENVIRONMENT:
+ if (runparams.for_search) {
+ os << "\\latexenvironment{" << style.latexname() << "}{";
+ }
+ break;
case LATEX_BIB_ENVIRONMENT:
// ignore this, the inset will write itself
break;
lang_end_command = "}";
lang_command_termination.clear();
}
-
+
bool const localswitch_needed = localswitch && par_lang != outer_lang;
// localswitches need to be closed and reopened at each par
if (!localswitch
&& (!using_begin_end || langOpenedAtThisLevel(state))
&& !lang_end_command.empty()
- && prev_lang != outer_lang
+ && prev_lang != outer_lang
&& !prev_lang.empty()
&& (!using_begin_end || !style.isEnvironment())) {
os << from_ascii(subst(lang_end_command,
// context (nesting issue).
if (par_language->encoding()->package() == Encoding::CJK
&& state->open_encoding_ != CJK && state->cjk_inherited_ == 0) {
- docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk"
- && LaTeXFeatures::isAvailable("CJKutf8")) ?
- from_ascii("UTF8")
- : from_ascii(par_language->encoding()->latexName());
- os << "\\begin{CJK}{" << cjkenc
+ os << "\\begin{CJK}{"
+ << from_ascii(par_language->encoding()->latexName())
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
state->open_encoding_ = CJK;
}
}
runparams.moving_arg |= style.needprotect;
+ if (style.needmboxprotect)
+ ++runparams.inulemcmd;
Encoding const * const prev_encoding = runparams.encoding;
bool const useSetSpace = bparams.documentClass().provides("SetSpace");
// if this is a CJK-paragraph and the next isn't, close CJK
// also if the next paragraph is a multilingual environment (because of nesting)
if (nextpar
- && state->open_encoding_ == CJK
+ && (state->open_encoding_ == CJK && bparams.encoding().iconvName() != "UTF-8"
+ && bparams.encoding().package() != Encoding::CJK )
&& (nextpar_language->encoding()->package() != Encoding::CJK
|| (nextpar->layout().isEnvironment() && nextpar->isMultiLingual(bparams)))
// inbetween environments, CJK has to be closed later (nesting!)
}
// If this is the last paragraph, close the CJK environment
- // if necessary. If it's an environment, we'll have to \end that first.
- if (runparams.isLastPar && !style.isEnvironment()) {
+ // if necessary. If it's an environment or nested in an environment,
+ // we'll have to \end that first.
+ if (runparams.isLastPar && !style.isEnvironment()
+ && par.params().depth() < 1) {
switch (state->open_encoding_) {
case CJK: {
// do nothing at the end of child documents
if (maintext && buf.masterBuffer() != &buf)
break;
- // end of main text
+ // end of main text: also insert a \clearpage (see #5386)
if (maintext) {
- os << "\n\\end{CJK}\n";
+ os << "\n\\clearpage\n\\end{CJK}\n";
// end of an inset
} else
os << "\\end{CJK}";
}
// Open a CJK environment at the beginning of the main buffer
- // if the document's language is a CJK language
- // (but not in child documents)
+ // if the document's main encoding requires the CJK package
+ // or the document encoding is utf8 and the CJK package is required
+ // (but not in child documents or documents using system fonts):
OutputState * state = getOutputState();
if (maintext && !is_child && !bparams.useNonTeXFonts
- && bparams.language->encoding()->package() == Encoding::CJK
- && (bparams.encoding().name() == "utf8-cjk"
- || bparams.encoding().iconvName() != "UTF-8")) {
- docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk"
- && LaTeXFeatures::isAvailable("CJKutf8")) ?
- from_ascii("UTF8")
- : from_ascii(bparams.encoding().latexName());
+ && (bparams.encoding().package() == Encoding::CJK
+ || (bparams.encoding().name() == "utf8"
+ && bparams.language->encoding()->package() == Encoding::CJK)
+ // FIXME: should test if any language requires CJK
+ // && LaTeXFeatures::mustProvide("CJK"))
+ // error: cannot call member function ‘bool lyx::LaTeXFeatures::mustProvide(const string&) const’ without object
+ )) {
+ docstring const cjkenc = bparams.encoding().iconvName() == "UTF-8"
+ ? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName());
os << "\\begin{CJK}{" << cjkenc
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
state->open_encoding_ = CJK;
// If the last paragraph is an environment, we'll have to close
// CJK at the very end to do proper nesting.
if (maintext && !is_child && state->open_encoding_ == CJK) {
- os << "\\end{CJK}\n";
+ os << "\\clearpage\n\\end{CJK}\n";
state->open_encoding_ = none;
}
// Likewise for polyglossia or when using begin/end commands
Encoding const & oldEnc = *runparams.encoding;
bool moving_arg = runparams.moving_arg;
- // If we switch from/to CJK, we need to switch anyway, despite custom inputenc,
- // except if we use CJKutf8
- bool const from_to_cjk =
- ((oldEnc.package() == Encoding::CJK && newEnc.package() != Encoding::CJK)
- || (oldEnc.package() != Encoding::CJK && newEnc.package() == Encoding::CJK))
- && (bparams.encoding().name() != "utf8-cjk" || !LaTeXFeatures::isAvailable("CJKutf8"));
- if (!force && !from_to_cjk
+ if (!force
&& ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg))
return make_pair(false, 0);
// This does of course only work in special cases (e.g. switch from
// tis620-0 to latin1, but the text in latin1 contains ASCII only),
// but it is the best we can do
- //
+ //
// 2019-01-08 Possibly no longer required since tis620-0 is supported
// by inputenc (but check special encodings "utf8-plain" and "default").
- if (oldEnc.package() == Encoding::none
- || newEnc.package() == Encoding::none)
+ if (oldEnc.package() == Encoding::none || newEnc.package() == Encoding::none)
return make_pair(false, 0);
+ // change encoding
LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
- << oldEnc.name() << " to " << newEnc.name());
+ << oldEnc.name() << " to " << newEnc.name());
os << setEncoding(newEnc.iconvName());
if (bparams.inputenc == "default")
- return make_pair(true, 0);
+ return make_pair(true, 0);
docstring const inputenc_arg(from_ascii(newEnc.latexName()));
OutputState * state = getOutputState();
os << "\\egroup";
count += 7;
}
- docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk"
- && LaTeXFeatures::isAvailable("CJKutf8")) ?
- from_ascii("UTF8")
- : from_ascii(bparams.encoding().latexName());
- os << "\\begin{CJK}{" << cjkenc << "}{"
+ os << "\\begin{CJK}{"
+ << from_ascii(newEnc.latexName()) << "}{"
<< from_ascii(bparams.fonts_cjk) << "}";
state->open_encoding_ = CJK;
return make_pair(true, count + 15);
}
// Dead code to avoid a warning:
return make_pair(true, 0);
-
}
} // namespace lyx