TeXLive是什么?我从http://tug.org/texlive/摘录它的介绍如下。
TeX Live is an easy way to get up and running with the TeX document production system. It provides a comprehensive TeX system with binaries for most flavors of Unix, including GNU/Linux, and also Windows. It includes all the major TeX-related programs, macro packages, and fonts that are free software, including support for many languages around the world.
Google对这段话的翻译是
TEX Live是一个简单的方法,起床和运行TeX的文件生产系统。它提供了一个二进制文件进行全面TEX最口味的Unix,包括GNU / Linux的,而且也是Windows系统。它包括了所有主要的TEX相关程序,宏包,字体是免费软件,包括为世界各地的许多语言的支持。
想必读者能猜出七八分意思吧。大致说TeXLive是跨平台的,支持多种语言的,当然包括世界上使用人数最多的中文。
TeXLive对中文的支持突出体现在XeTeX上,它对中文的支持是发自肺腹的,因为它使用 Unicode 编码,缺省的是 UTF-8。由于 TeXLive 的普及和跨平台,使得 XeTeX 易于在使用中文的TeX初学者中推广。
在安装了 TeXLive 之后,使用 xelatex 对中文 TeX 进行编译,可以得到 PDF 结果,毋须进行繁复的设置。这是 TeX 中文化的福音。
下面给出中文 TeX 源码的一个例子,在 FreeBSD 下经过 xelatex 编译后生成文件 test.pdf。
TeX 源码的例子
- \documentclass[12pt,a4paper]{article}
- \setlength{\parindent}{2em} % 首行空两字
- \usepackage{fontspec} % 设置字体
- \setmainfont{宋体}
- \usepackage{indentfirst} % 首行缩进
- %%%%%%%%%% 数学符号公式 %%%%%%%%%%
- \usepackage{xeCJK} % 中英文混排
- \usepackage{amsmath} % AMS LaTeX宏包
- %\usepackage{amssymb} % 用来排版漂亮的数学公式
- %\usepackage{amsbsy}
- \usepackage{amsthm}
- \usepackage{amsfonts}
- \usepackage{mathrsfs} % 英文花体字体
- \usepackage{bm} % 数学公式中的黑斜体
- \usepackage{bbding,manfnt} % 一些图标,如 \dbend
- \usepackage{lettrine} % 首字下沉,命令\lettrine
- \def\attention{\lettrine[lines=2,lraise=0,nindent=0em]{\large\textdbend\hspace{1mm}}{}}
- %\usepackage{relsize} % 调整公式字体大小:\mathsmaller,\mathlarger
- %\usepackage{caption2} % 浮动图形和表格标题样式
- %%%%%%%%%% 图形支持宏包 %%%%%%%%%%
- \usepackage{graphicx} % 嵌入png图像
- \usepackage{color,xcolor} % 支持彩色文本、底色、文本框等
- %\usepackage{subfigure}
- %\usepackage{epsfig} % 支持eps图像
- %\usepackage{picinpar} % 图表和文字混排宏包
- %\usepackage[verbose]{wrapfig} % 图表和文字混排宏包
- %\usepackage{eso-pic} % 向文档的部分页加n副图形, 可实现水印效果
- %\usepackage{eepic} % 扩展的绘图支持
- %\usepackage{curves} % 绘制复杂曲线
- %\usepackage{texdraw} % 增强的绘图工具
- %\usepackage{treedoc} % 树形图绘制
- %\usepackage{pictex} % 可以画任意的图形
- %\usepackage{hyperref}
- %%%%%%%%%% 粘贴源代码 %%%%%%%%%%
- \usepackage{listings} % 粘贴源代码
- \lstloadlanguages{R, C, csh, make} % 所要粘贴代码的编程语言
- \lstdefinelanguage{Renhanced}[]{R}{%
- morekeywords={acf,ar,arima,arima.sim,colMeans,colSums,is.na,is.null,%
- mapply,ms,na.rm,nlmin,replicate,row.names,rowMeans,rowSums,seasonal,%
- sys.time,system.time,ts.plot,which.max,which.min},
- deletekeywords={c},
- alsoletter={.\%},%
- alsoother={:_\$}}
- \newcommand{\indexfonction}[1]{\index{#1@\texttt{#1}}}
- \lstset{language=Renhanced,tabsize=4, keepspaces=true,
- xleftmargin=2em,xrightmargin=0em, aboveskip=1em,
- backgroundcolor=\color{gray!20}, % 定义背景颜色
- frame=none, % 表示不要边框
- extendedchars=false, % 解决代码跨页时,章节标题,页眉等汉字不显示的问题
- basicstyle=\small,
- keywordstyle=\color{black}\bfseries,
- breakindent=10pt,
- identifierstyle=, % nothing happens
- commentstyle=\color{blue}\small, % 注释的设置
- morecomment=[l][\color{blue}]{\#},
- numbers=left,stepnumber=1,numberstyle=\scriptsize,
- showstringspaces=false,
- showspaces=false,
- flexiblecolumns=true,
- breaklines=true, breakautoindent=true,breakindent=4em,
- escapeinside={/*@}{@*/},
- }
- %%%%%%%%%% 正文 %%%%%%%%%%
- \begin{document}
- %%%%%%%%%% 定理类环境的定义 %%%%%%%%%%
- %% 必须在导入中文环境之后
- \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}{目录} % 将Contents改为目录
- \renewcommand{\abstractname}{摘要} % 将Abstract改为摘要
- \renewcommand{\refname}{参考文献} % 将References改为参考文献
- \renewcommand{\indexname}{索引}
- \renewcommand{\figurename}{图}
- \renewcommand{\tablename}{表}
- \renewcommand{\appendixname}{附录}
- \renewcommand{\proofname}{证明}
- \renewcommand{\algorithm}{算法}
- %%%%%%%%%% 论文标题、作者等 %%%%%%%%%%
- \title{用\LaTeX 写科技论文\thanks{这是一个为初学者写的\TeX 论文模板,
- 未经作者允许可以随意下载使用并修改传播,目的是让更多的人迅速上手用\TeX 系统写作。}
- }
- \author{于江生,北京大学计算机系}
- %\date{2008年10月01日} % 日期
- \date{}
- \maketitle % 生成标题
- \tableofcontents % 插入目录
- \thispagestyle{empty} % 首页无页眉页脚
- \begin{abstract}
- \noindent 这是一个简单的中文\TeX 模板,为\TeX 的初学者提供便利上手的参照。
- 该模板在 \TeX Live 下通过xelatex命令生成PDF文件,适合在类UNIX操作系统下工作的朋友从一个简单的模板出发,
- 不断地提升对\TeX 的认识。注意:若想用 xelatex命令,\TeX 文件必须按照 UTF-8 编码保存。
- 因为 Xe\TeX 是一种使用 Unicode 编码的 \TeX 系统,它对中文的支持是发自肺腹的,免去了繁复的配置。
- \end{abstract}
- %\PencilRightUp % 一些可爱的图标,需要bbding宏包的支持
- 公元1974年,ACM图灵奖授予了Standford大学教授\index{Donald E. Knuth} Donald E. Knuth (高德纳),
- 表彰他在算法和程序语言设计等多方面杰出的成就。他的巨著 The Art of Computer Programming 令人震撼。
- 另外,Knuth的突出贡献还包括\index{\TeX 系统} \TeX 系统,毫不夸张地评价,\TeX 给排版带来了一场革命。
- %%%%%%%%%% section %%%%%%%%%%
- \section{编辑数学公式}
- \indent % 恢复缩进
- Knuth 用\$ 符号界定数学公式,暗指着每个好的公式都是无价之宝。有了\TeX 系统,输入数学公式变得简单愉快。如,
- \begin{theorem}[L\'{e}vy\index{L\'{e}vy 定理}]
- 令 $F(x),\varphi(t)$ 分别为随机变量 $X$ 的分布函数和特征函数。
- 假定 $F(x)$ 在 $a+h$ 和 $a-h (h>0)$ 处连续,则有
- \begin{align}
- \label{Levy theorem} % 方程的标记可以是专有名词
- F(a+h)-F(a-h)&=\lim_{T\rightarrow\infty}\frac{1}{\pi}\int^{T}_{-T}\frac{\sin ht}{t}
- e^{-ita}\varphi(t)dt
- \end{align}
- \end{theorem}
- \begin{proof}
- 从略。感兴趣的读者可以参考……。
- \end{proof}
- \begin{corollary}
- 密度函数和特征函数之间有如下的关系。
- \begin{align}
- \label{DensityCharacteristic} % 自定义的标记
- f(x)&=\frac{1}{2\pi}\int^{+\infty}_{-\infty} e^{-itx}\varphi(t)dt
- \end{align}
- \end{corollary}
- \begin{proof}
- 由公式 (\ref{Levy theorem}) 和 Lebesgue 定理,我们有
- \begin{align*}
- \frac{F(x+\Delta x)-F(x)}{\Delta x}&=\frac{1}{2\pi}\int^{+\infty}_{-\infty}
- \frac{\sin(t\Delta x/2)}{t\Delta x/2} e^{-it(x+\Delta x/2)}\varphi(t) dt\\
- f(x)&=\frac{1}{2\pi}\int^{+\infty}_{-\infty}\lim_{\Delta x\rightarrow 0}
- \frac{\sin(t\Delta x/2)}{t\Delta x/2} e^{-it(x+\Delta x/2)}\varphi(t) dt\\
- &=\frac{1}{2\pi}\int^{+\infty}_{-\infty} e^{-itx}\varphi(t)dt\qedhere
- \end{align*}
- \end{proof}
- 我们知道特征函数的定义是
- \begin{align}
- \label{section1:characteristic} % 标记中注明了章节号
- \varphi(t)&= E(e^{itX})=\int^{+\infty}_{-\infty} e^{itx} f(x)dx
- \end{align}
- L\'{e}vy 定理在分布函数和特征函数之间搭建了一座桥梁。
- 对比 (\ref{DensityCharacteristic}) 和 (\ref{section1:characteristic}) 可见,
- 密度函数和特征函数之间的关系非常巧妙。
-
- \attention 在\TeX 环境里,数学公式的表达是很自然的,绝大多数命令就是英文的数学专有名词或它们的缩写,
- 如果你以前读过英文的数学文献,记忆这些命令是不难的。如果你没读过,正好通过记忆这些命令来了解术语。
- 手头有个命令快速寻查表是很方便的,我用的是 Hypertext Help with \LaTeX,网上可以搜到,是免费的。
- %%%%%%%%%%% section %%%%%%%%%%
- \section{图形表格等浮动对象}
- \index{贝叶斯方法}贝叶斯方法\cite{Gelman} 主要用于小样本数据分析,它利用参数先验分布和
- 后验分布之差异进行统计推断,其一般步骤是:
- \begin{enumerate}
- \item 构建概率模型,包括参数的先验分布。
- \item 给定观察数据,计算参数的后验分布。
- \item 分析模型的效果,如有必要,回到第一步。
- \end{enumerate}
- \begin{example}
- 下面,我们给一个表格的例子,一个图形的例子。
- \begin{center}
- \begin{table}[!ht] % 强制在原位显示表格
- \centering
- \caption{二维随机向量$(X,Y)$的边缘分布}
- \begin{tabular}{l|ccccc|c}
- $_X$\hspace{3mm} $^Y[ DISCUZ_CODE_0 ]amp;$y_1[ DISCUZ_CODE_0 ]amp;$y_2[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$y_j[ DISCUZ_CODE_0 ]amp;$\cdots$\\
- \hline
- $x_1$ &$p_{11}[ DISCUZ_CODE_0 ]amp;$p_{12}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$p_{1j}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$p_{1\cdot}$\\
- $x_2$ &$p_{21}[ DISCUZ_CODE_0 ]amp;$p_{22}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$p_{2j}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$p_{2\cdot}$\\
- $\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots$\\
- $x_i$ &$p_{i1}[ DISCUZ_CODE_0 ]amp;$p_{i2}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$p_{ij}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$p_{i\cdot}$\\
- $\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots[ DISCUZ_CODE_0 ]amp;$\vdots$\\
- \hline
- &$p_{\cdot 1}[ DISCUZ_CODE_0 ]amp;$p_{\cdot 2}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;$p_{\cdot j}[ DISCUZ_CODE_0 ]amp;$\cdots[ DISCUZ_CODE_0 ]amp;1
- \label{marginal distribution}
- \end{tabular}
- \end{table}
- \end{center}
- 在表\ref{marginal distribution} 中,$p_{\cdot j}=\sum\limits_i p_{ij}$,
- 类似地,$ p_{i\cdot}=\sum\limits_j p_{ij}$。
- \end{example}
- % 插入一个图片
- \begin{center}
- \begin{figure}[!h]
- \centering
- \includegraphics[width=0.95\textwidth]{knot.png}
- \caption{吞尾的环面和纽结,由 Maxima 绘制。\hfill\mbox{}}
- \label{torus and knot}
- \end{figure}
- \end{center}
- %%%%%%%%%%% section %%%%%%%%%%
- \section{如何张贴源码?}
- 使用 listings 宏包,可以将R、Maxima等语言的源码以某种固定的模式张贴出来。譬如,
- \begin{lstlisting}
- ## 生日问题:n <= 365 个人中至少两人生日相同的概率?
- ## 输出: n 个人当中至少两人生日相同的概率 P(A)
- ## 注意:R 语言中,变量有大小写的区分
- N <- 365 # 一年的天数
- n <- 50 # 选取的人数。
- InitProb <- matrix(1,n,1) # 一个 n 维的列向量的初始化
- ## 计算 n 个人当中没有人生日相同的概率
- for (i in 2:n){
- InitProb[i] <- InitProb[i-1] * (N-i+1)/N
- }
- Prob <- 1 - InitProb # 生日问题的解,输出一个 n 维列向量
- idx <- n - sum(Prob>0.5) + 1 # 概率大于 50% 所需最少人数
- \end{lstlisting}
- %%%%%%%%%%% section %%%%%%%%%%
- \section{后记}
- 这个\TeX 模板只是为了提供一个学习\TeX 的参考,各节的内容并没有关联性。欢迎读者使用并改进该模板,
- 并祝学习\TeX 愉快!
- Knuth大师最初设计\TeX 的时候并没有想到中文化,\TeX 排版系统的中文化始终令初学者望而却步、云山雾罩。
- 类UNIX系统下的teTeX和Windows系统下的MikTeX,都是\TeX 知名的发行版。然而,teTeX已经停止研发五年之久,
- 基于MikTeX的中文发行版CTeX 虽然如火如荼,但依然挡不住\TeX Live 一统江湖的大趋势。
- 虽然\TeX Live 还未入住FreeBSD的ports tree,但teTeX的远去,
- 令FreeBSD之下的很多ports不得不面临改换门庭的窘境。例如,auctex、latex-cjk等等。
- \TeX 的中文化可以有多种途径,xelatex 是其中最简单的(不见得是最美观的)。
- 在\TeX Live 2011 之下,不需要有任何更多的设置,甚至不用考虑中英文混排,
- xelatex能满足绝大多数中文化要求。这对于初学者来说,无疑是一个福音。
- %%%%%%%%%% 参考文献 %%%%%%%%%%
- \begin{thebibliography}{}
- \bibitem[Gelman et al., 2004]{Gelman} Gelman, A., Carlin, J. B., Stern, H. S. \& Rubin, D. B.
- (2004) Bayesian Data Analysis (Second Edition). \newblock Chapman \& Hall/CRC.
- \end{thebibliography}
- \clearpage
- \end{document}
- %%%%%%%%%% 结束 %%%%%%%%%%


雷达卡





京公网安备 11010802022788号







