[Tex/LaTex] use chinese in lyx beamer slide

beamerlyx

I wish to use lyx beamer document type but use Chinese in document.
Maybe it's possible to use CJK but not sure how to do it.

Anyone can share your suggestion?

Best Answer

I have no idea if this is the correct way to do it (I don't know how to write in Chinese), but it appears to work for me. Note that I'm on Ubuntu with TeX Live 2014 and am using LyX 2.1.1. Before trying this, first make sure you can export LyX's Chinese manuals as a test that you have all of the prerequisites. Open doc/zh_CN/Intro.lyx and doc/zh_CN/Tutorial.lyx. Can you export them successfully to PDF (pdflatex) ? If so, do the following for Beamer with Chinese:

  1. In Document > Settings, change Language to "Chinese (simplified)" and Encoding to "other: Unicode (CJK) (utf8)"

  2. In Document > Settings, under Fonts change "CJK:" to "gbsn".

  3. View PDF (pdftex)

Below is an example (requires at least LyX 2.1.0 to run). Note that I just took the first frame of the English Help > Beamer manual and added some Chinese text to the second item of the itemize in the frame.

.lyx file:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass beamer
\begin_preamble
% We use the "Berkeley" theme with a 3.45em-wide side bar on the left
\usetheme[left,width=3.45em]{Berkeley}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language chinese-simplified
\language_package default
\inputencoding utf8-cjk
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_cjk gbsn
\graphics default
\default_output_format pdf2
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 0
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 0
\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 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\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 Title
Presentations with Beamer and LyX
\end_layout

\begin_layout Subtitle
An Introduction to the Basics
\end_layout

\begin_layout Author
The LyX Team
\end_layout

\begin_layout Date
V.
 2.1
\end_layout

\begin_layout Frame

\end_layout

\begin_deeper
\begin_layout FrameTitle
\begin_inset Argument 1
status open

\begin_layout Plain Layout
presentation
\end_layout

\end_inset

Contents
\end_layout

\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents

\end_inset


\end_layout

\end_deeper
\begin_layout Section
Purposes
\end_layout

\begin_layout Frame
\begin_inset Argument 2
status open

\begin_layout Plain Layout
+-
\end_layout

\end_inset


\begin_inset Argument 4
status open

\begin_layout Plain Layout
Purpose of the Beamer class
\end_layout

\end_inset


\end_layout

\begin_layout Frame
With the 
\begin_inset Flex Structure
status open

\begin_layout Plain Layout
Beamer
\end_layout

\end_inset

 class, you can produce presentation slides, which
\end_layout


\begin_deeper
\begin_layout Itemize
are visually highly customizable
\end_layout

\begin_layout Itemize
是一个文档写作系统
\end_layout

\begin_layout Itemize
can be constructed step-by-step (
\begin_inset Quotes eld
\end_inset

overlay
\begin_inset Quotes erd
\end_inset

 concept)
\end_layout

\begin_layout Itemize
may contain different navigation paths (note that the slides contain all
 sorts of hyperlinks)
\end_layout

\begin_layout Itemize
use LaTeX's superb output quality
\end_layout

\begin_layout Itemize
might embed multimedia content (audio, video)
\end_layout

\begin_layout Itemize
can easily be transformed to accompanying material (such as an article-like
 handout)
\end_layout

\begin_layout Itemize
and much more \SpecialChar \ldots{}

\end_layout

\end_deeper
\end_body
\end_document

Exported (with LaTeX (pdflatex)) .tex file:

%% LyX 2.2.0dev created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{CJKutf8}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
 % this default might be overridden by plain title style
 \newcommand\makebeamertitle{\frame{\maketitle}}%
 % (ERT) argument for the TOC
 \AtBeginDocument{%
   \let\origtableofcontents=\tableofcontents
   \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
   \def\gobbletableofcontents#1{\origtableofcontents}
 }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
% We use the "Berkeley" theme with a 3.45em-wide side bar on the left
\usetheme[left,width=3.45em]{Berkeley}

\makeatother

\begin{document}
\begin{CJK}{UTF8}{gbsn}%

\title{Presentations with Beamer and \LyX{}}

\subtitle{An Introduction to the Basics}

\author{The \LyX{} Team}

\date{V. 2.1}
\makebeamertitle
\begin{frame}


\frametitle<presentation>{Contents}

\tableofcontents{}
\end{frame}

\section{Purposes}
\begin{frame}[<+->]{Purpose of the Beamer class}

With the \structure{Beamer} class, you can produce presentation slides,
which

\begin{itemize}
\item are visually highly customizable
\item 是一个文档写作系统
\item can be constructed step-by-step (``overlay'' concept)
\item may contain different navigation paths (note that the slides contain
all sorts of hyperlinks)
\item use \LaTeX{}'s superb output quality
\item might embed multimedia content (audio, video)
\item can easily be transformed to accompanying material (such as an article-like
handout)
\item and much more \ldots{}
\end{itemize}
\end{frame}
\end{CJK}

\end{document}

(one slide of) output:

enter image description here