XeLaTeX

来自百合仙子's Wiki
(重定向自XeTeX
跳转到导航 跳转到搜索

示例

\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
% \usepackage{zhspacing}
\setromanfont{AR PL UMing CN}
\begin{document}
不需要安装字体,UMing \\
{\setromanfont{KaiTi_GB2312}
  不需要安装字体,楷书 GB2312  \\
}
{\setromanfont{FangSong_GB2312}
  不需要安装字体,仿宋 GB2312 \\
}
{\setromanfont{WenQuanYi Zen Hei}
  不需要安装字体,文泉驿 正黑 \\
}
{\setromanfont{AR PL UKai CN}
  不需要安装字体, UKai \\
}
{\setromanfont{LiSu}
  不需要安装字体,隶书 \\
}
{\setromanfont{LiSu}
  \large
    不需要安装字体,字号大点,隶书 \\
}
{\setromanfont{YouYuan}
  不需要安装字体,幼园 
}
{\setromanfont{方正静蕾简体}
  方正静蕾简体
}
\end{document}

字体

使用外部字体:

\newcommand\hei{\fontspec[ExternalLocation=/home/aeonlove/Others/Software/Font/Downloads/CJK/]{simhei.ttf}}

排版

对齐方式

一行对齐:

\leftline{左对齐} \centerline{居中} \rightline{右对齐}

多行或者段落对齐:

  • 左对齐 \begin{flushleft}...\end{flushleft},
  • 居中 \begin{center}...\end{center}
  • 右对齐 \begin{flushright}...\end{flushright}

来源:LaTeX 学习博客

中文

中英混排

使用zhspacing[1]。示例:

\documentclass{article}
\usepackage{zhspacing}
\zhspacing

% 重定义设置字体命令
\renewcommand{\setromanfont}[1]{\newfontfamily\zhfont{#1}}

\begin{document}
这是中文测 试。中文和English的混排。中
文和$E=mc^2$的混排。


{\setromanfont{KaiTi}
  不需要安装字体,楷书 GB2312
}

{\setromanfont{FangSong_GB2312}
  不需要安装字体,仿宋 GB2312
}
\end{document}

也可以使用 xeCJK 宏包。

中文直排

见http://space.uibe.edu.cn/u1/ryang/latex-xetex.html.

一些中文文档的重定义

%%%%%%%%%%%%%%%%%%%%%%%%%一些关于中文文档的重定义%%%%%%%%%%%%%%%%%
%%%%数学公式定理的重定义%%%%
\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{\abstractname}{摘要}
\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}
%%%%%%%%%%%%%%%%%%%%%%%%%中文重定义结束%%%%%%%%%%%%%%%%%%%%

备注

XeTeX 的标志定义:

\def\reflect#1{{\setbox0=\hbox{#1}\rlap{\kern0.5\wd0
  \special{x:gsave}\special{x:scale -1 1}}\box0 \special{x:grestore}}}
\def\XeTeX{\leavevmode
  \setbox0=\hbox{X\lower.5ex\hbox{\kern-.15em\reflect{E}}\kern-.1667em \TeX}%
  \dp0=0pt\ht0=0pt\box0}

sty

sty 文件可以置于 ~/texmf/tex/ 下。

参见

参考资料