inputenc only expects one option

File switches with documents are done via \inputencoding.
Other than with fontenc, these do not need to be laoded via options
beforehand.

Also, out current code loaded the additional languages' encoding last,
which might result in wrong encoding settings.
This commit is contained in:
Juergen Spitzmueller 2022-12-17 15:04:54 +01:00
parent 19ceef7f86
commit 9716e79624

View File

@ -3394,34 +3394,14 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
Encoding::Package const package =
language->encoding()->package();
// Create list of inputenc options:
set<string> encoding_set;
// luainputenc fails with more than one encoding
if (features.runparams().flavor != Flavor::LuaTeX
&& features.runparams().flavor != Flavor::DviLuaTeX)
// list all input encodings used in the document
encoding_set = features.getEncodingSet(doc_encoding);
// The "japanese" babel-language requires the pLaTeX engine
// which conflicts with "inputenc".
// See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
if ((!encoding_set.empty() || package == Encoding::inputenc)
if (package == Encoding::inputenc
&& !features.isRequired("japanese")
&& !features.isProvided("inputenc")) {
os << "\\usepackage[";
set<string>::const_iterator it = encoding_set.begin();
set<string>::const_iterator const end = encoding_set.end();
if (it != end) {
os << from_ascii(*it);
++it;
}
for (; it != end; ++it)
os << ',' << from_ascii(*it);
if (package == Encoding::inputenc) {
if (!encoding_set.empty())
os << ',';
os << from_ascii(doc_encoding);
}
os << "\\usepackage["
<< from_ascii(doc_encoding);
if (features.runparams().flavor == Flavor::LuaTeX
|| features.runparams().flavor == Flavor::DviLuaTeX)
os << "]{luainputenc}\n";