From 46f5acb19c3cf41d674c4eaee40aaf02de042012 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnter=20Milde?= Date: Tue, 29 Jan 2019 22:31:58 +0100 Subject: [PATCH] Chinese localization in user preamble using "ctex" with non-TeX fonts https://tex.stackexchange.com/questions/17611/how-does-one-type-chinese-in-latex TODO: use "ctex" if the document language is Chinese. Remove "\clearpage" workaround from documents (not required after fix for #5386 in [5ebc0b3f432f468/lyxgit]). --- development/autotests/unreliableTests | 5 ++-- lib/doc/zh_CN/Intro.lyx | 40 ++++--------------------- lib/doc/zh_CN/Tutorial.lyx | 42 ++++----------------------- 3 files changed, 13 insertions(+), 74 deletions(-) diff --git a/development/autotests/unreliableTests b/development/autotests/unreliableTests index 96a644b0c8..9b1a875d49 100644 --- a/development/autotests/unreliableTests +++ b/development/autotests/unreliableTests @@ -121,9 +121,10 @@ export/templates/acmart_pdf # the name of the day in English instead of Japanese. export/examples/ja/multilingual_lyx.* -# No localization of auto-strings with Chinese language (LyXHTML is OK) +# No localization of auto-strings with Chinese language under 8-bit TeX +# (ctex font issue with texlive-lang-chinese (from Debian) under pdflatex): export/export/latex/CJK/zh_CN-toc.* -export/doc/zh_CN/(Intro|Tutorial)_(dvi|pdf).* +export/doc/zh_CN/(Intro|Tutorial)_(dvi|pdf).? # Missing Chinese characters in the DVI (LuaTex) export/doc/zh_CN/(Intro|Tutorial)_dvi3_systemF diff --git a/lib/doc/zh_CN/Intro.lyx b/lib/doc/zh_CN/Intro.lyx index 8e17f5383b..46321bd255 100644 --- a/lib/doc/zh_CN/Intro.lyx +++ b/lib/doc/zh_CN/Intro.lyx @@ -6,20 +6,11 @@ \origin /systemlyxdir/doc/zh_CN/ \textclass article \begin_preamble -\usepackage{ifxetex} -\ifxetex -\usepackage{xeCJK} -\fi - -% proper line breaking, punctuation kerning and font switching -% features with LuaTeX -% see https://tex.stackexchange.com/questions/222980/how-to-use-chinese-with-lualatex -\usepackage{ifluatex} -\ifluatex - \usepackage{luatexja-fontspec} - \setmainjfont[Mapping=tex-text]{WenQuanYi Micro Hei} - \setsansjfont[Mapping=tex-text]{WenQuanYi Micro Hei} -\fi +% Chinese localization +\@ifpackageloaded{fontspec}% +{\usepackage{ctex}}% ctex with non-TeX fonts +{%\usepackage[UTF8]{ctex}% error with font setup (missing font?) +} \end_preamble \use_default_options true \maintain_unincluded_children false @@ -1500,26 +1491,5 @@ literal "false" 无论你修改文档的想法是什么,只要它能够改善文档质量,我们都是乐于接受的。 \end_layout -\begin_layout Standard -\begin_inset Note Note -status open - -\begin_layout Plain Layout -The following clearpage is required to avoid compilation errors at some - installations for an unknown reason. -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - \end_body \end_document diff --git a/lib/doc/zh_CN/Tutorial.lyx b/lib/doc/zh_CN/Tutorial.lyx index 9300934551..44f6cded94 100644 --- a/lib/doc/zh_CN/Tutorial.lyx +++ b/lib/doc/zh_CN/Tutorial.lyx @@ -6,27 +6,11 @@ \origin /systemlyxdir/doc/zh_CN/ \textclass book \begin_preamble -%\usepackage{fontspec} -%\setromanfont{AR PL ShanHeiSun Uni}%字体来自Adobe Reader 8.0 OpenType,可以选用任何系统已有的字体 -%中文断行 -%\XeTeXlinebreaklocale "zh" -%\XeTeXlinebreakskip = 0pt plus 1pt -\usepackage{ifxetex} -\ifxetex - \usepackage{xeCJK} - %\setCJKmainfont{WenQuanYi Micro Hei} - %\setCJKmonofont{WenQuanYi Micro Hei Mono} -\fi - -% proper line breaking, punctuation kerning and font switching -% features with LuaTeX -% see https://tex.stackexchange.com/questions/222980/how-to-use-chinese-with-lualatex -\usepackage{ifluatex} -\ifluatex - \usepackage{luatexja-fontspec} - \setmainjfont[Mapping=tex-text]{WenQuanYi Micro Hei} - \setsansjfont[Mapping=tex-text]{WenQuanYi Micro Hei} -\fi +% Chinese localization +\@ifpackageloaded{fontspec}% +{\usepackage{ctex}}% ctex with non-TeX fonts +{%\usepackage[UTF8]{ctex}% error with font setup (missing font?) +} \end_preamble \options cjk \use_default_options true @@ -2963,21 +2947,5 @@ Bib\SpecialChar TeX 错误信息。 \end_layout -\begin_layout Standard -\begin_inset ERT -status open - -\begin_layout Plain Layout - - -\backslash -clearpage -\end_layout - -\end_inset - - -\end_layout - \end_body \end_document -- 2.39.2