mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Do not switch the input encoding inside documents using platex.
Fixes wrong and missing characters in text parts in other languages (platex does not support "inputenc"). Fixes compilation errors due to desynchronized encoding switches.
This commit is contained in:
parent
ad8d1af907
commit
da23637d7f
@ -1,47 +1,12 @@
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 569
|
||||
\lyxformat 572
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
\origin unavailable
|
||||
\textclass scrbook
|
||||
\begin_preamble
|
||||
% DO NOT ALTER THIS PREAMBLE!!!
|
||||
%
|
||||
% This preamble is designed to ensure that the manual prints
|
||||
% out as advertised. If you mess with this preamble,
|
||||
% parts of the manual may not print out as expected. If you
|
||||
% have problems LaTeXing this file, please contact
|
||||
% the documentation team
|
||||
% email: lyx-docs@lists.lyx.org
|
||||
|
||||
\IfFileExists{pxjahyper.sty}
|
||||
{\usepackage{pxjahyper}}
|
||||
|
||||
% if pdflatex is used
|
||||
\usepackage{ifpdf}
|
||||
\ifpdf
|
||||
|
||||
% set fonts for nicer pdf view
|
||||
\IfFileExists{lmodern.sty}
|
||||
{\usepackage{lmodern}}{}
|
||||
|
||||
\fi % end if pdflatex is used
|
||||
|
||||
% the pages of the TOC are numbered roman
|
||||
% and a PDF-bookmark for the TOC is added
|
||||
\pagenumbering{roman}
|
||||
\let\myTOC\tableofcontents
|
||||
\renewcommand{\tableofcontents}{%
|
||||
\pdfbookmark[1]{\contentsname}{}
|
||||
\myTOC
|
||||
\cleardoublepage
|
||||
\pagenumbering{arabic}}
|
||||
|
||||
% extra space for tables
|
||||
\newcommand{\extratablespace}[1]{\noalign{\vskip#1}}
|
||||
|
||||
\usepackage{t1enc}
|
||||
\end_preamble
|
||||
\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading
|
||||
\use_default_options false
|
||||
@ -99,8 +64,8 @@ End
|
||||
\language_package default
|
||||
\inputencoding auto
|
||||
\fontencoding auto
|
||||
\font_roman "default" "default"
|
||||
\font_sans "default" "default"
|
||||
\font_roman "lmodern" "IPAexGothic"
|
||||
\font_sans "default" "IPAexMincho"
|
||||
\font_typewriter "default" "default"
|
||||
\font_math "auto" "auto"
|
||||
\font_default_family default
|
||||
@ -116,6 +81,8 @@ End
|
||||
\output_sync 0
|
||||
\bibtex_command default
|
||||
\index_command default
|
||||
\float_placement class
|
||||
\float_alignment class
|
||||
\paperfontsize 12
|
||||
\spacing single
|
||||
\use_hyperref true
|
||||
|
@ -61,6 +61,7 @@ export/examples/Modules/Chessboard_(lyx(16|20|21|22|23)|(pdf3|pdf5|dvi3)_texF)
|
||||
# 1. Exceptions to the following pattern (test cases with the right encoding):
|
||||
!export/.*(utf8|ascii)_pdf4_texF
|
||||
!export/examples/(|ar|ca|cs|da|de|el|es|eu|fa|fr|gl|he|hu|id|it|ja|ko|nb|nl|pl|pt|pt_BR|pt_PT|ro|ru|sk|sl|sr|sv|uk|zh_CN)/Welcome_pdf4_texF
|
||||
!export/examples/ja/Multilingual_Typesetting_.*CJK.*_pdf4_texF
|
||||
# 2. Catchall patterns to ignore the other tests:
|
||||
.*_pdf4_texF
|
||||
export/(doc|examples|templates)/(|ar|ca|cs|da|de|el|es|eu|fa|fr|gl|he|hu|id|it|ja|ko|nb|nl|pl|pt|pt_BR|pt_PT|ro|ru|sk|sl|sr|sv|uk|zh_CN)/.*pdf4_texF
|
||||
@ -82,7 +83,7 @@ export/examples/ja/Modules/Sweave.*
|
||||
#
|
||||
# Other Japanese documents use language "japanese" wich is tied to "platex"
|
||||
# (automatically invoked instead of "latex" to create a DVI file).
|
||||
# Export by other engines works with language "japanese-cjk", e.g.
|
||||
# Export by plain- and pdflatex engines works with language "japanese-cjk", e.g.
|
||||
!export/examples/ja/Multilingual_Typesetting_.*CJK.*
|
||||
# For a discussion of alternatives for Japanese with LaTeX , see also
|
||||
# http://www.preining.info/blog/2014/12/writing-japanese-in-latex-part-1-introduction/
|
||||
|
@ -188,8 +188,6 @@ export/doc/ar/UserGuide_lyx(22|23)
|
||||
|
||||
#11532 inputencoding desynchronisation
|
||||
export/export/latex/misplaced-inputenc-switch_pdf2
|
||||
# Error in Japanese document if LyX-logo is preceded by foreign language text
|
||||
export/export/latex/ja_wrong_auto_encoding_(dvi|pdf(|3)).*
|
||||
|
||||
|
||||
# ==============================================================
|
||||
|
@ -125,7 +125,15 @@ Russisch: Привет с
|
||||
|
||||
\begin_layout Standard
|
||||
Text in some other languages with correct language setting (not all languages
|
||||
supported by LyX are compatible with pLaTeX):
|
||||
supported by LyX are compatible with pLaTeX, try
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
japanese (CJK)
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
):
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
@ -143,27 +151,6 @@ Afrikaans: Good dag minher.
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\emph on
|
||||
Missing and wrong characters with
|
||||
\emph default
|
||||
Language\SpecialChar menuseparator
|
||||
Encoding
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
language default
|
||||
\emph on
|
||||
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
|
||||
\emph default
|
||||
:
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\lang swedish
|
||||
Swedish: Hej då.
|
||||
\end_layout
|
||||
|
@ -3259,9 +3259,9 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
|
||||
// list all input encodings used in the document
|
||||
encoding_set = features.getEncodingSet(doc_encoding);
|
||||
|
||||
// If the "japanese" package (i.e. pLaTeX) is used,
|
||||
// inputenc must be omitted.
|
||||
// see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
|
||||
// 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)
|
||||
&& !features.isRequired("japanese")
|
||||
&& !features.isProvided("inputenc")) {
|
||||
|
@ -747,7 +747,7 @@ void LaTeXFeatures::useLanguage(Language const * lang)
|
||||
// They use the CJK package
|
||||
if (lang->encoding()->package() == Encoding::CJK)
|
||||
require("CJK");
|
||||
// japanese package is special
|
||||
// japanese babel language is special (tied to the pLaTeX engine).
|
||||
if (lang->encoding()->package() == Encoding::japanese)
|
||||
require("japanese");
|
||||
}
|
||||
@ -879,8 +879,7 @@ set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding) const
|
||||
set<string> encs;
|
||||
for (auto const & lang : UsedLanguages_)
|
||||
if (lang->encoding()->latexName() != doc_encoding &&
|
||||
(lang->encoding()->package() == Encoding::inputenc
|
||||
|| lang->encoding()->package() == Encoding::japanese))
|
||||
lang->encoding()->package() == Encoding::inputenc)
|
||||
encs.insert(lang->encoding()->latexName());
|
||||
return encs;
|
||||
}
|
||||
|
@ -127,8 +127,7 @@ Encoding const * InsetListings::forcedEncoding(Encoding const * inner_enc,
|
||||
// Minted can deal with all encodings.
|
||||
if (buffer().params().use_minted
|
||||
|| inner_enc->name() == "utf8-plain"
|
||||
|| (buffer().params().encoding().package() == Encoding::japanese
|
||||
&& inner_enc->package() == Encoding::japanese)
|
||||
|| buffer().params().encoding().package() == Encoding::japanese
|
||||
|| inner_enc->hasFixedWidth())
|
||||
return 0;
|
||||
|
||||
|
@ -984,6 +984,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
// \inputencoding command; the encoding switch will occur when necessary
|
||||
if (bparams.inputenc == "auto"
|
||||
&& !runparams.isFullUnicode() // Xe/LuaTeX use one document-wide encoding (see also switchEncoding())
|
||||
&& runparams.encoding->package() != Encoding::japanese
|
||||
&& runparams.encoding->package() != Encoding::none) {
|
||||
// Look ahead for future encoding changes.
|
||||
// We try to output them at the beginning of the paragraph,
|
||||
@ -1627,39 +1628,41 @@ void latexParagraphs(Buffer const & buf,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Switch the input encoding for some part(s) of the document.
|
||||
pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
OutputParams const & runparams, Encoding const & newEnc,
|
||||
bool force, bool noswitchmacro)
|
||||
{
|
||||
// Never switch encoding with non-TeX fonts (always "utf8plain") or
|
||||
// with LuaTeX and TeX fonts (only one encoding accepted by luainputenc).
|
||||
// Never switch encoding with non-TeX fonts (always "utf8plain"),
|
||||
// with LuaTeX and TeX fonts (only one encoding accepted by luainputenc),
|
||||
// or if we're in a moving argument or inherit the outer encoding.
|
||||
if (bparams.useNonTeXFonts
|
||||
|| runparams.flavor == OutputParams::LUATEX
|
||||
|| runparams.flavor == OutputParams::DVILUATEX
|
||||
|| newEnc.name() == "inherit")
|
||||
return make_pair(false, 0);
|
||||
|
||||
// Only switch for auto-selected legacy encodings (inputenc setting
|
||||
// "auto" or "default").
|
||||
// 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")
|
||||
|| runparams.moving_arg))
|
||||
return make_pair(false, 0);
|
||||
|
||||
Encoding const & oldEnc = *runparams.encoding;
|
||||
bool moving_arg = runparams.moving_arg;
|
||||
if (!force
|
||||
&& ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg))
|
||||
// Do not switch, if the encoding is unchanged or switching is not supported.
|
||||
if (oldEnc.name() == newEnc.name()
|
||||
|| oldEnc.package() == Encoding::japanese
|
||||
|| oldEnc.package() == Encoding::none
|
||||
|| newEnc.package() == Encoding::none)
|
||||
return make_pair(false, 0);
|
||||
|
||||
// Do nothing if the encoding is unchanged.
|
||||
if (oldEnc.name() == newEnc.name())
|
||||
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.
|
||||
// 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)
|
||||
return make_pair(false, 0);
|
||||
// This may fail for characters not supported by "unicodesymbols"
|
||||
// or for non-ASCII characters in "listings"
|
||||
// but it is the best we can do.
|
||||
|
||||
// change encoding
|
||||
LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
|
||||
@ -1673,7 +1676,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
switch (newEnc.package()) {
|
||||
case Encoding::none:
|
||||
case Encoding::japanese:
|
||||
// shouldn't ever reach here, see above
|
||||
// shouldn't ever reach here (see above) but avoids warning.
|
||||
return make_pair(true, 0);
|
||||
case Encoding::inputenc: {
|
||||
int count = inputenc_arg.length();
|
||||
@ -1698,8 +1701,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
count += 7;
|
||||
state->open_encoding_ = inputenc;
|
||||
}
|
||||
// with the japanese option, inputenc is omitted.
|
||||
if (runparams.use_japanese || noswitchmacro)
|
||||
if (noswitchmacro)
|
||||
return make_pair(true, count);
|
||||
os << "\\inputencoding{" << inputenc_arg << '}';
|
||||
return make_pair(true, count + 16);
|
||||
|
Loading…
Reference in New Issue
Block a user