Математическое моделирование и исследование моделей с помощью математических программ 数学建模及数学软件的使用 Лекция 2 (LaTex) 张晔 ye.zhang@smbu.edu.cn
LaTex( 拉泰赫 ): 简介 ( 中国网站 : http://www.ctex.org/homepage) TEX 系统是公认的数学公式排得最好的系统 基本上所有的数学期刊都用 Tex 优点 vs 不足 : 不用考虑排版 美国 Donald E. Knuth 发明,1982 年发布第一版 LATEX 是当今世界上最流行和使用最为广泛的 TEX 宏集 它构筑在 Plain TEX 的基础之上, 并加进了很多的功能以使得使用者可以更为方便的利用 TEX 的强大功能 使用 LATEX 基本上不需要使用者自己设计命令和宏等, 因为 LATEX 已经替你做好了 MS Word + MathType( 可以用 TEX 命令了 )
LaTex( 拉泰赫 ): 简介 LATEX 是 TEX 中的一种格式 (format), 是建立在 TEX 基础上 的宏语言, 也就是说, 每一个 LATEX 命令实际上最后都会被 转换解释成几个甚至上百个 TEX 命令 如果你得到的宏包已经是编译过的, 也就是已经有.sty 或 者.cls 文件, 你只需把这些文件放在当前文件夹 例子 : \documentclass{article} \begin{document} This is a test file. \end{document} 这个例子需要保存为.tex 后缀的文件, 然后用 LATEX 编译, 生成的 DVI 文件可以用 DVI 浏览器进行查看或者用 dvips 转 换成 PostScript 文件
LaTex: 常识 空白距离 : 空格和制表符等空白字符在 LATEX 中被看作相同的空 白距离 (space) 多个连续的空白字符等同于一个空白字符 特殊字符 : 其他一些特殊符号可以由数学环境中的特殊命令或重音命令得到 反斜线 \ 不能通过在其前面加另一个反斜线得到 (\\): 试试 $\backslash$ 命令, 它将生成一个 `\' 注释 :LATEX 将忽略 % 后的该行内容, 换行符以及下一行前的空白字符 \usepackage{verbatim} % 多行注释宏包
LaTex: 文档 / 中文 & 俄语 LATEX 文档的标准结构是 \documentclass{article}... \begin{document}... \end{document}... 在 \begin{document} 和 \end{document} 之间的是我们的正文部分 而在 \documentclass{article} 和 \begin{document} 之间的部分, 通常用于 定义一些全局命令和参数, 这个部分就称为 导言区 (preamble) 加宏包 :\usepackage{*} 斯拉夫文 \usepackage[t1,t2a]{fontenc} \usepackage[koi8-ru]{inputenc} \usepackage[english,bulgarian,russian,ukranian]{babel} 如何同时显示俄语和中文? 中文排版例子 \documentclass{article} \usepackage{cjk} \begin{document} \begin{cjk*}{gbk}{kai} 这是中文楷体字 \end{cjk*} \end{document}
LaTex: 文档 \documentclass[options]{class} 例子 : \documentclass[11pt,twoside,a4paper]{article} 这条命令会引导 LATEX 使用 article 格式 11 磅大小的字体来排版该文档, 并得到在 A4 纸 上双面打印的效果
LaTex: 文档 另起一行, 而不另起一段 :\\ or \newline 在强制断行后, 还禁止分页 :\\* 另起一页 :\newpage 省略号 (ellipsis):\ldots 内置字符串 : 引号 : 你不能再像在打字机上那样, 把 用 作引号 (quotation marks) 在印刷中有专 门的左引号和右引号 在 LATEX 中, 用两个 `( 重音 ) 产生左引号, 用两个 '( 直立引号 ) 产生右引号 一个 ' 和一个 ' 产生一个单引号 破折号和连字号 (dash): 温度 (degree symbol): textcomp 宏包里有另外一个度的符号 \textcelsius 波浪号 :
LaTex: 注音符号 (accent) 和特殊字符 (special character)
LaTex: 标题 章和节 \section{...} \subsection{...} \subsubsection{...} \paragraph{...} \subparagraph{...} itemize 环境用于简单的列表,enumerate 环境用于带序号的列表,description 环境用于带描述的列表 当使用 report 或者 book 类的时候, 可以用另外一个高层次的分节命令 : \chapter{...} \appendix 目录 : \tableofcontents ( 为了得到正确的目录 (table of contents) 内容, 一个新文档必须编译 (LATEXed) 两次 有时还要编译第三次 )
LaTex: 表格 \begin{tabular}{ r l } \hline 7C0 & hexadecimal \\ 3700 & octal \\ \cline{2-2} 11111000000 & binary \\ \hline \hline 1984 & decimal \\ \hline \end{tabular} \begin{figure}[placement specier] 或 \begin{table}[... ] 例子 : \begin{table}[!hbp] [!hbp] 允许 LATEX 把表格就放当前页, 或放在某页的底部 (b), 或放在一个专门的浮动页上 (p), 严格按照放置说明符放置即使看起来不好 (!) 如果没有给定放置说明符, 缺省值为 [tbp] \begin{tabular}{c r @{.} l} Pi expression & \multicolumn{2}{c}{value} \\ \hline $\pi$ & 3&1416 \\ $\pi^{\pi}$ & 36&46 \\ $(\pi^{\pi})^{\pi}$ & 80662&7 \\ \end{tabular} \caption{caption text}
LaTex: 数学公式 Add $a$ squared and $b$ squared to get $c$ squared. Or, using a more mathematical approach: $c^{2}=a^{2}+b^{2}$ Add $a$ squared and $b$ squared to get $c$ squared. Or, using a more mathematical approach: \begin{displaymath} c^{2}=a^{2}+b^{2} \end{displaymath} or you can type less with: \[a+b=c\] 如果你希望 LATEX 给你的方程编上号, 你可以使用 equation 环境 然后你就可以用 \label 来给一个方程加上标签并在文中的某处用 \ref 或 amsmath 宏包中的 \eqref 命令来引用它 \begin{equation} \label{eq:eps} \epsilon > 0 \end{equation} From (\ref{eq:eps}), we gather \ldots{}from \eqref{eq:eps} we do the same.
LaTex: 数学公式的基本元素 小写希腊字母 (Greek letters) 的输入为 \alpha \beta \gamma, 大写希腊字母的输入为 \Gamma \Delta 指数和下标可以能过使用 ^ 和 _ 两个符号来指定 平方根 (square root) 输入用 \sqrt{};n 次根用 \sqrt[n] {} 来得到 命令 \overline 和 \underline 产生水平线, 它们会被放在表达式的正上方或是正下方 如 : $\overline{m+n}$ 命令 \overbrace 和 \underbrace 可以在一个表达式的上方或下方生成水平括号 如 : $\underbrace{a+b+\cdots+z}_{26}$ 向量 : \vec \overrightarrow 和 \overleftarrow 这两个命令可以用来表示一个从 A 到 B 的向量 如 : \overrightarrow{ab} 函数名 分数 : 例子 :\[\lim_{x \rightarrow 0} \frac{\sin x}{x}=1\]
LaTex: 数学公式的基本元素 排版二项式系数或类似的结构, 你可以使用 amsmath 宏包中的 \binom 命令, 如 :\binom{n}{k},\mathrm{c}_n^k \stackrel 命令会把其第一个参数中的符号以上标大小放在第二个上面, 而第二 个符号则以正常的位置摆放, 如 :\int f_n(x) \stackrel{!}{=} 1 \usepackage{stackrel} 复杂表达式中指标的放置,:\substack 命令和 subarray 环境 \begin{displaymath} \sum_{\substack{0<i<n \\ 1<j<m}} P(i,j) = \sum_{\begin{subarray}{l} i\in I\\ 1<j<m \end{subarray}} Q(i,j) \end{displaymath} 如果你在某个左定界符前放一个 \left 命令或是在某个右定界符前放一个 \right 命令,TEX 将会自动决定这对定界符的大小, 如 : 1 + \left( \frac{1}{ 1-x^{2} } \right) ^3
LaTex: 数学公式的基本元素 \begin{eqnarray} f(x) & = & \cos x \\ 三点列 (three dots) \ldots 得到在基线上的点列 f'(x) & = & -\sin x \\ 而 \cdots 是上下居中的点列 另外, 还有 \vdots \int_{0}^{x} f(y)dy & 命令产生竖直的点列,\ddots 产生对角线的点列 = & \sin x \end{eqnarray} 数组 : \begin{displaymath} \mathbf{x} = \left( \begin{array}{ccc} x_{11} & x_{12} & \ldots \\ x_{21} & x_{22} & \ldots \\ \vdots & \vdots & \ddots \end{array} \right) \end{displaymath} \begin{displaymath} y = \left\{ \begin{array}{ll} a & \textrm{if $d>c$}\\ b+x & \textrm{in the morning}\\ l & \textrm{all day long} \end{array} \right. \end{displaymath} 虚位 (phantom) \begin{displaymath} {}^{12}_{\phantom{1}6}\tex trm{c} \qquad \textrm{versus} \qquad {}^{12}_{6}\textrm{C} \end{displaymath} \begin{displaymath} \Gamma_{ij}^{\phantom{ij} k} \qquad \textrm{versus} \qquad \Gamma_{ij}^{k} \end{displaymath}
LaTex: 定义 定理 证明 amsthm 宏包提供了 \newtheoremstyle{style} 命令, 通过从三个预定义样式中选择其一来定义 定理的外观, 三个样式分别为 : definition( 标题粗体, 内容罗马体 ); plain ( 标题粗体, 内容斜体 ); remark( 标题斜体, 内容罗马体 ) \newtheorem{theorem}{theorem}[section] \newtheorem{corollary}{corollary} \newtheorem{lemma}[theorem]{lemma} \newtheorem{proposition}{proposition} \newtheorem{conjecture}{conjecture} \newtheorem*{problem}{problem} \theoremstyle{definition} \newtheorem{definition}[theorem]{definition} \newtheorem{remark}{remark} \newtheorem*{notation}{notation} amsthm 还提供了一个 proof 环境 \begin{proof} Trivial, use \[E=mc^2\] \end{proof}
LaTex: 数学符号表 (WinEdt 都有 不用记 )
LaTex: 图形 (eps) 载入 graphicx 宏包 : \usepackage[driver]{graphicx} \begin{figure} \centering \includegraphics[angle=90,width=0.5\textwidth]{test} \caption{this is a test.} \end{figure}
LaTex: 参考文献 Partl~\cite{pa} has proposed that \ldots \begin{thebibliography}{99} \bibitem{pa} H.~Partl: \emph{german \TeX}, TUGboat Volume~9, Issue~1 (1988) \end{thebibliography}
LaTex: 演示文稿 beamer 对于屏幕阅读版本的演示文稿 \mode<beamer>, 我们选择了 Goettingen 主题, 它将目录合成到导航面板 通过选项控制面板的大小 ( 这个例子采用 22 mm), 和确定面板的位置 ( 正文右侧 ) 选项 hideothersubsections 显示章节的标题, 但只显示当前章节的子节标题 对于 \mode<trans> 和 \mode<handout> 的设置也是一样的, 它们将出现在它们标准的版面上 命令 \title{},\author{},\institute{} 和 \titlegraphic{} 定义标题页的内容 \title[]{} 和 \author[]{} 的选项允许你定义显示在 Goettingen 主题的面板上的标题和作者名 面板中的标题和子标题由 frame 环境外面的命令 \section{} 和 \subsection{} 来创建
LaTex: 演示文稿 beamer 屏幕底部的一些微型导航图标也可以让你浏览整个文档 它们的出现不依赖你选择的主题 每张幻灯片或每版屏幕的内容放在 frame 环境中 利用尖括弧 (< 和 >) 里面的选项, 用演示文档的一个版式来定义一个特殊的帧 在这个例子中, 第一页不会由于参量 <handout:0> 而显示为讲义模式 除了幻灯片的标题页, 强烈建议通过命令 \frametitle{} 来重新设置每一张幻灯片的标题 如果需要, 使用 block 环境可以来定义子标题, 在这个例子中也可体现出来 注意到章节命令 \section{} 和 \subsection{} 不在幻灯片上产生输出结果 列表环境中的命令 \pause 允许你一个接一个地显示列表栏目的内容 命令 :\only \uncover \alt 和 \temporal, 可以让你获得其他的一些演示效果 很多情况下, 你可以通过尖括弧中的内容来定制演示效果
LaTex: beamer \documentclass[10pt]{beamer} \mode<beamer>{% \usetheme[hideothersubsections, right,width=22mm]{goettingen} } \title{simple Presentation} \author[d. Flipo]{Daniel Flipo} \institute{u.s.t.l. \& GUTenberg} \titlegraphic{\includegraphics[width=20mm]{ustl}} \date{2005} \begin{document} \begin{frame}<handout:0> \titlepage \end{frame} \section{ 一个例子 } \begin{frame} \frametitle{things to do on a Sunday Afternoon} \begin{block}{one could \ldots} \begin{itemize} \item walk the dog\dots \pause \item read a book\pause \item confuse a cat\pause \end{itemize} \end{block} and many other things \end{frame} \end{document}
LaTex: a0poster \documentclass[a0,portrait]{a0poster} \usepackage{multicol} % This is so we can have multiple columns of text side-by-side \columnsep=100pt % This is the amount of white space between the columns in the poster \columnseprule=3pt % This is the thickness of the black line between the columns in the poster \usepackage[svgnames]{xcolor} % Specify colors by their 'svgnames', for a full list of all colors available see here: http://www.latextemplates.com/svgnames-colors \usepackage{times} % Use the times font% \usepackage{palatino} % Uncomment to use the Palatino font \usepackage{graphicx} % Required for including images \graphicspath{{figures/}} % Location of the graphics files \usepackage{booktabs} % Top and bottom rules for table \usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures \usepackage{amsfonts, amsmath, amsthm, amssymb} % For math fonts, symbols and environments \usepackage{wrapfig} % Allows wrapping text around tables and figures