Fonts & Character SetsLine Breaks in Local Layout Text Styles (XeTeX & CJK)

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
dreamon
Posts: 2
Joined: Tue May 14, 2013 7:13 pm

Line Breaks in Local Layout Text Styles (XeTeX & CJK)

Post by dreamon »

Hello folks!

I have been playing around with LyX and XeTeX a lot recently, hoping to find a setup which allows me to switch easily between Chinese, Japanese and Korean (CJK) language input. I have set up a document with Local Layouts for each language, so Text Styles for CJK are easily accessible through the context menu. Although this seems to work well for separate words and short sentences, I am bothered by the inability to enter line breaks in sections formatted for a certain language. I can copy and paste text with line breaks from other sources into these sections, and I can force a line break using CTRL + Enter, but I was wondering if there is a way for me to enter normal line breaks directly that does not involve ERT insets? :-)

Have a look at the attached LyX document for an illustration of the problem. When placing the cursor in any text area formated for CJK text and pressing Enter LyX will tell you "Command Disabled".

Note: I am working on an Ubuntu 12.04 system (64bit) with LyX 2.0.6, fully updated. I have all the necessary packages and fonts for LaTeX/XeTeX and CJK installed. Line breaks work fine when working with the source file (File -> Export) and compiling in XeTeX directly.
Attachments
lyx-cjk.lyx
(6.35 KiB) Downloaded 391 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

dreamon
Posts: 2
Joined: Tue May 14, 2013 7:13 pm

Line Breaks in Local Layout Text Styles (XeTeX & CJK)

Post by dreamon »

Thanks to some friendly help by Richard Heck on the LyX mailing list (http://www.mail-archive.com/lyx-users@l ... 95611.html) I have been able to adapt my Local Layout definitions so that I can now enter line breaks within sections formatted with a certain Text Style :-)

The key is the MultiPar command, which needs to be set to "1" so Text Styles can contain multiple paragraphs. Here is how I modified the definition for the "zhcn" environment:

Code: Select all

InsetLayout		CharStyle:zhcn
  LyxType		charstyle
  MultiPar		1
  LabelString		zhcn
  LatexType		command
  LatexName		zhcn
  Font
    Family		Serif
  EndFont
  Preamble
    \newcommand{\zhcn}[1]{{\CJKfamily{zhcnfont}#1}}
  EndPreamble
End
Post Reply