Fix second part of #5386.

A \clearpage command issued right before \end{CJK} is recommended by the
package author to prevent any un-processed CJK chars outside the
\begin{CJK} and \end{CJK} scope. Otherwise, TOC, header, footer,
and may contain CJK chars but get processed outside the CJK environment scope.

Tha new dedicated export test fails without the fix.
This commit is contained in:
Günter Milde 2019-01-24 14:40:19 +01:00
parent 197735747e
commit 5ebc0b3f43
2 changed files with 177 additions and 2 deletions

View File

@ -0,0 +1,175 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 566
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass report
\begin_preamble
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\language chinese-traditional
\language_package default
\inputencoding utf8-cjk
\fontencoding auto
\font_roman "lmodern" "Noto Sans CJK SC"
\font_sans "default" "Noto Sans CJK SC Light"
\font_typewriter "default" "Noto Sans Mono CJK SC"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\font_cjk bsmi
\use_microtype false
\use_dash_ligatures false
\graphics default
\default_output_format pdf2
\output_sync 0
\bibtex_command default
\index_command default
\float_placement class
\float_alignment class
\paperfontsize 12
\spacing single
\use_hyperref true
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen true
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks true
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4paper
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\use_minted 0
\index 索引
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip 2ex
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents
\end_inset
\end_layout
\begin_layout Chapter
\SpecialChar LyX
\end_layout
\begin_layout Standard
This is a Chinese test document for \SpecialChar LyX
with the CJK package.
\end_layout
\begin_layout Standard
The
\emph on
Table of Contents
\emph default
heading appears as
\begin_inset Quotes eld
\end_inset
Contents
\begin_inset Quotes erd
\end_inset
in the PDF.
\end_layout
\begin_layout Standard
Without a
\backslash
clearpage before closing the
\begin_inset Quotes eld
\end_inset
CJK
\begin_inset Quotes erd
\end_inset
environment, Chinese characters in a section title lead to errors like
\end_layout
\begin_layout LyX-Code
! Package inputenc Error: Unicode char 中 (U+4E2D)
\end_layout
\begin_layout LyX-Code
(inputenc) not set up for use with LaTeX.
\end_layout
\begin_layout Standard
(cf.
https://www.lyx.org/trac/ticket/5386).
\end_layout
\begin_layout Section
Section in English
\end_layout
\begin_layout Standard
This section head is in English.
\end_layout
\begin_layout Section
Secition in Chinese 中文名
\end_layout
\begin_layout Standard
This section head is in Chinese.
這節的標題是中文。
\end_layout
\end_body
\end_document

View File

@ -1279,9 +1279,9 @@ void TeXOnePar(Buffer const & buf,
// 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}";