行者无疆 始于足下 - 行走,思考,在路上
终于搞定Ubuntu 9.04下XeTeX的配置了。
整整弄了三天。写了份《Ubuntu 9.04 环境下TEX中文化配置》,呕心之作。内容都在文档里面了。
主要内容包括:
这是我使用的xeCJK模板。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Name: XeTeX+xeCJK日常使用模板
% Author: Lox Freeman
% Email: xiaohanyu1988@gmail.com
%
% 本文档可以自由转载、修改,希望能给广大TeXer的中文之路提供一些方便。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper, 12pt, titlepage]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK相关宏包%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xltxtra,fontspec,xunicode}
\usepackage[slantfont, boldfont, CJKaddspaces, CJKchecksingle]{xeCJK}
\CJKsetecglue{\hskip 0.15em plus 0.05em minus 0.05em}
% slanfont: 允许斜体
% boldfont: 允许粗体
% CJKnormalspaces: 仅忽略汉字之间的空白,但保留中英文之间的空白。
% CJKchecksingle: 避免单个汉字单独占一行。
% CJKaddspaces: [备选]忽略汉字之间的空白,并且自动在中英文转换时插入空白。
\CJKlanguage{zh-cn} % 中文标点特殊处理
\XeTeXlinebreaklocale "zh" % 针对中文进行断行
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
% 给予TeX断行一定自由度
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%日常所用宏包、通通放在一起%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 什么常用的宏包都可以放这里。下面是我常用的宏包,每个都给出了简要注释
\usepackage[top=2.5cm, bottom=3cm, left=2cm, right=2cm]{geometry}
% 控制页边距
\usepackage{enumerate} % 控制项目列表
\usepackage{multicol} % 多栏显示
\usepackage[%
pdfstartview=FitH,%
CJKbookmarks=true,%
bookmarks=true,%
bookmarksnumbered=true,%
bookmarksopen=true,%
colorlinks=true,%
citecolor=blue,%
linkcolor=blue,%
anchorcolor=green,%
urlcolor=blue%
]{hyperref}
\usepackage{titlesec} % 控制标题
\usepackage{titletoc} % 控制目录
\usepackage{type1cm} % 控制字体大小
\usepackage{indentfirst} % 首行缩进,用\noindent取消某段缩进
\usepackage{bbding} % 一些特殊符号
\usepackage{cite} % 支持引用
\usepackage{color,xcolor} % 支持彩色文本、底色、文本框等
\usepackage{latexsym} % LaTeX一些特殊符号宏包
\usepackage{amsmath} % AMS LaTeX宏包
\usepackage{bm} % 数学公式中的黑斜体
\usepackage{relsize} % 调整公式字体大小:\mathsmaller, \mathlarger
%\makeindex % 生成索引
%%%%%%%%%%%%%%%%%%%%%%%%%基本插图方法%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx} % 图形宏包
% \begin{figure}[htbp] % 控制插图位置
% \setlength{\abovecaptionskip}{0pt}
% \setlength{\belowcaptionskip}{10pt}
% 控制图形和上下文的距离
% \centering % 使图形居中显示
% \includegraphics[width=0.8\textwidth]{CTeXLive2008.jpg}
% 控制图形显示宽度为0.8\textwidth
% \caption{CTeXLive2008安装过程} \label{fig:CTeXLive2008}
% 图形题目和交叉引用标签
% \end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%插图方法结束%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%fancyhdr设置页眉页脚%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr} % 页眉页脚
\pagestyle{fancy} % 页眉页脚风格
\setlength{\headheight}{15pt} % 有时会出现\headheight too small的warning
%\fancyhf{} % 清空当前页眉页脚的默认设置
%%%%%%%%%%%%%%%%%%%%%%%%%fancyhdr设置结束%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%listings宏包粘贴源码%%%%%%%%%%%%%%%%%%%%
\usepackage{listings} % 方便粘贴源代码,部分代码高亮功能
\lstloadlanguages{} % 所要粘贴代码的编程语言
%%%%设置listings宏包的一些全局样式%%%%
%%%%参见http://hi.baidu.com/shawpinlee/blog/item/9ec431cbae28e41cbe09e6e4.html%%%%
\lstset{
numbers=left, % 在左边显示行号
numberstyle=\tiny,
keywordstyle=\color{blue!70}, commentstyle=\color{red!50!green!50!blue!50},
% 关键字高亮
frame=shadowbox, % 给代码加框
rulesepcolor=\color{red!20!green!20!blue!20},
escapechar=`, % 中文逃逸字符
xleftmargin=2em,xrightmargin=2em, aboveskip=1em,
breaklines, % 这条命令可以让LaTeX自动将长的代码行换行排版
extendedchars=false % 这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
}
%%%%%%%%%%%%%%%%%%%%%%%%%listings宏包设置结束%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK字体设置%%%%%%%%%%%%%%%%%%%%%%%%%
\punctstyle{kaiming} % 设置中文标点样式
% 支持quanjiao、banjiao、kaiming等多种方式
\setCJKmainfont[BoldFont=Adobe Heiti Std]{Adobe Song Std} % 设置缺省中文字体
\setCJKsansfont[BoldFont=Adobe Heiti Std]{Adobe Kaiti Std} % 设置中文无衬线字体
\setCJKmonofont{Adobe Heiti Std} % 设置等宽字体
\setmainfont{DejaVu Serif} % 英文衬线字体
\setmonofont{DejaVu Sans Mono} % 英文等宽字体
\setsansfont{DejaVu Sans} % 英文无衬线字体
%%%%定义新字体%%%%
\setCJKfamilyfont{song}{Adobe Song Std}
\setCJKfamilyfont{kai}{Adobe Kaiti Std}
\setCJKfamilyfont{hei}{Adobe Heiti Std}
\setCJKfamilyfont{fangsong}{Adobe Fangsong Std}
\setCJKfamilyfont{lisu}{LiSu}
\setCJKfamilyfont{youyuan}{YouYuan}
\newcommand{\song}{\CJKfamily{song}} % 自定义宋体
\newcommand{\kai}{\CJKfamily{kai}} % 自定义楷体
\newcommand{\hei}{\CJKfamily{hei}} % 自定义黑体
\newcommand{\fangsong}{\CJKfamily{fangsong}} % 自定义仿宋体
\newcommand{\lisu}{\CJKfamily{lisu}} % 自定义隶书
\newcommand{\youyuan}{\CJKfamily{youyuan}} % 自定义幼圆
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK字体设置结束%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%一些关于中文文档的重定义%%%%%%%%%%%%%%%%%
%%%%数学公式定理的重定义%%%%
\newtheorem{example}{例} % 整体编号
\newtheorem{algorithm}{算法}
\newtheorem{theorem}{定理}[section] % 按 section 编号
\newtheorem{definition}{定义}
\newtheorem{axiom}{公理}
\newtheorem{property}{性质}
\newtheorem{proposition}{命题}
\newtheorem{lemma}{引理}
\newtheorem{corollary}{推论}
\newtheorem{remark}{注解}
\newtheorem{condition}{条件}
\newtheorem{conclusion}{结论}
\newtheorem{assumption}{假设}
%%%%章节等名称重定义%%%%
\renewcommand{\contentsname}{目录}
\renewcommand{\indexname}{索引}
\renewcommand{\listfigurename}{插图目录}
\renewcommand{\listtablename}{表格目录}
\renewcommand{\figurename}{图}
\renewcommand{\tablename}{表}
\renewcommand{\appendixname}{附录}
%%%%设置chapter、section与subsection的格式%%%%
\titleformat{\chapter}{\centering\huge}{第\thechapter{}章}{1em}{\textbf}
\titleformat{\section}{\centering\LARGE}{\thesection}{1em}{\textbf}
\titleformat{\subsection}{\Large}{\thesubsection}{1em}{\textbf}
%%%%%%%%%%%%%%%%%%%%%%%%%中文重定义结束%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%一些个性设置%%%%%%%%%%%%%%%%%%%%%%
% \renewcommand{\baselinestretch}{1.3} % 效果同\linespread{1.3}
% \pagenumbering{arabic} % 设定页码方式,包括arabic、roman等方式
% \sloppy % 有时LaTeX无从断行,产生overfull的错误,
% 这条命令降低LaTeX断行标准
\setlength{\parskip}{0.5\baselineskip} % 设定段间距
\linespread{1.2} % 设定行距
\newcommand{\pozhehao}{\kern0.3ex\rule[0.8ex]{2em}{0.1ex}\kern0.3ex}
% 中文破折号,据说来自清华模板
%%%%%%%%%%%%%%%%%%%%%%%%%个性设置结束%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%正文部分%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\setlength{\parindent}{2em}
% 设定首行缩进为2em。注意此设置一定要在document环境之中。
% 这可能与\setlength作用范围相关
\title{Ubuntu 9.04环境下\TeX 中文化配置}
\author{Lox Freeman}
\date{\today}
\maketitle
\tableofcontents
\newpage
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%正文部分结束%%%%%%%%%%%%%%%%%%%%%%
% Name: XeTeX+xeCJK日常使用模板
% Author: Lox Freeman
% Email: xiaohanyu1988@gmail.com
%
% 本文档可以自由转载、修改,希望能给广大TeXer的中文之路提供一些方便。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper, 12pt, titlepage]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK相关宏包%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xltxtra,fontspec,xunicode}
\usepackage[slantfont, boldfont, CJKaddspaces, CJKchecksingle]{xeCJK}
\CJKsetecglue{\hskip 0.15em plus 0.05em minus 0.05em}
% slanfont: 允许斜体
% boldfont: 允许粗体
% CJKnormalspaces: 仅忽略汉字之间的空白,但保留中英文之间的空白。
% CJKchecksingle: 避免单个汉字单独占一行。
% CJKaddspaces: [备选]忽略汉字之间的空白,并且自动在中英文转换时插入空白。
\CJKlanguage{zh-cn} % 中文标点特殊处理
\XeTeXlinebreaklocale "zh" % 针对中文进行断行
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
% 给予TeX断行一定自由度
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%日常所用宏包、通通放在一起%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 什么常用的宏包都可以放这里。下面是我常用的宏包,每个都给出了简要注释
\usepackage[top=2.5cm, bottom=3cm, left=2cm, right=2cm]{geometry}
% 控制页边距
\usepackage{enumerate} % 控制项目列表
\usepackage{multicol} % 多栏显示
\usepackage[%
pdfstartview=FitH,%
CJKbookmarks=true,%
bookmarks=true,%
bookmarksnumbered=true,%
bookmarksopen=true,%
colorlinks=true,%
citecolor=blue,%
linkcolor=blue,%
anchorcolor=green,%
urlcolor=blue%
]{hyperref}
\usepackage{titlesec} % 控制标题
\usepackage{titletoc} % 控制目录
\usepackage{type1cm} % 控制字体大小
\usepackage{indentfirst} % 首行缩进,用\noindent取消某段缩进
\usepackage{bbding} % 一些特殊符号
\usepackage{cite} % 支持引用
\usepackage{color,xcolor} % 支持彩色文本、底色、文本框等
\usepackage{latexsym} % LaTeX一些特殊符号宏包
\usepackage{amsmath} % AMS LaTeX宏包
\usepackage{bm} % 数学公式中的黑斜体
\usepackage{relsize} % 调整公式字体大小:\mathsmaller, \mathlarger
%\makeindex % 生成索引
%%%%%%%%%%%%%%%%%%%%%%%%%基本插图方法%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx} % 图形宏包
% \begin{figure}[htbp] % 控制插图位置
% \setlength{\abovecaptionskip}{0pt}
% \setlength{\belowcaptionskip}{10pt}
% 控制图形和上下文的距离
% \centering % 使图形居中显示
% \includegraphics[width=0.8\textwidth]{CTeXLive2008.jpg}
% 控制图形显示宽度为0.8\textwidth
% \caption{CTeXLive2008安装过程} \label{fig:CTeXLive2008}
% 图形题目和交叉引用标签
% \end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%插图方法结束%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%fancyhdr设置页眉页脚%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr} % 页眉页脚
\pagestyle{fancy} % 页眉页脚风格
\setlength{\headheight}{15pt} % 有时会出现\headheight too small的warning
%\fancyhf{} % 清空当前页眉页脚的默认设置
%%%%%%%%%%%%%%%%%%%%%%%%%fancyhdr设置结束%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%listings宏包粘贴源码%%%%%%%%%%%%%%%%%%%%
\usepackage{listings} % 方便粘贴源代码,部分代码高亮功能
\lstloadlanguages{} % 所要粘贴代码的编程语言
%%%%设置listings宏包的一些全局样式%%%%
%%%%参见http://hi.baidu.com/shawpinlee/blog/item/9ec431cbae28e41cbe09e6e4.html%%%%
\lstset{
numbers=left, % 在左边显示行号
numberstyle=\tiny,
keywordstyle=\color{blue!70}, commentstyle=\color{red!50!green!50!blue!50},
% 关键字高亮
frame=shadowbox, % 给代码加框
rulesepcolor=\color{red!20!green!20!blue!20},
escapechar=`, % 中文逃逸字符
xleftmargin=2em,xrightmargin=2em, aboveskip=1em,
breaklines, % 这条命令可以让LaTeX自动将长的代码行换行排版
extendedchars=false % 这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
}
%%%%%%%%%%%%%%%%%%%%%%%%%listings宏包设置结束%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK字体设置%%%%%%%%%%%%%%%%%%%%%%%%%
\punctstyle{kaiming} % 设置中文标点样式
% 支持quanjiao、banjiao、kaiming等多种方式
\setCJKmainfont[BoldFont=Adobe Heiti Std]{Adobe Song Std} % 设置缺省中文字体
\setCJKsansfont[BoldFont=Adobe Heiti Std]{Adobe Kaiti Std} % 设置中文无衬线字体
\setCJKmonofont{Adobe Heiti Std} % 设置等宽字体
\setmainfont{DejaVu Serif} % 英文衬线字体
\setmonofont{DejaVu Sans Mono} % 英文等宽字体
\setsansfont{DejaVu Sans} % 英文无衬线字体
%%%%定义新字体%%%%
\setCJKfamilyfont{song}{Adobe Song Std}
\setCJKfamilyfont{kai}{Adobe Kaiti Std}
\setCJKfamilyfont{hei}{Adobe Heiti Std}
\setCJKfamilyfont{fangsong}{Adobe Fangsong Std}
\setCJKfamilyfont{lisu}{LiSu}
\setCJKfamilyfont{youyuan}{YouYuan}
\newcommand{\song}{\CJKfamily{song}} % 自定义宋体
\newcommand{\kai}{\CJKfamily{kai}} % 自定义楷体
\newcommand{\hei}{\CJKfamily{hei}} % 自定义黑体
\newcommand{\fangsong}{\CJKfamily{fangsong}} % 自定义仿宋体
\newcommand{\lisu}{\CJKfamily{lisu}} % 自定义隶书
\newcommand{\youyuan}{\CJKfamily{youyuan}} % 自定义幼圆
%%%%%%%%%%%%%%%%%%%%%%%%%xeCJK字体设置结束%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%一些关于中文文档的重定义%%%%%%%%%%%%%%%%%
%%%%数学公式定理的重定义%%%%
\newtheorem{example}{例} % 整体编号
\newtheorem{algorithm}{算法}
\newtheorem{theorem}{定理}[section] % 按 section 编号
\newtheorem{definition}{定义}
\newtheorem{axiom}{公理}
\newtheorem{property}{性质}
\newtheorem{proposition}{命题}
\newtheorem{lemma}{引理}
\newtheorem{corollary}{推论}
\newtheorem{remark}{注解}
\newtheorem{condition}{条件}
\newtheorem{conclusion}{结论}
\newtheorem{assumption}{假设}
%%%%章节等名称重定义%%%%
\renewcommand{\contentsname}{目录}
\renewcommand{\indexname}{索引}
\renewcommand{\listfigurename}{插图目录}
\renewcommand{\listtablename}{表格目录}
\renewcommand{\figurename}{图}
\renewcommand{\tablename}{表}
\renewcommand{\appendixname}{附录}
%%%%设置chapter、section与subsection的格式%%%%
\titleformat{\chapter}{\centering\huge}{第\thechapter{}章}{1em}{\textbf}
\titleformat{\section}{\centering\LARGE}{\thesection}{1em}{\textbf}
\titleformat{\subsection}{\Large}{\thesubsection}{1em}{\textbf}
%%%%%%%%%%%%%%%%%%%%%%%%%中文重定义结束%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%一些个性设置%%%%%%%%%%%%%%%%%%%%%%
% \renewcommand{\baselinestretch}{1.3} % 效果同\linespread{1.3}
% \pagenumbering{arabic} % 设定页码方式,包括arabic、roman等方式
% \sloppy % 有时LaTeX无从断行,产生overfull的错误,
% 这条命令降低LaTeX断行标准
\setlength{\parskip}{0.5\baselineskip} % 设定段间距
\linespread{1.2} % 设定行距
\newcommand{\pozhehao}{\kern0.3ex\rule[0.8ex]{2em}{0.1ex}\kern0.3ex}
% 中文破折号,据说来自清华模板
%%%%%%%%%%%%%%%%%%%%%%%%%个性设置结束%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%正文部分%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\setlength{\parindent}{2em}
% 设定首行缩进为2em。注意此设置一定要在document环境之中。
% 这可能与\setlength作用范围相关
\title{Ubuntu 9.04环境下\TeX 中文化配置}
\author{Lox Freeman}
\date{\today}
\maketitle
\tableofcontents
\newpage
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%正文部分结束%%%%%%%%%%%%%%%%%%%%%%