From 15fd5e51d9cd5137ea905df3f55cae0c81ecae38 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 3 Aug 2020 21:43:05 +0000 Subject: lshort-chinese (3aug20) git-svn-id: svn://tug.org/texlive/trunk@56036 c570f23f-e606-0410-a88d-b1316a301751 --- .../doc/latex/lshort-chinese/README-zh.md | 16 +- .../texmf-dist/doc/latex/lshort-chinese/README.md | 17 +- .../doc/latex/lshort-chinese/lshort-zh-cn.pdf | Bin 1049683 -> 1452490 bytes .../doc/latex/lshort-chinese/src/INSTRUCTIONS.md | 36 +- .../doc/latex/lshort-chinese/src/app.A.install.tex | 137 --- .../latex/lshort-chinese/src/app.B.error.help.tex | 246 ----- .../doc/latex/lshort-chinese/src/biblio.tex | 103 -- .../latex/lshort-chinese/src/chap.01.basics.tex | 399 ------- .../doc/latex/lshort-chinese/src/chap.02.text.tex | 380 ------- .../latex/lshort-chinese/src/chap.03.elements.tex | 1139 ------------------- .../doc/latex/lshort-chinese/src/chap.04.math.tex | 894 --------------- .../doc/latex/lshort-chinese/src/chap.05.style.tex | 696 ------------ .../doc/latex/lshort-chinese/src/chap.06.spec.tex | 683 ------------ .../latex/lshort-chinese/src/chap.07.graphic.tex | 472 -------- .../latex/lshort-chinese/src/chap.08.custom.tex | 349 ------ .../lshort-chinese/src/chap/app.A.install.tex | 137 +++ .../lshort-chinese/src/chap/app.B.error.help.tex | 246 +++++ .../doc/latex/lshort-chinese/src/chap/biblio.tex | 103 ++ .../lshort-chinese/src/chap/chap.01.basics.tex | 451 ++++++++ .../latex/lshort-chinese/src/chap/chap.02.text.tex | 357 ++++++ .../lshort-chinese/src/chap/chap.03.elements.tex | 1145 ++++++++++++++++++++ .../latex/lshort-chinese/src/chap/chap.04.math.tex | 901 +++++++++++++++ .../lshort-chinese/src/chap/chap.05.style.tex | 776 +++++++++++++ .../latex/lshort-chinese/src/chap/chap.06.spec.tex | 680 ++++++++++++ .../lshort-chinese/src/chap/chap.07.graphic.tex | 473 ++++++++ .../lshort-chinese/src/chap/chap.08.custom.tex | 349 ++++++ .../doc/latex/lshort-chinese/src/chap/fdl.tex | 490 +++++++++ .../lshort-chinese/src/chap/preface.contrib.tex | 238 ++++ .../lshort-chinese/src/chap/preface.overview.tex | 58 + .../lshort-chinese/src/chap/sec.symbol.table.tex | 393 +++++++ .../latex/lshort-chinese/src/chap/titlepage.tex | 35 + .../doc/latex/lshort-chinese/src/fdl.tex | 490 --------- .../lshort-chinese/src/lshort-zh-cn-style.sty | 46 +- .../doc/latex/lshort-chinese/src/lshort-zh-cn.tex | 36 +- .../doc/latex/lshort-chinese/src/make.bat | 66 +- .../latex/lshort-chinese/src/preface.contrib.tex | 238 ---- .../latex/lshort-chinese/src/preface.overview.tex | 58 - .../latex/lshort-chinese/src/sec.symbol.table.tex | 392 ------- .../doc/latex/lshort-chinese/src/titlepage.tex | 35 - 39 files changed, 6957 insertions(+), 6803 deletions(-) delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/app.A.install.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/app.B.error.help.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/biblio.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.01.basics.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.02.text.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.03.elements.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.04.math.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.05.style.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.06.spec.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.07.graphic.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap.08.custom.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.A.install.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.B.error.help.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/biblio.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.01.basics.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.02.text.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.03.elements.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.04.math.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.05.style.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.06.spec.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.07.graphic.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.08.custom.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/fdl.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.contrib.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.overview.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/sec.symbol.table.tex create mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/chap/titlepage.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/fdl.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/preface.contrib.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/preface.overview.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/sec.symbol.table.tex delete mode 100644 Master/texmf-dist/doc/latex/lshort-chinese/src/titlepage.tex (limited to 'Master/texmf-dist/doc/latex/lshort-chinese') diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/README-zh.md b/Master/texmf-dist/doc/latex/lshort-chinese/README-zh.md index cb8b69d0410..eda9fdcecc2 100644 --- a/Master/texmf-dist/doc/latex/lshort-chinese/README-zh.md +++ b/Master/texmf-dist/doc/latex/lshort-chinese/README-zh.md @@ -1,4 +1,4 @@ -# 中文版 lshort,6.01 版 +# 中文版 lshort,6.02 版 ## 许可证 @@ -12,8 +12,9 @@ ### 手动编译 -在 src 目录下按照以下顺序编译: -``` +在 `src` 目录下按照以下顺序编译: + +```sh xelatex lshort-zh-cn makeindex -s lshort-zh-cn.ist lshort-zh-cn xelatex lshort-zh-cn @@ -24,14 +25,15 @@ xelatex lshort-zh-cn ### 使用脚本和 Makefile 编译 -Linux 下提供了 GNU make 可用的 Makefile,使用 GNU make 的顺序为: -``` +对于 GNU/Linux 或 macOS 用户,我们提供了 GNU make 所需的 Makefile,在 `src` 目录下执行以下命令进行编译: + +```sh make make install ``` -Windows 下在 src 目录提供批处理脚本 `make.bat`,双击执行编译。 +对于 Windows 用户,我们也在 `src` 目录提供了批处理脚本 `make.bat`,双击进行编译。 ### 使用 latexmk 编译 -在 src 目录下提供了供 `latexmk` 构建工具使用的配置文件 `latexmkrc`。在 src 目录下执行 `latexmk` 命令进行编译,完成后将 PDF 文件移动到根目录。 \ No newline at end of file +在 `src` 目录下有可供 `latexmk` 构建工具使用的配置文件 `latexmkrc`。在 `src` 目录下执行 `latexmk` 命令进行编译,完成后将 PDF 文件移动到根目录。 diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/README.md b/Master/texmf-dist/doc/latex/lshort-chinese/README.md index ecfe6062ca2..a6de7cfc1d5 100644 --- a/Master/texmf-dist/doc/latex/lshort-chinese/README.md +++ b/Master/texmf-dist/doc/latex/lshort-chinese/README.md @@ -1,4 +1,4 @@ -# The Not So Short Introduction To LaTeX (Chinese Edition), v6.01 +# The Not So Short Introduction To LaTeX (Chinese Edition), v6.02 ## License @@ -6,6 +6,7 @@ This document is distributed under the **GNU Free Documentation License, version For detailed information, see the section entitled 'GNU Free Documentation License' in the document, or the source code file `fdl.tex`. ## Preparation for typesetting + Update `ctex` and `xeCJK` (and all the packages they rely on) in your TeX distritusion. And make sure you've installed all the other packages used in `lshort-zh-cn-style.sty` and updated them to the newest version. @@ -13,8 +14,9 @@ all the other packages used in `lshort-zh-cn-style.sty` and updated them to the ### Manually typesetting -In 'src' directory, typeset the source code in the following order: -``` +In `src` directory, typeset the source code in the following order: + +```sh xelatex lshort-zh-cn makeindex -s lshort-zh-cn.ist lshort-zh-cn xelatex lshort-zh-cn @@ -25,14 +27,15 @@ If typesetting succeeds and the target PDF document is made correctly, then move ### Using scripts and Makefile -For GNU/Linux and OS/X users, we provide Makefile in the 'src' directory. Use GNU make tool in the following order: -``` +For GNU/Linux and macOS users, we provide Makefile in the `src` directory. Use GNU make tool in the following order: + +```sh make make install ``` -For Windows users, we also provide a batch file `make.bat` in the 'src' directory, which you can double-click to do the typesetting. +For Windows users, we also provide a batch file `make.bat` in the `src` directory, which you can double-click to do the typesetting. ### Using latexmk -We also provide `latexmkrc` configuration file for building with `latexmk` tool. Run the command `latexmk` in `src` directory for typesetting, then move the PDF document to the root directory. \ No newline at end of file +We also provide `latexmkrc` configuration file for building with `latexmk` tool. Run the command `latexmk` in `src` directory for typesetting, then move the PDF document to the root directory. diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/lshort-zh-cn.pdf b/Master/texmf-dist/doc/latex/lshort-chinese/lshort-zh-cn.pdf index b8c28394a77..291e3080341 100644 Binary files a/Master/texmf-dist/doc/latex/lshort-chinese/lshort-zh-cn.pdf and b/Master/texmf-dist/doc/latex/lshort-chinese/lshort-zh-cn.pdf differ diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/INSTRUCTIONS.md b/Master/texmf-dist/doc/latex/lshort-chinese/src/INSTRUCTIONS.md index fa493e575a2..a441c6470b6 100644 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/INSTRUCTIONS.md +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/INSTRUCTIONS.md @@ -1,35 +1,44 @@ # 中文版 lshort 代码用到的命令 -### 约定俗成的习惯 +## 约定俗成的习惯 -1. 命令后面用 `\␣` 加空格,如 `\LaTeX\␣`,不用 `\LaTeX{}␣`。 -2. 每章的 `\chapter` 命令后手动给 `.los` 目录写间距: +1. 在控制序列后面显式加空格时使用空分组 `{}`,如 `\LaTeX{} 命令`。 +2. TeX 专有术语尽量使用 `\hologo` 宏排版。 +3. 每章的 `\chapter` 命令后手动给 `.los` 目录写间距: ``` \addtocontents{los}{\protect\addvspace{10pt}} ``` -### 命令和环境 +## LaTeX 术语的表示方式 +### 命令和环境名称 + +用 `\cmd` 和 `\env` 命令生成命令名 `\cmdname` / 环境名 `envname`,以等宽字体排版: ``` \cmd{cmdname} \env{envname} ``` -生成命令名 \cmdname / 环境 envname,等宽字体。cmdname 参数不要带斜杠。 +`cmdname` 参数不要带斜杠。名称内在必要的时候添加 `\-` 控制分词。 + +### 宏包和文档类名称 +用 `\pkg` 和 `\cls` 命令生成宏包和文档类的名称,以无衬线字体排版。 ``` \pkg{pkgname} \cls{clsname} ``` -生成宏包和文档类的名称(无衬线字体)。 +### 命令参数 + +用 `\marg` 命令生成必选参数,用 `\oarg` 命令生成可选参数: ``` \marg{argument} \marg*{argument} \oarg{argument} \oarg*{argument} ``` -命令的必选参数/可选参数,分别为参数自动包裹大括号和中括号。不带星号的版本生成 meta 形式的 <*argument*>。 +生成的参数自动包裹大括号和中括号。不带星号的版本生成 meta 形式的 <*argument*>。 ``` \Arg{argument} @@ -42,12 +51,15 @@ > `\cmd{usepackage}\oarg*{\Arg{key1}=\Arg{value1},\ldots}\marg{pkgname}` +### 其它 + +CTAN 资源的链接使用以下命令: ``` \CTAN|link| ``` -生成 CTAN 资源的链接。参数 link 为链接的子目录名称,如 systems/win32/miktex,macros/contrib/... 等。 +参数 `link` 为链接的子目录名称,如 `systems/win32/miktex`,`macros/contrib/...` 等。 -### 索引 +## 索引 ``` \cmdindex{cmdname} @@ -55,8 +67,8 @@ \envindex{envname} \envindex[pkgname]{envname} ``` -命令和环境的索引项。LaTeX 基本命令用不带可选参数的形式;宏包/文档类的命令在可选参数里指定宏包名称。 -cmdname 和 envname 可写多个命令和环境名,以逗号分隔(唯一例外的是 `\,` 命令)。 +命令和环境的索引项。TeX 原始命令、LaTeX 内核和标准文档类命令用不带可选参数的形式;宏包/文档类的命令在可选参数里指定宏包名称。 +`cmdname` 和 `envname` 可写多个命令和环境名,以逗号分隔(唯一例外的是 `\,` 命令)。 ``` \pkgindex{pkgname} @@ -82,7 +94,7 @@ cmdname 和 envname 可写多个命令和环境名,以逗号分隔(唯一例 ``` 汉字索引项,通过拼音参与排序。 -### 排版元素 +## 排版元素 ``` \demowidth{length} diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/app.A.install.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/app.A.install.tex deleted file mode 100644 index 27a4ca2ca55..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/app.A.install.tex +++ /dev/null @@ -1,137 +0,0 @@ -\chapter{安装 \protect\TeX\ 发行版}\label{app:install} - -\begin{intro} -高德纳的 \TeX\ 程序开发于 20 世纪 80 年代,那时候电子计算机的运算能力有限,\TeX\ 还是大型服务器上的玩物。 -而如今个人计算机完全能够胜任排版的工作,并催生了用于个人计算机的工具集合—— \TeX\ 发行版的发展。 - -本章会简单介绍如何安装 \TeX\ 发行版,以及保持发行版的内容紧跟最新。后者非常重要, -因为 \LaTeX\ 宏包是不断更新换代的。 -\end{intro} - -\section{\protect\TeX\ 发行版简介}\label{sec:dists} - -一个\textbf{\TeX\ 发行版}是 \TeX\ 排版引擎、支持排版的文件(基本格式、\LaTeX\ 宏包、字体等)以及一些辅助工具的集合。 -各式各样的 \TeX\ 发行版经过十多年的发展,大浪淘沙,现今的两个主流发行版为: -\begin{itemize} - \item \textbf{\TeX\ Live}\par - \TeX\ Live 由类 UNIX 系统上的 te\TeX\ 发展并取而代之,最终成为跨平台的 \TeX\ 发行版。 - \TeX\ Live 自 2011 年起以年份作为发行版的版本号,保持了一年一更的频率。 - - Mac\TeX\ 是 macOS(OS X)系统下的一个定制化的 \TeX\ Live 版本,与 \TeX\ Live 同步更新。 - - \item \textbf{Mik\TeX}\par - Mik\TeX\ 是主要用于 Windows 平台的一个稳定发展的 \TeX\ 发行版。 - 中国的 \LaTeX\ 用户应该对“C\TeX\ 套装”比较熟悉,它是一个经过本地化配置的 Mik\TeX 。 -\end{itemize} - -\TeX\ Live 和 Mik\TeX\ 都集成了一个简单的 \LaTeX\ 源代码编辑器 \TeX works(Mac\TeX\ 则集成了类似的 \TeX shop)。 -用户在安装完毕后,可直接使用 \TeX works 编写和编译 \LaTeX\ 源代码。 - -\subsection{安装发行版}\label{subsec:install-dists} - -\subsubsection{\TeX\ Live} - -\TeX\ Live 的光盘镜像发布于 \url{http://www.tug.org/texlive/}% -\footnote{Linux 发行版的软件源也提供 \TeX\ Live 的安装,不过不够完整,更新也不是很及时。建议直接从镜像安装。}。 -下载镜像到本地,挂载到虚拟光驱,或者用压缩工具解压后,在其根目录有几个用于安装的脚本: -\begin{itemize} - \item 用于 Windows 的批处理文件: - \begin{itemize} - \item \texttt{install-tl-windows.bat} 双击启动图形界面安装程序(简单安装); - \item \texttt{install-tl-advanced.bat} 双击启动图形界面安装程序(定制安装); - \item 在命令提示符中输入 \texttt{install-tl-windows.bat -no-gui} 启动文本界面安装程序。 - \end{itemize} - \item 用于 Linux 的 Perl 脚本 \texttt{install-tl} : - \begin{itemize} - \item \texttt{install-tl} 启动文本界面安装程序; - \item \texttt{install-tl -gui=wizard} 启动图形界面安装程序(简单安装); - \item \texttt{install-tl -gui=peritk} 启动图形界面安装程序(定制安装)。 - \end{itemize} -\end{itemize} -另外也可以下载在线安装程序 \texttt{install-tl.zip},包含以上所有安装脚本。安装过程中会从 CTAN 软件源下载所有组件。 - -Linux 下 \TeX\ Live 安装完毕后,一般还需要在 root 权限下进行以下操作,使得 \hologo{XeLaTeX} 能正确通过 \pkg{fontspec} -等宏包使用字体\footnote{\url{http://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf},% -可用 \texttt{texdoc texlive-zh-cn} 在本地打开。}: -\begin{enumerate} - \item 将 \texttt{texlive-fontconfig.conf} 文件复制到 \texttt{/etc/fonts/conf.d/09-texlive.conf}。 - \item 运行 \texttt{fc-cache -fsv}。 -\end{enumerate} - -\subsubsection{Mik\TeX} -从 Mik\TeX\ 官网 \url{http://www.miktex.org/} 下载名为 \texttt{basic-miktex-***.exe} 的 Windows 安装程序包。 -下载后直接双击打开,按照程序的提示进行安装即可。 - -\section{安装和更新宏包}\label{sec:pkg-manager} - -\TeX\ Live 提供了图形界面的宏包管理器 \TeX\ Live Manager 用于安装和更新宏包,而 Mik\-\TeX\ 也提供了管理器 -Mik\-\TeX\ Package Manager。用户可直接打开程序,进行宏包的安装和更新 -(Mik\-\TeX\ Package Manager 有普通权限和管理员权限的版本,建议总是使用管理员权限的版本)。 - -两者也可以通过各自的命令行工具安装和更新宏包: -\begin{verbatim} -% TeX Live 命令行工具 tlmgr 的使用示例 -% 安装/卸载宏包 -tlmgr install -tlmgr remove -% 更新所有宏包(包括 tlmgr 本身) -tlmgr update --all --self -% 列出所有可更新的宏包 -tlmgr update --list -% 指定更新源地址 -% 形如 https://mirrors.tuna.tsinghua.edu.cn/CTAN -tlmgr repository set /systems/texlive/tlnet -% 查看宏包信息,加 --list 参数可列出宏包的所有文件 -tlmgr info -\end{verbatim} - -\begin{verbatim} -% MikTeX 命令行工具 mpm 的使用示例 -% 建议始终加 --admin 参数使用 -% 安装/卸载宏包 -mpm --admin --install -mpm --admin --uninstall -% 更新所有宏包 -mpm --admin --update -% 列出所有可更新的宏包 -mpm --admin --find-updates -% 指定更新源地址 -mpm --admin --set-repository=/systems/win32/miktex/tm/packages -% 查看宏包信息 -mpm --admin --print-package-info -\end{verbatim} - -\TeX\ Live 默认安装所有宏包,而 Mik\TeX\ 的安装程序只包含了 \LaTeX\ 的一些基本宏包。从 \TeX\ Live 的光盘镜像和 Mik\-\TeX\ 的安装包体积可见一斑。 -默认情况下,编译过程中如果遇到宏包未安装而报错的情况下,Mik\TeX\ 会弹出一个对话框,让用户可以选择临时安装宏包,安装成功后继续编译。 - -\subsection{手动安装宏包}\label{subsec:pkg-manual-install} - -\textbf{\textcolor{red}{如非万不得已,尽量不要手动安装宏包}}。绝大多数宏包都已打包到 \TeX\ Live 和 Mik\TeX\ 两大发行版的安装源, -可用宏包管理器安装。如果你知道某个宏包的名称,但不确定是否在发行版中已打包,可在 CTAN 中搜索。 - -如果确实有手动安装宏包的需要,本小节的内容将有所帮助。在手动安装之前,有必要了解一下 \TeX\ 目录结构(\TeX\ Directory Structure, TDS)。 -它是 \TeX\ 发行版中宏包、字体、帮助文档等文件的组织结构。TDS 有时也称为 TEXMF 树,取 \TeX$+$\hologo{METAFONT} 之意。 - -以 \TeX\ Live 为例,假设系统的 TEXMF 树根目录为 \nolinkurl{C:\\texlive\\2015\\texmf-dist},其下有很多子目录,仅举几例: -\begin{description} - \item[\texttt{tex/latex}] \LaTeX\ 宏包。 - \item[\texttt{doc/latex}] \LaTeX\ 宏包的帮助文档。 - \item[\texttt{source/latex}] \LaTeX\ 宏包的源代码。 - \item[\texttt{bibtex}] \hologo{BibTeX} 工具相关文件,许多宏包配套的 \hologo{BibTeX} 格式文件位于子目录 \texttt{bst} 中。 - \item[\texttt{fonts/tfm}] \TeX\ 使用的字体文件,TFM 格式。 - \item[\texttt{fonts/type1}] PostScript 字体文件(Type1),PFB 格式。 - \item[\texttt{fonts/opentype}] OpenType 格式的字体文件。 -\end{description} - -需要手动安装的宏包,一般已经按照上述目录结构打包完成。手动安装时,尽量不要拷贝到系统的 TEXMF 树,而是拷贝到发行版提供的用户 TEXMF 树,如 -\TeX Live 的 \nolinkurl{C:\\texlive\\texmf-local}。安装完成后,还需\textbf{刷新 \TeX\ 发行版的文件名数据库},令新安装的宏包文件能够被系统找到。 -\TeX\ Live 用户须在 Windows 命令行或者 Linux 终端执行命令: -\begin{verbatim} -mktexlsr -\end{verbatim} -Mik\TeX\ 用户的命令为: -\begin{verbatim} -initexmf --update-fndb -\end{verbatim} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/app.B.error.help.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/app.B.error.help.tex deleted file mode 100644 index d96c53ed030..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/app.B.error.help.tex +++ /dev/null @@ -1,246 +0,0 @@ -\chapter{排除错误、寻求帮助}\label{chap:error-helps} - -\begin{intro} -\LaTeX\ 入门用户总会为两大问题头疼:我写的代码到底哪里出错了?如果想要实现某种用法该怎么办? -本章首先总结了常见的 \LaTeX\ 错误及应对的办法。 -\end{intro} - -\section{\LaTeX\ 错误}\label{sec:errors} - -当我们用排版引擎编译 \LaTeX\ 代码时,命令行的窗口(终端)会显示大量信息(\TeX works 等编辑器会有一个区域显示这些信息)。 -当编译过程中出现错误时,信息将会停止在出错的地方,等待我们接下来的操作。 - -比如说我们有一个明显出错的例子: -\begin{verbatim} -\documentclass{article} -\begin{document} -Test \LaTEx{} and it's friends. -\end{document} -\end{verbatim} - -编译过程中遇到这个错误将会停顿下来,提示错误,并等待用户输入指令: -\begin{verbatim} -! Undefined control sequence. -l.3 Test \LaTEx - {} and it's friends. -\end{verbatim} - -这种错误信息分两部分,前一部分提示了错误的信息,后一部分指出了错误发生的行号, -以及通过错落的文字告知发生错误的命令所在位置。如上错误显示 \cmd{LaTEx} 位置发生了错误,错误信息是“未定义的控制序列”, -意思是 \cmd{LaTEx} 是 \TeX\ 编译器无法识别的一个命令,很显然是我们把 \cmd{LaTeX} 的大小写写错了。 - -\subsubsection{处理方式} - -出现错误时,编译过程将暂停,等待用户输入命令。用户可以直接敲回车跳过当前的错误,继续编译,相当于丢掉了写错的命令, -将``Test and it's friends.''排版出来。但这个例子过于简单,有些复杂的代码中,有可能会由于一个小问题导致一连串的错误。 -此时可以选择按 \textbf{S/R/Q} 选择跳过接下来的所有错误,或者按 \textbf{X} 直接退出编译,将源代码中的错误修改后重新编译。 - -\subsubsection{常见的 \LaTeX\ 错误信息} - -笔者在此总结一些经常发生、问题比较明确的 \LaTeX\ 错误: - -\long\def\LaTeXerror#1{\begingroup\color{red}\bfseries\ttfamily{}#1\endgroup} - -\begin{itemize} -\item \LaTeXerror{! Undefined control sequences.} - -使用了未定义的命令。拼写错误是原因之一,如把 \cmd{LaTeX} 写作 \cmd{Latex} 这样。 -也有可能是没有调用某个宏包,但用了该宏包定义的命令。 - -\item \LaTeXerror{! LaTeX error: Environment \ldots\ undefined.} - -使用了未定义的环境。 - -\item \LaTeXerror{! Missing \$ inserted.} - -缺少数学环境的符号 \texttt\$。多由于将数学符号用在公式之外而导致。 - -\item \LaTeXerror{Runaway argument? \\ - ! Paragraph ended before \ldots\ was complete.} - -\item \LaTeXerror{! File ended while scanning definition/use of \ldots} - -这两个错误主要是由于漏写了包裹命令参数的花括号,导致识别参数时出现错误。许多编辑器的括号配对功能有助于检查和消除这类错误。 - -这类错误还有可能是由于前一次编译中断导致 \texttt{.aux} 等辅助文件不完整,再次编译读入不完整的文件产生错误。解决办法是删除辅助文件并重新编译。 - -\item \LaTeXerror{! Extra alignment tab has been changed to \cmd{cr}.} - -\item \LaTeXerror{! Misplaced \cmd{noalign}.} - -两个错误信息都与表格有关。 -\begin{itemize} - \item 前者的字面意义是“一行中使用的列分隔符 \texttt\& 太多”,有时可能确实是 \texttt\& 的个数和列格式不匹配, - 但多数情况是漏掉了行尾的 \crcmd\ 命令。 - \item 后者常出现于漏掉了行尾的 \crcmd\ 命令而接着使用 \cmd{hline} 命令画横线的时候。 -\end{itemize} - -\item \LaTeXerror{! LaTeX Error: Lonely \cmd{item}-{}-perhaps a missing list environment.} - -\item \LaTeXerror{! LaTeX Error: Something's wrong-{}-perhaps a missing \cmd{item}.} - -两个错误信息都与列表环境和 \cmd{item} 命令有关。前者意味着在没有使用列表环境的情况下用了 \cmd{item}; -后者则相反,是在列表环境中漏了 \cmd{item}。 - -\item \LaTeXerror{! I can't find file `\ldots'.} - -\item \LaTeXerror{! LaTeX Error: File `\ldots' not found.} - -两个错误都意味着缺少文件。 -\begin{itemize} - \item 如果使用 \cmd{input} 或者 \cmd{include} 命令添加文件,出现上述错误的原因当然是文件不存在或者文件名不对; - \item 如果错误提示里的文件名带 \texttt{.cls} 或者 \texttt{.sty} 扩展名,那么很显然,是因为\textbf{没有安装所需的宏包或文档类}。 -\end{itemize} - -\item \LaTeXerror{! LaTeX Error: Missing \cmd{begin}\marg*{document}.} - -字面上是缺少 \cmd{begin}\marg*{docu\-ment},实际上往往是由于在 \cmd{begin}\marg*{docu\-ment} 之前(导言区)输入了文字或某些命令。 - -\item \LaTeXerror{! LaTeX Error: Cam be used only in preamble.} - -与上一条相反,由于将必须用于导言区的命令在 \cmd{begin}\marg*{docu\-ment} 之后使用而产生。 - -\item \LaTeXerror{! LaTeX Error: \cmd{begin}\marg*{\ldots} on input line \ldots\ ended by \cmd{end}\marg*{\ldots}.} - -环境首尾不匹配。比如 \cmd{begin}\marg*{enumerate} 用了 \cmd{end}\marg*{itemize} 结尾。或者也可能是由于漏写了 \cmd{begin} -或者 \cmd{end} 命令。 - -\item \LaTeXerror{! LaTeX Error: Option clash for package `\ldots'.} - -以\textbf{不同选项}重复调用宏包造成冲突。有可能是因为其它宏包内部事先调用了这个宏包,用户再次带选项调用而导致冲突。 -解决问题的办法是去掉重复调用的宏包。如果宏包允许的话,尽量使用其定义的命令改变设置,减少宏包选项的使用。 - -\item \LaTeXerror{! LaTeX Error: Command \ldots\ already defined, \\ - or name \cmd{end}\ldots\ illegal \ldots} - -使用 \cmd{newcommand} 或 \cmd{newenvironment} 定义已有的命令/环境时产生的错误。如果自己确实作了定义,可考虑用 -\cmd{re\-new\-command} 或 \cmd{re\-new\-environment} 定义;如果是宏包定义的命令产生了这个错误,则属于隐性的宏包冲突。 - -相比之前的 ``Option Clash''{},隐性宏包冲突是更难以解决的问题,对各种宏包不熟悉的用户,尤其是使用模板的用户而言,往往难以下手。 -用户可尝试查找引起冲突的宏包的帮助文档。详尽的手册里通常会告知用户这个宏包应当在某个宏包的前面/后面调用,或者不能与某个宏包一起调用。 -如果是模板调用了大量宏包导致冲突,可联系模板的作者解决。 - -\item \LaTeXerror{! LaTeX Error: Unknown option `\ldots' for package `\ldots'.} - -调用宏包时指定了不能被其识别的选项。此时应该查找宏包的帮助文档来解决问题。 - -\item \LaTeXerror{! Package `\ldots' error: \ldots} - -宏包或文档类自定义的错误,由于不正确地使用宏包里的命令而导致。此时应该查找宏包的帮助文档来解决问题。 - -\end{itemize} - -\section{查找帮助文档}\label{sec:texdoc} - -\index{texdoc@\texttt{texdoc} 工具} -无论是 \TeX\ Live 还是 Mik\TeX\ ,提供了一个命令行模式的程序 \texttt{texdoc}。 -比如对 \ref{subsec:fancyhdr} 小节的 \pkg{fancyhdr} 宏包感兴趣,这时在 Windows 命令提示符或者 Linux 终端输入以下命令, -则会弹出宏包的帮助文档 \texttt{fancyhdr.pdf}: -\begin{verbatim} -texdoc fancyhdr -\end{verbatim} - -除了宏包的帮助文档外,\TeX\ 发行版还包括了各类有用的文档,有一部分在参考文献中给出。 - -如果不熟悉命令行工具的话,\TeX\ Live 提供了一个图形界面的程序 TeXdoc GUI。打开后,可以看到程序里的许多按钮,分别代表某一类的帮助文档。 -除此之外,点击 File Search 弹出搜索框,输入想要搜索的宏包和文件并按回车键,TeXdoc GUI 会弹出它搜索到的所有结果,可点击任意一项来打开文档。 - -当然对于初学者,有一个现实而棘手的问题:\textbf{某个命令到底是 \LaTeX\ 自有的,还是哪个宏包提供的?} -很遗憾地说,除了通过慢慢积累、熟悉较多宏包之外,没有很方便的办法解决这个问题,因为 \LaTeX\ 的宏包实在太丰富了。 -本手册末尾的索引给出了所有在本手册见到的命令和环境,其中哪些命令和环境需要调用哪个宏包才能使用,一目了然。但是这个索引远远不够。 - -解决这个问题有几点可行的办法: -\begin{enumerate} - \item 查询一些综述性的资料,如总结所有 \LaTeX\ 自带命令的文档 \cite{latex2e}、\LaTeX\ 符号大全 \cite{symbols} 等; - \item 在互联网上搜索自己不清楚的命令; - \item 在论坛上提问求助有经验的人。 -\end{enumerate} - -\section{常用宏包简介}\label{sec:pkg-list} - -\def\pkglabel#1{\makebox[60pt][l]{\pkg{#1}}} -\newenvironment{pkglist}% - {\list{}{% - \labelwidth=60pt - \itemindent=0pt - \leftmargin=60pt - \labelsep=0pt - \let\makelabel\pkglabel}}% - {\endlist} - -此处不包含设置字体或数学符号的宏包,它们已经在表 \ref{tbl:font-pkgs} 中列出。 - -\subsection{文字、公式和符号}\label{subsec:text-math-symbols} - -\begin{pkglist} - \item[amsmath] \AmS\ 数学公式扩展。 - \item[mathtools] 数学公式扩展宏包,提供了公式编号定制和更多的符号、矩阵等。 - \item[amsfonts] \AmS\ 扩展符号的基础字体支持。 - \item[amssymb] 在 \pkg{amsfonts} 基础上将 \AmS\ 扩展符号定义成命令。 - \item[bm] 提供将数学符号加粗的命令 \cmd{bm}。 - \item[siunitx] 以国际单位规范排版物理量的单位。 - \item[mhchem] 排版化学式和方程式。 - \item[tipa] 排版国际音标。 -\end{pkglist} - -\subsection{排版元素}\label{subsec:pkg-elements} - -\begin{pkglist} - \item[ulem] 提供排版可断行下划线的命令 \cmd{uline} 以及其它装饰文字的命令。 - \item[endnote] 排版尾注。 - \item[marginnote] 改善的边注排版功能。 - \item[multicol] 提供将内容自由分栏的 \env{multicols} 环境。 - \item[multitoc] 生成多栏排版的目录。 - \item[minitoc] 为章节生成独立的小目录。 - \item[glossaries] 生成词汇表。 - \item[verbatim] 对原始的 \env{verbatim} 环境的改善。提供了命令 \cmd{verbatim\-input} 调用源文件。 - \item[fancyvrb] 提供了代码排版环境 \env{Verbatim} 以及对版式的自定义。 - \item[listings] 提供了排版关键字高亮的代码环境 \env{lst\-listing} 以及对版式的自定义。类似宏包有 \pkg{minted}。 - \item[algorithmic] 一个简单的实现算法排版的宏包。如果要生成浮动体的话,需要搭配 \pkg{algorithm} 宏包使用。 - \item[algorithm2e] 较为复杂的、可定制的算法排版宏包。类似宏包有 \pkg{algorithmicx} 等。 - \item[ntheorem] 定制定理环境。类似宏包包括 \pkg{theorem}、\pkg{thmtools}、\pkg{amsthm} 等。 - \item[mdframed] 排版可自动断页的带边框文字段落,提供边框样式的定制功能。 - \item[tcolorbox] 以 \TikZ\ 为基础提供排版样式丰富的彩色盒子的功能。 -\end{pkglist} - -\subsection{图表和浮动体}\label{subsec:pkg-tab-fig} - -\begin{pkglist} - \item[booktabs] 排版三线表。 - \item[array] 对表格列格式的扩展。 - \item[tabularx] 提供 \env{tabularx} 环境排版定宽表格,支持自动计算宽度的 X 列格式。 - \item[arydshln] 支持排版虚线表格线。 - \item[colortbl] 支持修改表格的行、列、单元格的颜色。 - \item[multirow] 支持合并多行单元格。 - \item[makecell] 支持在单元格里排版多行内容(嵌套一个单列的小表格)。 - \item[diagbox] 排版斜线表头。 - \item[longtable] 提供排版跨页长表格的 \env{longtable} 环境。 - \item[ltxtable] 跨页长表格可使用 \env{tabularx} 的 X 列格式。 - \item[tabu] 提供排版复杂格式表格的 \env{tabu} 环境。与 \pkg{longtable} 一同调用时,提供排版复杂格式跨页长表格的 \env{longtabu} 环境。 - \item[graphicx] 支持插图。 - \item[bmpsize] \texttt{latex} + \texttt{dvipdfmx} 命令下支持 BMP/JPG/PNG 等格式的位图。 - \item[epstopdf] \texttt{pdflatex} 命令下支持 EPS 格式的矢量图。 - \item[wrapfig] 支持简单的文字在图片周围的绕排。 - \item[subfig] 提供子图表和子标题的排版。类似宏包有 \pkg{subfigure} 和 \pkg{subcaption} 等。 - \item[caption] 控制浮动体标题的格式。 - \item[bicaption] 生成双语浮动体标题。 - \item[float] 为浮动体提供不浮动的 H 模式;提供自定义浮动体结构的功能。 -\end{pkglist} - -\subsection{修改版式}\label{subsec:pkg-layout} - -\begin{pkglist} - \item[geometry] 修改页面尺寸、页边距、页眉页脚等参数。 - \item[fancyhdr] 修改页眉页脚格式,令页眉页脚可以左对齐、居中、右对齐。 - \item[titlesec] 修改章节标题 \cmd{chapter}、\cmd{section} 等的格式。 - \item[titletoc] 修改目录中各条目的格式。 - \item[tocloft] 类似 \pkg{titletoc} 的修改目录条目格式的宏包。 - \item[tocbibind] 支持将目录、参考文献、索引本身写入目录项。 - \item[footmisc] 修改脚注 \cmd{footnote} 的格式。 - \item[indentfirst] 令章节标题后的第一段首行缩进。 - \item[enumerate] 提供简单的自定义标签格式的 \env{enumerate} 环境。 - \item[enumitem] 修改列表环境 \env{enumerate} 和 \env{itemize} 等的格式。 - \item[lettrine] 生成段落首字母大写的效果。 -\end{pkglist} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/biblio.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/biblio.tex deleted file mode 100644 index 124b5d19023..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/biblio.tex +++ /dev/null @@ -1,103 +0,0 @@ -\begin{thebibliography}{20} - -\item[\S] {\bfseries \LaTeX\ 经典书籍:} - -\bibitem{manual} Leslie Lamport. - \newblock \emph{\LaTeX: A Document Preparation System}, 2nd edition. - \newblock Addison-Wesley, Reading, Massachusetts, 1994, ISBN~0-201-52983-1. - -\bibitem{companion} Frank Mittelbach, Michel Goossens, Johannes Braams, David Carlisle, Chris Rowley. - \newblock \emph{The \LaTeX\ Companion}, 2nd edition. - \newblock Addison-Wesley, Reading, Massachusetts, 2004, ISBN~0-201-36299-6. - -\bibitem{graphicscompanion} Michel Goossens, Sebastian Rahtz and Frank Mittelbach. - \newblock \emph{The \LaTeX\ Graphics Companion}, 2nd edition. - \newblock Addison-Wesley, Reading, Massachusetts, 1997, ISBN~0-301-50892-0. - -\bibitem{guide2latex} Helmut Kopka and Patrick~W. Daly, - \newblock \emph{Guide to \LaTeX}, 4th edition. - \newblock Addison-Wesley, Reading, Massachusetts, 2004, ISBN~0-321-17385-6. - -\bibitem{leoliu} 刘海洋. - \newblock \emph{\LaTeX\ 入门}. - \newblock 电子工业出版社, 北京, 2013, ISBN~978-7-121-20208-7. - -\item[\S] {\bfseries \TeX\ 经典书籍,介绍底层的命令和排版方式,有志深入学习 \LaTeX\ 者或参与宏包开发者必读。有一些书籍已经开放网络资源:} -\bibitem{texbook} Donald~E. Knuth. - \newblock \emph{The \TeX book}, Volume~A of \textit{Computers and Typesetting}, 2nd edition. - \newblock Addison-Wesley, Reading, Massachusetts, 1984, ISBN~0-201-13448-9. - -\bibitem{impatient} Paul Abrahams, Kathryn A. Hargreaves, Karl Berry. - \newblock \emph{\TeX\ for the impatient}, 2nd edition. - \newblock Addison-Wesley, Reading, Massachusetts, 1984, ISBN~0-201-51375-7. \\ - \CTAN|info/impatient/book.pdf| (\texttt{texdoc impatient}) - -\bibitem{texbytopic} Victor Eijkhout. - \newblock \emph{\TeX\ by Topic, A \TeX nician's Reference}. - \newblock Addison-Wesley, Reading, Massachusetts, 1992, ISBN~0-201-56882-9. \\ - \CTAN|info/texbytopic/TeXbyTopic.pdf| (\texttt{texdoc texbytopic}) - -\item[\S] {\bfseries \TeX\ 发行版内置的资源(除宏包帮助手册之外的一些文档), - 可以在本地使用 \texttt{texdoc} 命令查找,也可以在 CTAN 上找到:} - -\bibitem{usrguide} \LaTeX3 Project Team. - \newblock \emph{\LaTeXe\ for authors}.\\ - \CTAN|macros/latex/doc/usrguide.pdf| (\texttt{texdoc usrguide}) - -\bibitem{clsguide} \LaTeX3 Project Team. - \newblock \emph{\LaTeXe\ for class and package writers}. \\ - \CTAN|macros/latex/doc/clsguide.pdf| (\texttt{texdoc clsguide}) - -\bibitem{fntguide} \LaTeX3 Project Team. - \newblock \emph{\LaTeXe\ font selection}. \\ - \CTAN|macros/latex/doc/fntguide.pdf| (\texttt{texdoc fntguide}) - -\bibitem{latex2e} Karl Berry, Jim Hefferon, Vincent Bela\"{\i}che. - \newblock \emph{\LaTeXe: An unofficial reference manual}. \\ - \CTAN|info/latex2e-help-texinfo/latex2e.pdf| (\texttt{texdoc latex2e}) - -\bibitem{uk-tex-faq} The UK TeX users group (TUG). - \newblock \emph{The UK TeX FAQ}. - \newblock HTML version on \url{https://texfaq.org/}. \\ - \CTAN|help/uk-tex-faq/newfaq.pdf| (\texttt{texdoc faq}) - -\bibitem{l2tabu} J\"{u}rgen Fenn. - \newblock \emph{An essential guide to \LaTeXe\ usage: Obsolete commands and packages} (English translation). \\ - \CTAN|info/l2tabu/english/l2tabuen.pdf| (\texttt{texdoc l2tabuen}) - -\bibitem{symbols} Scott Pakin. - \newblock \emph{The Comprehensive \LaTeX\ Symbol List}. \\ - \CTAN|info/symbols/comprehensive/symbols-a4.pdf| (\texttt{texdoc symbols-a4}) - -\bibitem{cheatsheet} Winston Chang. - \newblock \emph{\LaTeXe\ Cheat Sheet}. \\ - \CTAN|info/latexcheat/latexcheat/latexsheet.pdf| (\texttt{texdoc latexcheat}) - -\item[\S] {\bfseries CTAN 上的其它网络资源:} - -\bibitem{catalogue} Graham Williams. - \newblock \emph{The \TeX\ Catalogue (Preface CTAN Edition)}.\\ - \CTAN|help/Catalogue/catalogue.html| - -\bibitem{survey} Stephen~G. Hartke. - \newblock \emph{A Survey of Free Math Fonts for \TeX\ and \LaTeX}.\\ - \CTAN|info/Free_Math_Font_Survey/survey.pdf| - -\item[\S] {\bfseries 其它网络渠道可获得的资源:} - -\bibitem{fontcatalogue} Palle J{\o}rgensen. - \newblock \emph{The \LaTeX\ font catalogue}, a font catalogue of \LaTeX\ font packages.\\ - \url{http://www.tug.dk/FontCatalogue/} - -\bibitem{ltxprimer} Indian \TeX\ users group. - \newblock \emph{\LaTeX\ Tutorials: A primer}. \\ - \url{http://www.tug.org/twg/mactex/tutorials/ltxprimer-1.0.pdf} - -\bibitem{lnotes} 黄新刚. - \newblock \emph{雷太赫排版系统简介(\LaTeX\ Notes)}, 第二版. \\ - \url{http://dralpha.altervista.org/zh/tech/lnotes2.pdf} \\ - (旧版可用 \texttt{texdoc latex-notes-zh-cn}) - -\end{thebibliography} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.01.basics.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.01.basics.tex deleted file mode 100644 index 5a1bf17a8b4..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.01.basics.tex +++ /dev/null @@ -1,399 +0,0 @@ -\chapter{\LaTeX\ 的基本概念}\label{chap:basics} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -欢迎使用 \LaTeX{}!本章开头用简短的篇幅介绍了 \LaTeX\ 的来源, -然后介绍了 \LaTeX\ 源代码的写法,如何编译 \LaTeX\ 源代码生成文档,以及理解接下来的章节所必须的一些知识。 -\end{intro} - -\section{概述}\label{sec:intro} - -\subsection{\protect\TeX}\label{subsec:tex} - -\index{Knuth@Knuth, Donald E. (\textit{高德纳})} -\index{TeX@\TeX} -\TeX\ 是高德纳 (Donald E.~Knuth) 开发的、以排版文字和数学公式为目的的软件\cite{texbook}。 -1977 年,正在编写著作《计算机程序设计艺术》的高德纳,意图扭转排版质量每况愈下的状况,以免影响他的出书, -于是开始开发 \TeX{},以发掘当时开始用于出版工业的数字印刷设备的潜力。 -\TeX\ 排版引擎发布于 1982 年,在 1989 年又加以改进以更好地支持 8-bit 字符和多语言排版。 -\TeX\ 以其卓越的稳定性、跨平台、几乎没有 bug 而著称。\TeX\ 的版本号不断趋近于 $\pi$,当前为 3.141592653。 - -\TeX\ 读作 ``Tech'' ,其中 ``ch'' 的发音类似于 ``h'' ,与汉字“泰赫”的发音相近。\TeX\ 的拼写来自希腊词语 -τεχνική (technique,技术) 的开头几个字母。在 ASCII 字符环境,\TeX\ 写作 \texttt{TeX}。 - -\subsection{\LaTeX}\label{subsec:latex} - -\index{LaTeX@\LaTeX} -\index{LaTeX2e@\LaTeXe} -\LaTeX\ 是一种格式(format)。为免误会,初次接触这一概念的读者可以粗略地将 \LaTeX\ 理解成是对 \TeX\ 的一层封装。 -\LaTeX\ 使用 \TeX\ 程序作为自己的排版引擎。 -\LaTeX\ 最初的设计目标是分离内容与格式,以便作者能够无需关注版式设计,只需专注与内容创作就能得到高质量排版的作品。 -最初的开发者是 Leslie Lamport 博士\cite{manual},当前 \LaTeX\ 由 \LaTeX 3 工作组% -\footnote{\url{https://www.latex-project.org}}维护。 - -\LaTeX\ 读作 ``Lah-tech'' 或者 ``Lay-tech'' ,与汉字“拉泰赫”或“雷泰赫”的发音相近。\LaTeX\ 在 ASCII 字符环境写作 \texttt{LaTeX}。 -当前的 \LaTeX\ 版本为 \LaTeXe ,意思是超出了第二版,但还远未没达到第三版,在 ASCII 字符环境写作 \texttt{LaTeX2e}。 - -\subsection{\LaTeX\ 的优缺点}\label{subec:advs} - -经常有人喜欢对比 \LaTeX\ 和以 Microsoft Office Word 为代表的“所见即所得”% -(What You See Is What You Get)字处理工具。 -这种对比是没有意义的,因为 \TeX\ 是一个排版引擎,\LaTeX\ 是其封装,而 Word 是字处理工具。 -二者的设计目标不一致,也各自有自己的适用范围。 - -不过,这里仍旧总结 \LaTeX\ 的一些优点: -\begin{itemize} - \item 具有专业的排版输出能力,产生的文档看上去就像“印刷品”一样。 - \item 具有方便而强大的数学公式排版能力,无出其右者。 - \item 绝大多数时候,用户只需专注于一些组织文档结构的基础命令,无需(或很少)操心文档的版面设计。 - \item 很容易生成复杂的专业排版元素,如脚注、交叉引用、参考文献、目录等。 - \item 强大的可扩展性。世界各地的人开发了数以千计的 \LaTeX\ 宏包用于补充和扩展 \LaTeX\ 的功能。 - 本手册附录中的 \ref{sec:pkg-list} 小节可见一瞥。更多的宏包参考 \textit{The \LaTeX\ companion}\cite{companion}。 - \item 能够促使用户写出结构良好的文档——而这也是 \LaTeX\ 存在的初衷。 - \item \LaTeX\ 和 \TeX\ 及相关软件是跨平台、免费、开源的。 - 无论用户使用的是 Windows,macOS(OS X),GNU/Linux 还是 FreeBSD 等操作系统,都能轻松获得和使用这一强大的排版工具,并且获得稳定的输出。 -\end{itemize} - -\LaTeX\ 的缺点也是显而易见的: -\begin{itemize} - \item 入门门槛高。本手册的副标题叫做 “\pageref{lshort-minutes}~分钟了解 \LaTeXe ”, - 实际上 \pageref{lshort-minutes} 是本手册正文部分(包括附录)的页数。如果你以平均一页一分钟的速度看完了本手册, - 你只是粗窥门径而已,离学会它还很远。 - \item 不容易排查错误。\LaTeX\ 作为一个依靠编写代码工作的排版工具,其使用的宏语言比 C++ 或 Python 等程序设计语言在错误排查方面困难得多。 - 它虽然能够提示错误,但不提供调试的机制,有时错误提示还很难理解。 - \item 不容易定制样式。\LaTeX\ 提供了一个基本上良好的样式,为了让用户不去关注样式而专注于文档结构。 - 但如果想要改进 \LaTeX\ 生成的文档样式则是十分困难。 - \item 相比“所见即所得”的模式有一些不便,为了查看生成文档的效果,用户总要不停地编译。 -\end{itemize} - -\section{第一次使用 \LaTeX}\label{sec:run} - -源代码~\ref{code:hello-world}~是一份最短的 \LaTeX\ 源代码示例。 - -\begin{sourcecode}[htp] -\begin{Verbatim} -\documentclass{article} -\begin{document} -``Hello world!'' from \LaTeX. -\end{document} -\end{Verbatim} -\caption{\LaTeX\ 的一个最简单的源代码示例。}\label{code:hello-world} -\end{sourcecode} - -这里首先介绍如何编译使用这份源代码,在后续小节中再介绍源代码的细节。 - -你可以将这份源代码保存为~\texttt{helloworld.tex},而后编译。具体来说: -\begin{itemize} - \item 如果使用 \TeX works! 或 \TeX studio 等编辑器,你可以使用编辑器提供的“编译”按钮 - 或者“排版”按钮。建议将编译命令设置为 “XeLaTeX”。 - \item 如果使用命令行方式进行编译,则需打开 Windows 命令提示符或者 Linux / macOS(OS X)的终端,在源代码所在的目录下输入命令: -\begin{verbatim} -xelatex helloworld -\end{verbatim} -\end{itemize} - -如果编译成功,可以在~\texttt{helloworld.tex}~所在的目录, -看到生成的 \texttt{helloworld.pdf} 以及一些其它文件。 - -\section{\LaTeX\ 命令和代码结构}\label{sec:src} - -\LaTeX\ 的源代码为文本文件。这些文本除了文字本身,还包括各种命令, -用在排版公式、划分文档结构、控制样式等等不同的地方。 - -\subsection{\LaTeX\ 命令和环境}\label{subsec:cmds} - -\index{LaTeX macro@\LaTeX\ 命令} -\LaTeX\ 中命令\footnote{也叫作控制序列(control sequence)。}以反斜线 \texttt{\textbackslash} 开头,为以下两种形式之一: -\begin{itemize} - \item 反斜线和后面的一串字母,如 \cmd{LaTeX}。它们以任意非字母符号(空格、数字、标点等)为界限。 - \item 反斜线和后面的单个非字母符号,如 \cmd{\$}。 -\end{itemize} - -要注意 \LaTeX\ 命令是\textbf{对大小写敏感}的,比如输入 \cmd{LaTeX} 命令可以生成错落有致的 \LaTeX\ 字母组合, -但输入 \cmd{Latex} 或者 \cmd{LaTex} 什么都得不到,还会报错;它们与 \cmd{LaTeX} 是不同的命令。 - -字母形式的 \LaTeX\ 命令忽略其后的所有连续空格。 -如果要人为引入空格,需要在命令后面加一对花括号阻止其忽略空格% -\footnote{另外也可以在命令后面紧跟一个 \cmd{\textvisiblespace} 命令(反斜线加空格),代表插入一个间距。 -比如 \cmd{TeX}\cmd{\textvisiblespace}\texttt{user} 的输出效果就是 \TeX\ user。}: -\begin{example} -Shall we call ourselves -\TeX users - -or \TeX{} users? -\end{example} - -\pinyinindex{canshu}{参数} -一些 \LaTeX\ 命令可以接收一些参数,参数的内容会影响命令的效果。 -\LaTeX\ 的参数分为可选参数和必选参数。 -可选参数以方括号 \texttt[ 和 \texttt] 包裹;必选参数一般以花括号 \texttt\{ 和 \texttt\} 包裹% -\footnote{以单个字符作为命令的参数时,可以不加括号。例如,在数学环境下, -\cmd{frac}\texttt{12} 和 \cmd{frac}\texttt{\{1\}\{2\}} 的效果是一样的。}。 -还有些命令可以带一个星号 \texttt*,带星号和不带星号的命令效果有一定差异。 -初次接触这些概念时,可以粗略地把星号看作一种特殊的可选参数。 - -\index{LaTeX environment@\LaTeX\ 环境} -\cmdindex{begin,end} -\LaTeX\ 中还包括\textbf{环境},用以令一些效果在局部生效,或是生成特殊的文档元素。 -\LaTeX\ 环境的用法为一对命令 \cmd{begin} 和 \cmd{end}: -\begin{command} -\cmd{begin}\marg{environment name}\oarg{optional arguments}\marg{mandatory arguments} \\ -\ldots \\ -\cmd{end}\marg{environment name} -\end{command} - -其中 \Arg{environment name} 为环境名,\cmd{begin} 和 \cmd{end} 中填写的环境名应当一致。 -类似命令,\marg{mandatory arguments} 和 \oarg{optional arguments} 为环境所需的必选和可选参数。 -\LaTeX\ 环境可能需要一个或多个必选/可选参数,也可能完全不需要参数。 -部分环境允许嵌套使用。 - -\pinyinindex{fenzu}{分组} -有些命令(如 \cmd{bfseries})会对其后所有内容产生作用。若要限制其作用范围,则需要使用\textbf{分组}。\LaTeX\ 使用一对花括号 \texttt\{ 和 \texttt\} 作为分组,在分组中使用的命令被限制在分组内,不会影响到分组外的内容% -\footnote{个别命令在分组内仍然会产生全局作用,例如第 \ref{sec:counters} 节介绍的 \cmd{setcounter} 等命令。}。 -上文提到的 \LaTeX\ 环境隐含了一个分组,在环境中的命令被包裹在分组内。 -\ref{subsec:fontshape} 和 \ref{subsec:fontsize} 小节中介绍的修改字体和字号的命令用法,即属此类。 - -\subsection{\LaTeX\ 源代码结构}\label{subsec:struct} - -\cmdindex{documentclass} -\pinyinindex{wendanglei}{文档类} -\LaTeX\ 源代码以一个 \cmd{document\-class} 命令作为开头,它指定了文档使用的\textbf{文档类}: -\begin{verbatim} -\documentclass{...} -\end{verbatim} -\cmd{document\-class} 命令有一个可选参数。可选参数会传递给相应的文档类,作为文档类的参数(见 \ref{subsec:classes})。 - -\envindex{document} -\env{document} 环境当中的内容是文档正文。 -\begin{verbatim} -\begin{document} -\section{...} -正文内容…… -\end{document} -\end{verbatim} - -\pinyinindex{daoyanqu}{导言区} -在 \cmd{documentclass} 和 \cmd{begin}\marg*{document} 之间的位置称为\textbf{导言区}。 -在导言区中一般会使用 \cmd{use\-package} 调用宏包,以及会进行对文档的全局设置。 - -\section{\LaTeX\ 宏包和文档类}\label{sec:latex-pkgs} - -本节将仔细解释在 \ref{subsec:struct} 小节中出现的宏包和文档类的概念以及详细用法。 - -\subsection{文档类}\label{subsec:classes} - -\pinyinindex{wendanglei}{文档类} -文档类规定了 \LaTeX\ 源代码所要生成的文档的性质——普通文章、书籍、演示文稿、个人简历等等。\LaTeX\ 源代码的开头须用 -\cmd{document\-class}指定文档类: -\begin{command} -\cmd{documentclass}\oarg{options}\marg{class-name} -\end{command} - -\clsindex{article,book,report} -\clsindex{ctexart,ctexrep,ctexbook} -其中 \Arg{class-name} 为文档类的名称,如 \LaTeX\ 提供的 \cls{article}, \cls{book}, \cls{report}, -在其基础上派生的一些文档类如支持中文排版的 \cls{ctexart} / \cls{ctexbook} / \cls{ctexrep}, -或者有其它功能的一些文档类,如 \cls{moderncv} / \cls{beamer} 等。 -\LaTeX\ 提供的基础文档类见表 \ref{tbl:ltx-classes},其中前三个习惯上称为“标准文档类”。 - -\begin{table}[htp] -\centering -\caption{\LaTeX\ 提供的基础文档类。}\label{tbl:ltx-classes} -\begin{tabular}{lp{30em}} - \hline - \cls{article} & 文章格式的文档类,广泛用于科技论文、报告、说明文档等。\\ - \cls{report} & 长篇报告格式的文档类,具有章节结构,用于综述、长篇论文、简单的书籍等。\\ - \cls{book} & 书籍文档类,包含章节结构和前言、正文、后记等结构。\\ - \hline - \cls{proc} & 基于 \cls{article} 文档类的一个简单的学术文档模板。\\ - \cls{slides} & 幻灯格式的文档类,使用无衬线字体。\\ - \cls{minimal} & 一个极其精简的文档类,只设定了纸张大小和基本字号, - 用作代码测试的最小工作示例(Minimal Working Example)。 \\ - \hline -\end{tabular} -\end{table} - -\pinyinindex{xuanxiang}{选项(宏包/文档类)} -可选参数 \Arg{options} 为文档类指定选项,以全局地规定一些排版的参数,如字号、纸张大小、单双面等等。 -比如调用 \cls{article} 文档类排版文章,指定纸张为 A4 大小,基本字号为 11pt,双面排版: -\begin{verbatim} -\documentclass[11pt,twoside,a4paper]{article} -\end{verbatim} - -\LaTeX\ 的三个标准文档类可指定的选项包括: -\begin{description} -\item[\texttt{10pt, 11pt, 12pt}] \quad 指定文档的基本字号。默认为 \texttt{10pt}。 -\item[\texttt{a4paper, letterpaper, \ldots}] \quad 指定纸张大小,默认为美式信纸 \texttt{letterpaper} ($8.5\times11$英寸)。 -可指定选项还包括 \texttt{a5paper},\texttt{b5paper},\texttt{executivepaper} 和 \texttt{legalpaper}。 -\item[\texttt{twoside, oneside}] \quad 指定单面/双面排版。双面排版时,奇偶页的页眉页脚、页边距不同。 -\cls{article} 和 \cls{report} 默认为 \texttt{oneside},\cls{book} 默认为 \texttt{twoside}。 -\item[\texttt{onecolumn, twocolumn}] \quad 指定单栏/双栏排版。默认为 \texttt{onecolumn}。 -\item[\texttt{openright, openany}] \quad 指定新的一章 \cmd{chapter} 是在奇数页(右侧)开始,还是直接紧跟着上一页开始。 -\cls{report} 默认为 \texttt{openany},\cls{book} 默认为 \texttt{openright}。对 \cls{article} 无效。 -\item[\texttt{landscape}] \quad 指定横向排版。默认为纵向。 -\item[\texttt{titlepage, notitlepage}] 指定标题命令 \cmd{maketitle} 是否生成单独的标题页。 -\cls{article} 默认为 \texttt{notitlepage},\cls{report} 和 \cls{book} 默认为 \texttt{titlepage}。 -\item[\texttt{fleqn}] \quad 令行间公式左对齐。默认为居中对齐。 -\item[\texttt{leqno}] \quad 将公式编号放在左边。默认为右边。 -\item[\texttt{draft, final}] \quad 指定草稿/终稿模式。 -草稿模式下,断行不良的地方会在行尾添加一个黑色方块。默认为 \texttt{final}。 -\end{description} - -\subsection{宏包}\label{subsec:packages} - -\cmdindex{usepackage} -\pinyinindex{hongbao}{宏包} -\pinyinindex{xuanxiang}{选项(宏包/文档类)} -在使用 \LaTeX\ 时,时常需要依赖一些扩展来增强或补充 \LaTeX\ 的功能,比如排版复杂的表格、插入图片、增加颜色甚至超链接等等。 -这些扩展称为\textbf{宏包}。调用宏包的方法非常类似调用文档类的方法: -\begin{command} -\cmd{usepackage}\oarg{options}\marg{package-name} -\end{command} - -\cmd{usepackage}~可以一次性调用多个宏包,在 \Arg{package-name} 中用逗号隔开。这种用法一般不要指定选项% -\footnote{使用多个宏包时指定选项,相当于给每个宏包指定同样的选项。如果有某个宏包不能识别指定的选项,则会出错。}: -\begin{verbatim} -% 一次性调用三个排版表格常用的宏包 -\usepackage{tabularx, makecell, multirow} -\end{verbatim} - -附录 \ref{sec:pkg-list} 汇总了常用的一些宏包。我们在手册接下来的章节中,也会穿插介绍一些最常用的宏包的使用方法。 - -在使用宏包和文档类之前,一定要首先确认它们是否安装在你的计算机中,否则 \cmd{use\-package} 等命令会报错误。 -详见附录 \ref{sec:pkg-manager}。 - -宏包(包括前面所说的文档类)可能定义了许多命令和环境,或者修改了 \LaTeX\ 已有的命令和环境。 -它们的用法说明记在相应宏包和文档类的帮助文档。在 Windows 命令提示符或者 Linux 终端下输入命令可查阅相应文档: -\begin{command} -\texttt{texdoc} \Arg{pkg-name} -\end{command} - -其中 \Arg{pkg-name} 是宏包或者文档类的名称。更多获得帮助的方法见附录 \ref{sec:texdoc}。 - -\section{\LaTeX\ 用到的文件一览}\label{sec:latex-files} - -除了源代码文件 \texttt{.tex} 以外,我们在使用 \LaTeX\ 时还可能接触到各种格式的文件。 -本节简单介绍一下在使用 \LaTeX\ 时能够经常见到的文件。 - -每个宏包和文档类都是带特定扩展名的文件,除此之外也有一些文件出现于 \LaTeX\ 模板中: -\begin{description} - \item[\texttt{.sty}] 宏包文件。宏包的名称与文件名一致。 - \item[\texttt{.cls}] 文档类文件。文档类名称与文件名一致。 - \item[\texttt{.bib}] \hologo{BibTeX} 参考文献数据库文件。 - \item[\texttt{.bst}] \hologo{BibTeX} 用到的参考文献格式模板。详见 \ref{subsec:bibtex-use} 小节。 -\end{description} - -\LaTeX\ 在编译过程中除了生成 \texttt{.dvi} 或 \texttt{.pdf} 格式的文档外\footnote{\hologo{XeLaTeX} 还可能生成 \texttt{.xdv} 文件。},还可能会生成相当多的辅助文件和日志。 -一些功能如交叉引用、参考文献、目录、索引等,需要先通过编译生成辅助文件, -然后再次编译时读入辅助文件得到正确的结果,所以复杂的 \LaTeX\ 源代码可能要编译多次: -\begin{description} - \item[\texttt{.log}] 排版引擎生成的日志文件,供排查错误使用。 - \item[\texttt{.aux}] \LaTeX\ 生成的主辅助文件,记录交叉引用、目录、参考文献的引用等。 - \item[\texttt{.toc}] \LaTeX\ 生成的目录记录文件。 - \item[\texttt{.lof}] \LaTeX\ 生成的图片目录记录文件。 - \item[\texttt{.lot}] \LaTeX\ 生成的表格目录记录文件。 - \item[\texttt{.bbl}] \hologo{BibTeX} 生成的参考文献记录文件。 - \item[\texttt{.blg}] \hologo{BibTeX} 生成的日志文件。 - \item[\texttt{.idx}] \LaTeX\ 生成的供 makeindex 处理的索引记录文件。 - \item[\texttt{.ind}] makeindex 处理 \texttt{.idx} 生成的用于排版的格式化索引文件。 - \item[\texttt{.ilg}] makeindex 生成的日志文件。 - \item[\texttt{.out}] \pkg{hyperref} 宏包生成的 PDF 书签记录文件。 -\end{description} - -\section{文件的组织方式}\label{sec:latex-multi-files} - -当编写长篇文档时,例如当编写书籍、毕业论文时,单个源文件会使修改、校对变得十分困难。 -将源文件分割成若干个文件,例如将每章内容单独写在一个文件中,会大大简化修改和校对的工作。 -可参考源代码 \ref{code:book-struct} 的写法。 - -\cmdindex{include} -\LaTeX\ 提供了命令 \cmd{include} 用来在源代码里插入文件: -\begin{command} -\cmd{include}\marg{filename} -\end{command} -\Arg{filename} 为文件名,如果和要编译的主文件不在一个目录中,则要加上相对或绝对路径,例如: -\begin{verbatim} -\include{chapters/a.tex} % 相对路径 -\include{/home/Bob/file.tex} % Linux/macOS 绝对路径 -\include{D:/file.tex} % Windows 绝对路径,用正斜线 -\end{verbatim} - -\Arg{filename} 可以不带扩展名,此时默认扩展名为 \texttt{.tex}。 - -\cmdindex{input} -值得注意的是 \cmd{include} 在读入 \Arg{filename} 之前会另起一页。有的时候我们并不需要这样,而是用 \cmd{input} 命令,它纯粹是把文件里的内容插入: -\begin{command} -\cmd{input}\marg{filename} -\end{command} - -\cmdindex{includeonly} -另外 \LaTeX\ 提供了一个 \cmd{includeonly} 命令来组织文件,用于\textbf{导言区},指定只载入某些文件: -\begin{command} -\cmd{includeonly}\marg*{\Arg{filename1},\Arg{filename2},\ldots} -\end{command} - -导言区使用了 \cmd{includeonly} 后,正文中不在其列表范围的 \cmd{include} 命令不会起效。 - -\pkgindex{syntonly} -最后介绍一个实用的工具宏包 \pkg{syntonly}。加载这个宏包后,在导言区使用 \cmd{syntaxonly} 命令, -可令 \LaTeX\ 编译后不生成 DVI 或者 PDF 文档,只排查错误,编译速度会快不少: -\begin{verbatim} -\usepackage{syntonly} -\syntaxonly -\end{verbatim} - -如果想生成文档,则用 \texttt\% 注释掉 \cmd{syntaxonly} 命令即可。 - -\section{\LaTeX\ 和 \TeX\ 相关的术语和概念}\label{sec:concepts} - -\pinyinindex{paibanyinqing}{排版引擎} -\index{pdfTeX@\hologo{pdfTeX}} -\index{XeTeX@\hologo{XeTeX}} -在本章的最后有必要澄清几个概念: -\begin{description} - \item[引擎] 全称为排版引擎,是编译源代码并生成文档的程序,如 \hologo{pdfTeX}、\hologo{XeTeX} 等。有时也称为编译器。 - \item[格式] 是定义了一组命令的代码集。\LaTeX\ 就是最广泛应用的一个格式,高德纳本人还编写了一个简单的 plain \TeX\ 格式, - 没有定义诸如 \cmd{document\-class} 和 \cmd{section} 等等命令。 - \item[编译命令] 是实际调用的、结合了引擎和格式的命令。如 \texttt{xelatex} 命令是结合 \hologo{XeTeX} - 引擎和 \LaTeX\ 格式的一个编译命令。 -\end{description} -常见的引擎、格式和编译命令的关系总结于表 \ref{tbl:engine-format-command}。 - -\begin{table}[htp] - \centering - \caption{\TeX\ 引擎、格式及其对应的编译命令。} - \label{tbl:engine-format-command} - \begin{tabular}{cccc} - \hline - & \textbf{文档格式} & \textbf{plain \TeX\ 格式} & \textbf{\LaTeX\ 格式} \\ - \hline - \TeX\ 引擎 & DVI & \texttt{tex} & N/A \\ - \hologo{pdfTeX} 引擎 & DVI & \texttt{etex} & \texttt{latex} \\ - & PDF & \texttt{pdftex} & \texttt{pdflatex} \\ - \hologo{XeTeX} 引擎 & PDF & \texttt{xetex} & \texttt{xelatex} \\ - \hologo{LuaTeX} 引擎 & PDF & \texttt{luatex} & \texttt{lualatex} \\ - \hline - \end{tabular} -\end{table} - -\texttt{latex} 编译命令和 \LaTeX\ 格式往往容易混淆,在讨论关于 \LaTeX\ 的时候需要明确。 -为避免混淆,本手册中的 \LaTeX\ 一律指的是\textbf{格式},\textbf{编译命令}则用等宽字体 \texttt{latex} 表示。 - -在此介绍一下几个编译命令的基本特点: -\begin{description} - \item[\texttt{latex}] - 虽然名为 \texttt{latex} 命令,底层调用的引擎其实是 \hologo{pdfTeX}。 - 该命令生成 \texttt{dvi}(Device Independent)格式的文档, - 用 \texttt{dvipdfmx} 命令可以将其转为 \texttt{pdf}。 - \item[\texttt{pdflatex}] - 底层调用的引擎也是 \hologo{pdfTeX},可以直接生成 \texttt{pdf} 格式的文档。 - \item[\texttt{xelatex}] - 底层调用的引擎是 \hologo{XeTeX},支持 UTF-8 编码和 TrueType / OpenType 字体。 - 当前较为方便的中文排版解决方案基于 \texttt{xelatex},详见 \ref{sec:chinese} 节。 - \item[\texttt{lualatex}] - 底层调用的引擎是 \hologo{LuaTeX},这个引擎在 \hologo{pdfTeX} 引擎基础上发展而来, - 除了支持 UTF-8 编码和 TrueType / OpenType 字体外,还支持通过 Lua 语言扩展 \TeX\ 的功能。 - \texttt{lualatex} 编译命令下的中文排版支持需要借助 \pkg{luatex-ja} 宏包。 -\end{description} - -\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.02.text.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.02.text.tex deleted file mode 100644 index 55b43be44ca..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.02.text.tex +++ /dev/null @@ -1,380 +0,0 @@ -\chapter{用 \LaTeX\ 排版文字}\label{chap:text} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -文字是排版的基础。在介绍 \LaTeX\ 支持的各种文档元素之前,首先应当了解一下如何在 \LaTeX\ 源代码中输入并排版文字, -尤其是(西文中的)标点符号、连字符、重音等一些细节。 - -本文的开头首先介绍了中文的支持方式。随着 \LaTeX\ 和底层 \TeX\ 引擎的发展,旧方式(CCT、CJK 等)日渐退出舞台, -xelatex 编译命令配合 \cls{xeCJK} 或 \cls{ctex} 宏包的方式成为主流。 -\end{intro} - -\section{语言文字和编码}\label{sec:encoding} - -\pinyinindex{bianma}{编码} -\LaTeX\ 源代码为文本文件,而文本文件的一个至关重要的性质是它的编码。在此用尽量短的篇幅介绍一下。 - -\subsection{ASCII 编码}\label{subsec:ascii} - -\index{bianma@编码!ASCII} -计算机的基本存储单位是字节(byte),每个字节为八位(8-bit),范围用十六进制写作 0x00-0xFF。 -ASCII (美国通用信息交换码)使用 0x00-0x7F 对文字编码,也就是 7-bit,能够表示 QWERTY 键盘上能够输入的拉丁字母、数字和符号。 - -由于 \TeX\ 最初面向英语文档的排版,ASCII 编码完全够用,而早期版本的 \TeX\ 也只支持 7-bit 和 ASCII。 -要排版西欧语系中带重音的字符,就必须用到后文所叙述的重音命令,如 M\"obius 必须输入 \texttt{M\char`\\"obius}。 - -\subsection{扩展编码}\label{subsec:ext-encoding} - -在 ASCII 之后,各种语言文字都发展了自己的编码,比如西欧语言的 Latin-1,日本的 Shift-JIS,中国大陆的 GB2312-80 和 GBK 等。 -它们之中的绝大多数都向下兼容 ASCII,因此无论是在哪种编码下,\TeX\ 以及 \LaTeX\ 的命令和符号都能用。 - -\index{bianma@编码!Latin-1} -\pkgindex{inputenc} -\TeX\ 从 3.0 版开始支持 8-bit,能够处理源代码里编码处于 0x80-0xFF 范围的字符。 -西欧(拉丁字母)、俄语系(西里尔字母)等语言的编码方案刚好能够利用 0x80-0xFF 这个范围,处理起来较为方便。 -\texttt{latex} 命令及 \texttt{pdflatex} 命令下,这些编码的处理由 \pkg{inputenc} 宏包支持。 -比如将源代码保存为 Latin-1 编码,并在导言区调用宏包: -\begin{verbatim} -\usepackage[latin1]{inputenc} -\end{verbatim} -接下来,M\"obius 就直接可以通过(用适当输入法)输入 \texttt{M\"obius} 得到了。 - -\index{bianma@编码!GBK} -GBK 等编码是多字节编码,ASCII 字符为一个字节,汉字等非 ASCII 字符为两个字节,这就需要借助一些宏包进行较为复杂的判断和处理。 -\pkg{CJK} 宏包就是用于处理中、日、韩等多字节编码的语言文字的宏包。但 \pkg{CJK} 宏包的使用非常不方便,笔者不再推荐直接使用。 - -\subsection{UTF-8 编码}\label{subsec:utf8} - -\index{bianma@编码!UTF-8} -Unicode 是一个多国字符的集合,覆盖了几乎全球范围内的语言文字。UTF-8 是 Unicode 的一套编码方案, -一个字符可以由一个到四个字节编码,其中单字节字符兼容 ASCII 编码。 - -\pkgindex{inputenc} -\texttt{latex} 命令及 \texttt{pdflatex} 命令下可以使用 \pkg{inputenc} 宏包支持 UTF-8 编码: -\begin{verbatim} -\usepackage[utf8]{inputenc} -\end{verbatim} - -\texttt{xelatex} 和 \texttt{lualatex} 命令原生支持 UTF-8 编码,而且也\textbf{不适用 \pkg{inputenc} 宏包}。将 \texttt{.tex} 源代码保存为 UTF-8 编码, -并借助 \pkg{fontspec} 宏包(见 \ref{subsec:fontspec} 小节)调用适当的字体,就可以在源代码中输入任意语言的文字。 -但各个语言(印地语、阿拉伯语等)的特殊排版要求需要更多的宏包支持,如 \pkg{babel}、 \pkg{polyglossia} 等。 - -\section{排版中文}\label{sec:chinese} - -\subsection{\pkg{xeCJK} 宏包}\label{subsec:xeCJK} - -用 \LaTeX\ 排版中文的一大难题是中文字体的处理。\TeX\ 使用的字体格式仅支持不超过 256 个字符, -旧式的中文排版方案如 \pkg{CJK} 宏包往往需要复杂的预处理,将中文字体拆分成数百个小字体,非常麻烦% -\footnote{现在的 \texttt{pdflatex} 以及 \texttt{latex} + \texttt{dvipdfmx} 命令通过字体映射的方式支持直接使用中文字体,不需要经过预处理, -但仍然是不方便新手操作的。}。 - -\index{xelatex@\texttt{xelatex} 命令} -\pkgindex{xeCJK} -\texttt{xelatex} 命令支持直接使用系统安装的 TrueType (\texttt{.ttf}) / OpenType (\texttt{.otf}) 等格式的字体,加上对 UTF-8 编码的原生支持, -免去了预处理字体的麻烦。在此基础上的 \pkg{xeCJK} 宏包更进一步完善了排版中文的一些细节,比如中英文之间插入空隙、 -中文行尾的回车不引入空格、标点符号不出现在行首,等等。 - -\pkg{xeCJK} 宏包支持用简单的命令配置中文字体。举一个在 Windows 下使用 \pkg{xeCJK} 的例子(设置字体的命令详见 \ref{subsec:CJKfont} 小节), -源代码须保存为 UTF-8 编码,并使用 \texttt{xelatex} 命令编译: -\begin{verbatim} -\documentclass{article} -\usepackage{xeCJK} -\setCJKmainfont{SimSun} -\begin{document} -中文\LaTeX{}排版。 -\end{document} -\end{verbatim} - -\subsection{\pkg{ctex} 宏包和文档类}\label{subsec:ctex} - -\pkgindex{ctex} -\clsindex{ctexart,ctexbook,ctexrep} -\pkg{ctex} 宏包和文档类是对 \pkg{CJK} 和 \pkg{xeCJK} 等宏包的进一步封装。\pkg{ctex} 文档类包括 -\cls{ctexart} / \cls{ctexrep} / \cls{ctexbook},是对 \LaTeX\ 的三个标准文档类的封装,对 \LaTeX\ 的排版样式做了许多调整, -以切合中文排版风格。最新版本的 \pkg{ctex} 宏包/文档类甚至能够根据操作系统自动配置字体。比如上述例子可进一步简化为: -\begin{verbatim} -\documentclass{ctexart} -\begin{document} -中文\LaTeX{}排版。 -\end{document} -\end{verbatim} - -虽然 \pkg{ctex} 宏包和文档类保留了对 GBK 编码以及 \texttt{latex} + \texttt{dvipdfmx}、\texttt{pdflatex} 等旧的编译命令的支持, -笔者建议在使用 \pkg{ctex} 宏包和文档类时总是将源代码保存为 UTF-8 编码,用 \texttt{xelatex} 命令编译。 - -\section{\LaTeX\ 中的字符}\label{sec:text-symbols} - -\subsection{空格和分段}\label{subsec:spaces} - -\LaTeX\ 源代码中,空格键和 Tab 键输入的空白字符视为“空格”。 -连续的若干个空白字符视为一个空格。一行开头的空格忽略不计。 - -\cmdindex{par} -行末的回车视为一个空格;但连续两个回车,也就是空行,会将文字分段。多个空行被视为一个空行。 -也可以在行末使用 \cmd{par} 命令分段。 -\begin{example} -Several spaces equal one. - Front spaces are ignored. - -An empty line starts a new -paragraph.\par -A \verb|\par| command also -starts a new line. -\end{example} - -\subsection{注释}\label{subsec:comments} - -\index{^^e@\texttt\% (\textit{注释})} -\LaTeX\ 用 \texttt\% 字符作为注释。在这个字符之后直到行末,所有的字符都被忽略, -行末的回车也不引入空格。 -\begin{example} -This is an % short comment -% --- -% Long and organized -% comments -% --- -example: Comments do not bre% -ak a word. -\end{example} - -\subsection{特殊字符}\label{subsec:special-chars} - -以下字符在 \LaTeX\ 里有特殊用途,如 \texttt\% 表示注释, \texttt\$、\texttt\textasciicircum 、\texttt\_ 等用于排版数学公式, -\texttt\& 用于排版表格,等等。直接输入这些字符得不到对应的符号,还往往会出错: -\begin{verbatim} -# $ % & { } _ ^ ~ \ -\end{verbatim} - -如果想要输入以上符号,需要使用以下带反斜线的形式输入: -\begin{example} -\# \$ \% \& \{ \} \_ -\^{} \~{} \textbackslash -\end{example} - -事实上这些带反斜线的形式就是 \LaTeX\ 命令。\cmd{\textasciicircum} 和 \cmd{\textasciitilde} -两个命令是需要带参数的,如果不加一对花括号(空参数),就将后面的字符作为参数,形成重音效果(详见 \ref{subsec:accents} 节)。 -\crcmd\ 被直接定义成了手动换行的命令,输入反斜杠就只好用 \cmd{text\-back\-slash}。 - -\subsection{连字}\label{subsec:ligatures} - -西文排版中经常会出现连字(Ligatures),常见的有 ff / fi / fl / ffi / ffl{}。 -\begin{example} -It's difficult to find \ldots .\\ -It's dif{}f{}icult to f{}ind \ldots . -\end{example} - -\subsection{标点符号}\label{subsec:punct} - -中文的标点符号(绝大多数为非 ASCII 字符)使用中文输入法输入即可,一般不需要过多留意。 -而在英文标点符号上,有许多需要留意的地方。 - -\subsubsection{引号} - -\index{biaodianfuhao@标点符号!`@\protect\verb+`+ (\textit{前引号} `)} -\index{biaodianfuhao@标点符号!``@\protect\verb+'+ (\textit{后引号} ')} -\index{biaodianfuhao@标点符号!'@\protect\verb+``+ (\textit{前双引号} ``)} -\index{biaodianfuhao@标点符号!''@\protect\verb+''+ (\textit{后双引号} '')} -\LaTeX\ 的单引号 ` ' 用 \texttt` 和 \texttt' 输入;双引号 `` '' 用 \verb|``| 和 \verb|''| 输入 -(虽然 \texttt" 也能表示双引号,但没有合适的单个符号用来表示前双引号,所以不常用在正文)。 -\begin{example} -``Please press the `x' key.'' -\end{example} - -\subsubsection{连字号和破折号} - -\index{biaodianfuhao@标点符号!-@\protect\verb+-+ (\textit{连字号} -)} -\index{biaodianfuhao@标点符号!--@\protect\verb+--+ (\textit{短破折号} --)} -\index{biaodianfuhao@标点符号!---@\protect\verb+---+ (\textit{长破折号} ---)} -\LaTeX\ 中有三种长度的“横线”可用:连字号(hyphen)、短破折号(en-dash)和长破折号(em-dash)。 -它们分别有不同的用途:连字号 - 用来组成复合词;短破折号 -- 用来连接数字表示范围;长破折号 --- 用来连接单词,与中文语境中的破折号用法类似。 -\begin{example} -daughter-in-law, X-rated\\ -pages 13--67\\ -yes---or no? -\end{example} - -\subsubsection{省略号} - -\index{biaodianfuhao@标点符号!ldots@\cmd{ldots} (\textit{省略号} \ldots)} -\index{biaodianfuhao@标点符号!dots@\cmd{dots} (\textit{省略号} \dots)|see{\cmd{ldots}}} -\LaTeX\ 提供了命令 \cmd{ldots} 来生成省略号,相对于直接输入三个点的方式更为合理。 -\cmd{ldots} 和 \cmd{dots} 是两个等效的命令。 -\begin{example} -one, two, three, \ldots one hundred. -\end{example} - -\subsubsection{波浪号} - -我们在 \ref{subsec:special-chars} 小节中了解了 \cmd{\textasciitilde} 命令,它可以用来输入波浪号, -但位置靠顶端(\cmd{\textasciitilde} 命令主要用作重音,参考下一小节)。西文中较少将波浪号作为标点符号使用,通常使用中文的全角波浪号(~)。 - -\subsection{特殊西文符号与重音}\label{subsec:accents} - -\pinyinindex{zhongyin}{重音} -\LaTeX\ 支持用命令输入各种西欧语言的特殊符号和重音: -\begin{example} -H\^otel, na\"\i ve, \'el\`eve,\\ -sm\o rrebr\o d, !`Se\ norita!,\\ -Sch\"onbrunner Schlo\ss{} -Stra\ss e -\end{example} - -更多可用的符号和重音见表 \ref{tbl:accents}。注意与 \ref{subsec:math-accents} 小节的数学重音区分开来。 - -\def\TSYM #1{#1 & \texttt{\string#1}} -\def\TACC #1#2{#1{#2} & \texttt{\string#1#2}} % accents using a control character -\def\TTACC #1#2{#1{#2} & \texttt{\string#1 #2}} % accents using a control word -\def\WTACC #1#2{#1{#2} & \texttt{\string#1\{#2\}}} % multi-letter accents -\begin{table}[htp] -\centering -\caption{\LaTeX\ 文本中的重音和特殊字符。} \label{tbl:accents} -\begin{tabular}{*4{cl}} - \hline - \TACC{\`}{o} & \TACC{\'}{o} & \TACC{\^}{o} & \TACC{\~}{o} \\ - \TACC{\=}{o} & \TACC{\.}{o} & \TACC{\"}{o} & \TTACC{\r}{o}\\ - \TTACC{\u}{o} & \TTACC{\v}{o} & \TTACC{\H}{o} & \TTACC{\c}{o} \\ - \TTACC{\d}{o} & \TTACC{\b}{o} & \WTACC{\t}{oo} \\[6pt] - \TSYM{\oe} & \TSYM{\OE} & \TSYM{\ae} & \TSYM{\AE} \\ - \TSYM{\aa} & \TSYM{\AA} & \TSYM{\ss} \\[6pt] - \TSYM{\o} & \TSYM{\O} & \TSYM{\l} & \TSYM{\L} \\ - \TSYM{\i} & \TSYM{\j} & !` & \verb|!`| & ?` & \verb|?`| \\ - \hline -\end{tabular} -\begin{quote}\footnotesize% -前四行实际上都是带一个参数的命令。\cmd{\textasciicircum}\texttt{o} 也可以写作 -\cmd{\textasciicircum}\marg*{o},以此类推。 -\end{quote} -\end{table} - -\subsection{其它符号}\label{subsec:text-misc} - -\symindex{dag,ddag,P,S,copyright,pounds} -\symindex{textasteriskcentered,textperiodcentered,textbullet,textregistered,texttrademark} -\LaTeX\ 预定义了其它一些文本模式的符号,部分符号可参考表 \ref{tbl:general-syms}。 -\begin{example} -\P{} \S{} \dag{} \ddag{} -\copyright{} \pounds{} - -\textasteriskcentered -\textperiodcentered -\textbullet - -\textregistered{} \texttrademark -\end{example} - -更多的符号多由特定的宏包支持。参考文献 \cite{symbols} 搜集了所有在 \TeX\ 发行版中可用的符号,使用时要留意每个符号所依赖的宏包。 - -\subsection{\LaTeX\ 标志}\label{subsec:latex-mark} - -\cmdindex{TeX,LaTeX,LaTeXe} -我们见到的所有错落有致的 \LaTeX\ 标志都是由以下命令输入的: -\begin{center} -\begin{tabular}{*{2}{l}} - \hline - \TeX & \cmd{TeX} \\ - \LaTeX & \cmd{LaTeX} \\ - \LaTeXe & \cmd{LaTeXe} \\ - \hline -\end{tabular} -\end{center} - -\section{文字强调}\label{sec:emph} - -强调文字的方法,要么是添加下划线等装饰物,要么是改变文字的字体。 - -\cmdindex{underline} -\LaTeX\ 定义了 \cmd{underline} 命令用来为文字添加下划线: -\begin{example} -An \underline{underlined} text. -\end{example} - -\pkgindex{ulem} -\cmdindex[ulem]{uline} -\cmd{underline} 命令生成下划线的样式比较机械,不同的单词可能生成高低各异的下划线,并且无法换行。 -\pkg{ulem} 宏包解决了这一问题,它提供的 \cmd{uline} 命令能够轻松生成自动换行的下划线: -\begin{example} -An example of \uline{some -long and underlined words.} -\end{example} - -\cmdindex{emph} -\cmd{emph} 命令用来将文字变为斜体以示强调。如果在本身已经用 \cmd{emph} 命令强调的文字内部嵌套使用 \cmd{emph} 命令, -内部则使用直立体文字: -\begin{example} -Some \emph{emphasized words, -including \emph{double-emphasized} -words}, are shown here. -\end{example} - -如果需要用其它字体表示强调,可参考后文的 \ref{subsec:fontshape} 小节。 - -\section{断行和断页}\label{sec:break} - -\LaTeX\ 将文字段落在合适的位置进行断行,尽可能做到每行的宽度一致,并且单词间距匀称。 -文字段落和公式、图表等内容从上到下顺序排布,并在合适的位置断页,分割成匀称的页面。 -在绝大多数时候,我们无需自己操心断行和断页。但偶尔会遇到需要手工调整的地方。 - -\subsection{单词间距和断行}\label{subsec:interword} - -在西文排版实践中,断行的位置尽可能选取在两个单词之间,也就是用户在源文件中输入的“空格”% -\footnote{中文排版实现汉字间断行,则需要宏包(如 \pkg{xeCJK} 等)或排版引擎(如 upLaTeX)的支持。}。 -这个“空格”通常生成一个间距,它会根据行宽和上下文自动调整,文字密一些的地方,单词间距就略窄,反之略宽。 - -\index{~@\texttt\textasciitilde\ (\textit{不断行空格})} -我们可以使用字符 \texttt\textasciitilde 在合适的位置插入一个不会断行的空格(高德纳称之为 tie,“带子”), -通常用在英文人名、图表名称等场景: -\begin{example} -Fig.~2a \\ -Donale~E. Knuth -\end{example} - -\subsection{手动断行和断页}\label{subsec:manual-break} - -\index{\@\crcmd\ (\textit{换行})} \cmdindex{newline} -如果我们确实需要手动断行,可使用如下命令: -\begin{command} -\crcmd \oarg{length} \\ -\cmd{newline} -\end{command} - -它们有两点区别:一是 \crcmd\ 可以带可选参数 \Arg{length},用于在换行处向下增加垂直间距(见 \ref{subsec:vspace} 小节), -而 \cmd{newline} 不带可选参数;二是 \crcmd\ 也在表格、公式等地方用于分行,而 \cmd{newline} 只用于文本段落中。 - -\cmdindex{newpage,clearpage} -断页的命令有两个: -\begin{command} -\cmd{newpage} \quad or \quad \cmd{clearpage} -\end{command} - -通常情况下两个命令都能起到另起一页的作用,但有一些区别:一是在双栏排版中 \cmd{newpage} 只起到另起一栏的作用;二是涉及到浮动体的排版上行为不同。 -后文的 \ref{sec:float} 节以及 \ref{subsec:columns} 小节会更详细地介绍相关内容。 - -\cmdindex{linebreak,nolinebreak} -有时候我们不满足于 \LaTeX\ 默认的断行和断页位置,需要进行微调,就要用以下命令告诉 \LaTeX\ 哪些地方适合断页,哪些地方不适合: -\begin{command} -\cmd{linebreak}\oarg{n} \quad \cmd{nolinebreak}\oarg{n} \\ -\cmd{pagebreak}\oarg{n} \quad \cmd{nopagebreak}\oarg{n} -\end{command} - -以上命令都带一个可选参数,用数字 \Arg{n} 代表适合/不适合的程度,取值范围为 0-4,不带可选参数时,缺省为 4。 -比如 \cmd{linebreak}\texttt{[3]} 意味着此处在断行时优先考虑;\cmd{nopagebreak} 或 \cmd{nopagebreak}\texttt{[4]} -意味着禁止在此处断页。 - -以上命令适合给出优先考虑断行断页/禁止断行断页的位置,但不适合直接拿来断行或断页,使用 \cmd{newline} 或 \cmd{newpage} 等是更好的选择% -\footnote{\cmd{newline} 和 \cmd{newpage} 会在断行/断页位置正确添加空白,但 \cmd{linebreak} 和 \cmd{pagebreak} 不能, -它们的强行断行/断页会导致 \LaTeX\ 报 \texttt{Underfull \cmd{hbox}} 等警告。}。 - -\subsection{断词}\label{subsec:hyphen} - -如果 \LaTeX\ 遇到了很长的英文单词,仅在单词之间的位置断行无法生成宽度匀称的行时,就要考虑从单词中间断开。 -对于绝大部分单词,\LaTeX\ 能够找到合适的断词位置,在断开的行尾加上连字符 \char\hyphenchar\font 。 - -\index{-@\cmd{-} (\textit{断词})} -如果一些单词没能自动断词,我们可以在单词内手动使用 \cmd{-} 命令指定断词的位置: -\begin{example} -I think this is: su\-per\-cal\-% -i\-frag\-i\-lis\-tic\-ex\-pi\-% -al\-i\-do\-cious. -\end{example} - -\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.03.elements.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.03.elements.tex deleted file mode 100644 index 95f4d86556b..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.03.elements.tex +++ /dev/null @@ -1,1139 +0,0 @@ -\chapter{文档元素}\label{chap:elements} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -在知道了如何输入文字后,我们将在本章了解一个结构化的文档所依赖的各种元素——章节、目录、列表、图表、交叉引用、脚注等等。 -\end{intro} - -\section{章节和目录}\label{sec:secs} - -\subsection{章节标题}\label{subsec:secs} - -\cmdindex{part,chapter,section,subsection,subsubsection,paragraph,subparagraph} -\clsindex{article,book,report} - -一篇结构化的、条理清晰文档一定是层次分明的,通过不同的命令分割为章、节、小节。三个标准文档类 \cls{article}、\cls{report} 和 \cls{book}% -\footnote{千万注意是\textbf{标准文档类},其它文档类,如果不是从标准文档类衍生而来, -很可能没有定义或只定义了一部分命令,如 \cls{beamer} 或 \cls{moderncv} 等。}% -提供了划分章节的命令: -\begin{command} -\cmd{chapter}\marg{title} \quad -\cmd{section}\marg{title} \quad -\cmd{subsection}\marg{title} \\ -\cmd{subsubsection}\marg{title} \quad -\cmd{paragraph}\marg{title} \quad -\cmd{subparagraph}\marg{title} -\end{command} -其中 \cmd{chapter} \textbf{只在 \cls{book} 和 \cls{report} 文档类有定义}。这些命令生成章节标题,并能够自动编号。 -除此之外 \LaTeX\ 还提供了 \cmd{part} 命令,用来将整个文档分割为大的分块,但不影响 \cmd{chapter} 或 \cmd{section} 等的编号。 - -上述命令除了生成带编号的标题之外,还向目录中添加条目,并影响页眉页脚的内容(详见 \ref{sec:pagestyle} 节)。每个命令有两种变体: -\begin{itemize} - \item 带可选参数的变体:\cmd{section}\oarg{short title}\marg{title}\par - 标题使用 \Arg{title} 参数,在目录和页眉页脚中使用 \Arg{short title} 参数; - \item 带星号的变体:\cmd{section*}\marg{title}\par - 标题不带编号,也不生成目录项和页眉页脚。 -\end{itemize} - -较低层次如 \cmd{paragraph} 和 \cmd{subparagraph} 即使不用带星号的变体,生成的标题默认也不带编号,事实上,除 \cmd{part} 外: -\begin{itemize} - \item \cls{article} 文档类带编号的层级为 \cmd{section} / \cmd{subsection} / \cmd{sub\-sub\-section} 三级; - \item \cls{report}/\cls{book} 文档类带编号的层级为 \cmd{chapter} / \cmd{section} / \cmd{sub\-section} 三级。 -\end{itemize} -对此的详细解释和调整方法见 \ref{subsec:latex-counts} 小节。 - -\pkgindex{titlesec} -\LaTeX\ 及标准文档类并未提供为 \cmd{section} 等章节命令定制格式的功能,这一功能由 \pkg{titlesec} 宏包提供。详情请参考宏包的帮助文档。 - -\subsection{目录}\label{sec:toc} - -\cmdindex{tableofcontents} -\pkgindex{tocbibind,tocloft,titletoc} -在 \LaTeX\ 中生成目录非常容易,只需在合适的地方使用命令: -\begin{command} -\cmd{tableofcontents} -\end{command} - -这个命令会生成单独的一章(\cls{book} / \cls{report})或一节(\cls{article}),标题默认为 ``Contents''{},可通过 \ref{sec:latex-settings} 节给出的方法定制标题。 -\cmd{tableof\-contents} 生成的章节默认不写入目录(\cmd{section*} 或 \cmd{chapter*}),可使用 \pkg{tocbibind} 等宏包修改设置。 - -正确生成目录项,一般需要编译两次源代码。 - -\cmdindex{addcontentsline} -有时我们使用了 \cmd{chapter*} 或 \cmd{section*} 这样不生成目录项的章节标题命令, -而又想手动生成该章节的目录项,可以在标题命令后面使用: -\begin{command} -\cmd{addcontentsline}\marg*{toc}\marg{level}\marg{title} -\end{command} - -其中 \Arg{level} 为章节层次 \texttt{chapter} 或 \texttt{section} 等,\Arg{title} 为出现于目录项的章节标题。 - -\pkg{titletoc}、\pkg{tocloft} 等宏包提供了具体定制目录项格式的功能,详情请参考宏包的帮助文档。 - -\subsection{文档结构的划分}\label{sec:matters} - -\cmdindex{appendix} -所有标准文档类都提供了一个 \cmd{appendix} 命令将正文和附录分开% -\footnote{有的参考文档可能使用 \cmd{begin} \marg*{appendix} \ldots \cmd{end} \marg*{appendix} 这样的写法, -虽然有效,但并不规范,只要使用 \cmd{appendix} 命令就够了。}, -使用 \cmd{appendix} 后,最高一级章节改为使用拉丁字母编号,从 A 开始。 - -\clsindex{book} -\cmdindex{frontmatter,mainmatter,backmatter} -\cls{book} 文档类还提供了前言、正文、后记结构的划分命令: -\begin{description} - \item[\cmd{frontmatter}] 前言部分,页码为小写罗马字母格式;其后的 \cmd{chapter} 不编号。 - \item[\cmd{mainmatter}] 正文部分,页码为阿拉伯数字格式,从 1 开始计数;其后的章节编号正常。 - \item[\cmd{backmatter}] 后记部分,页码格式不变,继续正常计数;其后的 \cmd{chapter} 不编号。 -\end{description} - -\cmdindex{include} -以上三个命令还可和 \cmd{appendix} 命令结合,生成有前言、正文、附录、后记四部分的文档。 -源代码 \ref{code:book-struct} 结合 \ref{sec:latex-multi-files} 节的 \cmd{include} 命令和其它一些命令示意了一份完整的文档结构。 - -\begin{sourcecode}[htp] -\begin{Verbatim} -\documentclass[...]{book} -% 导言区,加载宏包和各项设置,包括参考文献、索引等 -\usepackage{...} -\usepackage{makeidx} -\makeindex -\bibliographystyle{...} - -\begin{document} -\frontmatter -\maketitle % 标题页 -\include{preface} % 前言章节 preface.tex -\tableofcontents -\mainmatter -\include{chapter1} % 第一章 chapter1.tex -\include{chapter2} % 第二章 chapter2.tex -... -\appendix -\include{appendixA} % 附录 A appendixA.tex -... -\backmatter -\include{prologue} % 后记 prologue.tex -\bibliography{...} % 利用 BibTeX 工具生成参考文献 -\printindex % 利用 makeindex 工具生成索引 -\end{document} -\end{Verbatim} -\caption{\cls{book} 文档类的文档结构示例。}\label{code:book-struct} -\end{sourcecode} - -\section{标题页}\label{sec:titlepage} - -\cmdindex{title,author,date,today} -\cmdindex{thanks,and} -\LaTeX\ 支持生成简单的标题页。首先需要给定标题和作者等信息: -\begin{command} -\cmd{title}\marg{title} \quad -\cmd{author}\marg{author} \quad -\cmd{date}\marg{date} -\end{command} -其中前两个命令是必须的(不用 \cmd{title} 会报错;不用 \cmd{author} 会警告),\cmd{date} 命令可选。 -\LaTeX\ 还提供了一个 \cmd{today} 命令自动生成当前日期,\cmd{date} 默认使用 \cmd{today}。 -在 \cmd{title}、\cmd{author} 等命令内可以使用 \cmd{thanks} 命令生成标题页的脚注,用 \cmd{and} 隔开多个人名。 - -\cmdindex{maketitle} -\pinyinindex{biaotiye}{标题页} -在信息给定后,就可以使用 \cmd{maketitle} 命令生成一个简单的标题页了。 -源代码 \ref{code:titlepage} 给出了一个标题页的示例和大致效果。 -\cls{article} 文档类的标题默认不单独成页,而 \cls{report} 和 \cls{book} 默认单独成页。 -可在 \cmd{document\-class} 命令调用文档类时指定 \texttt{titlepage / notitlepage} 选项以修改默认的行为。 - -\begin{sourcecode}[htp] -\begin{Verbatim} -\title{Test title} -\author{ Mary\thanks{E-mail:*****@***.com} - \and Ted\thanks{Corresponding author} - \and Louis} -\date{\today} -\end{Verbatim} -\bigskip -\makeatletter -\begin{minipage}{\textwidth} - \centering - \renewcommand\thempfootnote{\@fnsymbol\c@mpfootnote}% - {\LARGE Test title \par}% - \vskip 1.5em% - {\large - \lineskip .5em% - \begin{tabular}[t]{c}% - Mary\footnote{E-mail:*****@***.com} - \end{tabular} - \hskip 1em \@plus.17fil% - \begin{tabular}[t]{c}% - Ted\footnote{Corresponding author} - \end{tabular} - \hskip 1em \@plus.17fil% - \begin{tabular}[t]{c}% - Louis - \end{tabular}\par}% - \vskip 1em% - {\large September 10, 2015}% -\end{minipage} -\makeatother -\caption{\LaTeX\ 默认的标题页示例和效果。}\label{code:titlepage} -\end{sourcecode} - -\envindex{titlepage} -\LaTeX\ 标准类还提供了一个简单的 \env{titlepage} 环境,生成不带页眉页脚的一页。用户可以在这个环境中使用各种排版元素自由发挥, -生成自定义的标题页以替代 \cmd{maketitle} 命令。甚至可以利用 \env{titlepage} 环境重新定义 \cmd{maketitle}: -\begin{verbatim} -\renewcommand{\maketitle}{\begin{titlepage} -... % 用户自定义命令 -\end{titlepage}} -\end{verbatim} - -事实上,为标准文档类指定了 \texttt{titlepage} 选项以后,使用 \cmd{maketitle} 命令生成的标题页就是一个 \env{titlepage} 环境。 - -以上是 \LaTeX\ 标准文档类的标题页相关命令用法。在各种文档模板中经常有自定义的标题页, -有可能需要除了 \cmd{title} 和 \cmd{author} 以外的命令给定信息,用法也可能与标准文档类的不一致 -(甚至有些模板可能没有定义 \env{titlepage} 等环境)。使用文档模板前\textbf{一定要仔细阅读文档模板的帮助文档}。 - -\section{交叉引用}\label{sec:crossref} - -\cmdindex{label} -交叉引用是 \LaTeX\ 强大的自动排版功能的体现之一。在能够被交叉引用的地方,如章节、公式、图表、定理等位置使用 \cmd{label} 命令: -\begin{command} -\cmd{label}\marg{label-name} -\end{command} - -\cmdindex{ref,pageref} -之后可以在别处使用 \cmd{ref} 或 \cmd{pageref} 命令,分别生成交叉引用的编号和页码: -\begin{command} -\cmd{ref}\marg{label-name} \quad -\cmd{pageref}\marg{label-name} -\end{command} -\begin{example} -A reference to this subsection -\label{sec:this} looks like: -``see section~\ref{sec:this} on -page~\pageref{sec:this}.'' -\end{example} - -为了生成正确的交叉引用,一般也需要多次编译源代码。 - -\cmd{label} 命令可用于记录各种类型的交叉引用,使用位置分别为: -\begin{description} - \item[章节标题] 在章节标题命令 \cmd{section} 等之后紧接着使用。 - \item[行间公式] 单行公式在公式内任意位置使用;多行公式在每一行公式的任意位置使用。 - \item[有序列表] 在 \env{enumerate} 环境的每个 \cmd{item} 命令之后、下一个 \cmd{item} 命令之前任意位置使用。 - \item[图表标题] 在图表标题命令 \cmd{caption} 之后紧接着使用。 - \item[定理环境] 在定理环境内部任意位置使用。 -\end{description} - -在使用不记编号的命令形式(\cmd{section*}、\cmd{caption*}、带可选参数的 \cmd{item} 命令等)时不要使用 \cmd{label} 命令, -否则生成的引用编号不正确。 - -\section{脚注和边注}\label{sec:footnote-marginpar} - -\cmdindex{footnote} -使用 \cmd{footnote} 命令可以在页面底部生成一个脚注: -\begin{command} -\cmd{footnote}\marg{footnote} -\end{command} - -假如我们输入以下文字和命令: -\begin{verbatim} -“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnote{出自《千字文》。} -\end{verbatim} - -在正文中则为:% -“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnote{出自《千字文》。} - -\cmdindex{footnotemark,footnotetext} -有些情况下(比如在表格环境、各种盒子内)使用 \cmd{footnote} 并不能正确生成脚注。我们可以分两步进行, -先使用 \cmd{foot\-note\-mark} 为脚注计数,再在合适的位置用 \cmd{foot\-note\-text} 生成脚注。比如: - -\begin{verbatim} -\begin{tabular}{l} -\hline -“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnotemark \\ -\hline -\end{tabular} -\footnotetext{表格里的名句出自《千字文》。} -\end{verbatim} - -效果为: - -\leavevmode\begin{tabular}{l} -\hline -“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnotemark \\ -\hline -\end{tabular} -\footnotetext{表格里的名句出自《千字文》。} - -\cmdindex{marginpar} -使用 \cmd{marginpar} 命令可在边栏位置生成边注: -\begin{command} -\cmd{marginpar}\oarg{left-margin}\marg{right-margin} -\end{command} -如果只给定了 \Arg{right-margin},那么边注在奇偶数页文字相同;如果同时给定了 \Arg{left-margin}, -则偶数页使用 \Arg{left-margin} 的文字。 - -例如以下代码: -\begin{verbatim} -\marginpar{\footnotesize 边注较窄,不要写过多文字,最好设置较小的字号。} -\end{verbatim} -其效果见边栏。\marginpar{\footnotesize 边注较窄,不要写过多文字。最好设置较小的字号。} - -\section{特殊环境}\label{sec:envs} - -\subsection{列表}\label{subsec:lists} - -\envindex{enumerate,itemize} -\cmdindex{item} -\LaTeX\ 提供了基本的有序和无序列表环境 \env{enumerate} 和 \env{itemize},两者的用法很类似,都用 \cmd{item} 标明每个列表项。 -\env{enumerate} 环境会自动对列表项编号。 -\begin{command} -\cmd{begin}\marg*{enumerate} \\ -\cmd{item} \ldots \\ -\cmd{end}\marg*{enumerate} -\end{command} - -其中 \cmd{item} 可带一个可选参数,将有序列表的计数或者无序列表的符号替换成自定义的符号。 -列表可以嵌套使用,最多嵌套四层。 -\begin{example} -\begin{enumerate} - \item An item. - \begin{enumerate} - \item A nested item.\label{itref} - \item[*] A starred item. - \end{enumerate} - \item Reference(\ref{itref}). -\end{enumerate} -\end{example} - -\begin{example} -\begin{itemize} - \item An item. - \begin{itemize} - \item A nested item. - \item[+] A `plus' item. - \item Another item. - \end{itemize} - \item Go back to upper level. -\end{itemize} -\end{example} - -\envindex{description} -关键字环境 \env{description} 的用法与以上两者类似,不同的是 \cmd{item} 后的可选参数用来写关键字,以粗体显示,一般是必填的: -\begin{command} -\cmd{begin}\marg*{description} \\ - \cmd{item}\oarg{item title} \ldots \\ -\cmd{end}\marg*{description} -\end{command} - -\begin{example} -\begin{description} - \item[Enumerate] Numbered list. - \item[Itemize] Non-numbered list. -\end{description} -\end{example} - -各级无序列表的符号由命令 \cmd{labelitemi} 到 \cmd{labelitemiv} 定义,可以简单地重新定义它们: -\begin{example} -\renewcommand{\labelitemi}{\ddag} -\renewcommand{\labelitemii}{\dag} -\begin{itemize} - \item First item - \begin{itemize} - \item Subitem - \item Subitem - \end{itemize} - \item Second item -\end{itemize} -\end{example} - -有序列表的符号由命令 \cmd{labelenumi} 到 \cmd{labelenumiv} 定义, -重新定义这些命令需要用到 \ref{sec:counters} 节的计数器相关命令: -\begin{example} -\renewcommand{\labelenumi}% - {\Alph{enumi}>} -\begin{enumerate} - \item First item - \item Second item -\end{enumerate} -\end{example} - -默认的列表间距比较宽,\LaTeX\ 本身也未提供方便的定制功能,可用 \pkg{enumitem} 宏包定制各种列表间距。 -\pkg{enumitem} 宏包还提供了对列表标签、引用等的定制。有兴趣的读者可参考其帮助文档。 - -\subsection{对齐环境}\label{subsec:flush} - -\envindex{center,flushleft,flushright} -\env{center}、\env{flush\-left} 和 \env{flush\-right} 环境分别用于生成居中、左对齐和右对齐的文本环境。 -\begin{command} -\cmd{begin}\marg*{center} \ldots\ \cmd{end}\marg*{center} \\ -\cmd{begin}\marg*{flushleft} \ldots\ \cmd{end}\marg*{flushleft} \\ -\cmd{begin}\marg*{flushright} \ldots\ \cmd{end}\marg*{flushright} -\end{command} - -\begin{example} -\begin{center} -Centered text using a -\verb|center| environment. -\end{center} -\begin{flushleft} -Left-aligned text using a -\verb|flushleft| environment. -\end{flushleft} -\begin{flushright} -Right-aligned text using a -\verb|flushright| environment. -\end{flushright} -\end{example} - -\cmdindex{centering,raggedleft,raggedright} -除此之外,还可以用以下命令直接改变文字的对齐方式: -\begin{command} -\cmd{centering} \quad -\cmd{raggedright} \quad -\cmd{raggedleft} -\end{command} - -\begin{example} -\centering -Centered text paragraph. - -\raggedright -Left-aligned text paragraph. - -\raggedleft -Right-aligned text paragraph. -\end{example} - -三个命令和对应的环境经常被误用,有直接用所谓 \cmd{flushleft} 命令或者 \env{raggedright} 环境的,都是不甚严格的用法(即使它们可能有效)。 -有一点可以将两者区分开来:\env{center} 等环境会在上下文产生一个额外间距,而 \cmd{centering} 等命令不产生,只是改变对齐方式。 -比如在浮动体环境 \env{table} 或 \env{figure} 内实现居中对齐,用 \cmd{centering} 命令即可,没必要再用 \env{center} 环境。 - -\subsection{引用环境}\label{subsec:quote} - -\envindex{quote,quotation} -\LaTeX\ 提供了两种引用的环境:\env{quote} 用于引用较短的文字,首行不缩进;\env{quotation} 用于引用若干段文字,首行缩进。 -引用环境较一般文字有额外的左右缩进。 -\begin{example} -Francis Bacon says: -\begin{quote} -Knowledge is power. -\end{quote} -\end{example} - -\begin{example} -《木兰诗》: -\begin{quotation} -万里赴戎机,关山度若飞。 -朔气传金柝,寒光照铁衣。 -将军百战死,壮士十年归。 - -归来见天子,天子坐明堂。 -策勋十二转,赏赐百千强。…… -\end{quotation} -\end{example} - -\envindex{verse} -\env{verse} 用于排版诗歌,与 \env{quotation} 恰好相反,\env{verse} 是首行悬挂缩进的。 -\begin{example} -Rabindranath Tagore's short poem: -\begin{verse} -Beauty is truth's smile -when she beholds her own face in -a perfect mirror. -\end{verse} -\end{example} - -\subsection{摘要环境}\label{subsec:abstract} - -\envindex{abstract} -摘要环境 \env{abstract} 默认只在标准文档类中的 \cls{article} 和 \cls{report} 文档类可用, -一般用于紧跟 \cmd{maketitle} 命令之后介绍文档的摘要。如果文档类指定了 \texttt{titlepage} 选项,则单独成页; -反之,单栏排版时相当于一个居中的小标题加一个 \env{quotation} 环境,双栏排版时相当于 \cmd{section*} 定义的一节。 - -\subsection{代码环境}\label{subsec:verbatim} - -\envindex{verbatim} -有时我们需要将一段代码原样转义输出,这就要用到代码环境 \env{verbatim},它以等宽字体排版代码,回车和空格也分别起到换行和空位的作用; -带星号的版本更进一步将空格显示成 \textvisiblespace 。 -\begin{example} -\begin{verbatim} -#include -int main() -{ - std::cout << "Hello, world!" - << std::endl; - return 0; -} -\end{verbatim} -\end{example} - -\begin{example} -\begin{verbatim*} -for (int i=0; i<4; ++i) - printf("Number %d\n",i); -\end{verbatim*} -\end{example} - -\cmdindex{verb} -要排版简短的代码或关键字,可使用 \cmd{verb} 命令: -\begin{command} -\cmd{verb}\Arg{delim}\Arg{code}\Arg{delim} -\end{command} - -\Arg{delim} 标明代码的分界位置,前后必须一致,除字母、空格或星号外,可任意选择使得不与代码本身冲突,习惯上使用 \texttt| 符号。 - -同 \env{verbatim} 环境,\cmd{verb} 后也可以带一个星号,以显示空格: -\begin{example} -\verb|\LaTeX| \\ -\verb+(a || b)+ \verb*+(a || b)+ -\end{example} - -\cmd{verb} 命令对符号的处理比较复杂,一般\textbf{不能用在其它命令的参数里},否则多半会出错。 - -\pkg{verbatim} 宏包优化了 \env{verbatim} 环境的内部命令,并提供了 \cmd{verbatiminput} 命令用来直接读入文件生成代码环境。 -\pkg{fancyvrb} 宏包提供了可定制格式的 \env{Verbatim} 环境;\pkg{listings} 宏包更进一步,可生成关键字高亮的代码环境, -支持各种程序设计语言的语法和关键字。详情请参考各自的帮助文档。 - -\section{表格}\label{sec:tabular} - -\pinyinindex{biaoge}{表格|(} -\LaTeX\ 里排版表格不如 Word 等所见即所得的工具简便和自由,不过对于不太复杂的表格来讲,完全能够胜任。 - -\envindex{tabular} -\cmdindex{hline} -\index{&@\texttt\& (\textit{单元格/对齐})} -\index{\@\crcmd\ (\textit{换行})} -排版表格最基本的 \env{tabular} 环境用法为: -\begin{command} -\cmd{begin}\marg*{tabular}\marg{column-spec}\\ - \Arg{item1} \texttt\& \Arg{item2} \texttt\& \ldots\ \crcmd \\ - \cmd{hline} \\ - \Arg{item1} \texttt\& \Arg{item2} \texttt\& \ldots\ \crcmd \\ -\cmd{end}\marg*{tabular} -\end{command} -其中 \Arg{column-spec} 是列格式标记,在接下来的内容将仔细介绍;\texttt\& 用来分隔单元格; -\crcmd\ 用来换行;\cmd{hline} 用来在行与行之间绘制横线。 - -直接使用 \env{tabular} 环境的话,会\textbf{和周围的文字混排}。\env{tabular} 环境可带一个可选参数控制垂直对齐(默认是垂直居中): -\begin{example} -\begin{tabular}{|c|} - center-\\ aligned \\ -\end{tabular}, -\begin{tabular}[t]{|c|} - top-\\ aligned \\ -\end{tabular}, -\begin{tabular}[b]{|c|} - bottom-\\ aligned\\ -\end{tabular} tabulars. -\end{example} - -但是通常情况下我们不这么用,\env{tabular} 环境一般会放置在 \env{table} 浮动体环境中,并用 \cmd{caption} 命令加标题。 - -\subsection{列格式}\label{subsec:tabular-cols} - -\env{tabular} 环境使用 \Arg{column-spec} 参数指定表格的列数以及每列的格式。基本的列格式见表 \ref{tbl:table-column-spec}。 -\begin{table}[htp] -\centering -\caption{\LaTeX\ 表格列格式。}\label{tbl:table-column-spec} -\begin{tabular}{*{2}{l}} - \hline - \textbf{列格式} & \textbf{说明} \\ - \hline - \ttfamily l/c/r & 单元格内容左对齐/居中/右对齐,不折行 \\ - \ttfamily p\marg{width} & 单元格宽度固定为 \Arg{width},可自动折行 \\ - \ttfamily | & 绘制竖线 \\ - \ttfamily @\marg{string} & 自定义内容 \Arg{string} \\ - \hline -\end{tabular} -\end{table} - -\begin{example} -\begin{tabular}{lcr|p{6em}} - \hline - left & center & right - & par box with fixed width\\ - L & C & R & P \\ - \hline -\end{tabular} -\end{example} - -表格中每行的单元格数目不能多于列格式里 \texttt{l/c/r/p} 的总数(可以少于这个总数),否则出错。 - -\texttt{@} 格式可在单元格前后插入任意的文本,但同时它也消除了单元格前后额外添加的间距。 -\texttt{@} 格式可以适当使用以充当“竖线”。特别地,\texttt{@}\marg*{} 可直接用来消除单元格前后的间距: -\begin{example} -\begin{tabular}{@{} r@{:}lr @{}} - \hline - 1 & 1 & one \\ - 11 & 3 & eleven \\ - \hline -\end{tabular} -\end{example} - -另外 \LaTeX\ 还提供了简便的将格式参数重复的写法 \texttt*\marg{n}\marg{column-spec},比如以下两种写法是等效的: -\begin{verbatim} -\begin{tabular}{|c|c|c|c|c|p{4em}|p{4em}|} -\begin{tabular}{|*{5}{c|}*{2}{p{4em}|}} -\end{verbatim} - -\pkgindex{array} -有时需要为整列修饰格式,比如整列改变为粗体,如果每个单元格都加上 \cmd{bfseries} 命令会比较麻烦。 -\pkg{array} 宏包提供了辅助格式 \texttt> 和 \texttt<,用于给列格式前后加上修饰命令: -\begin{example} -\begin{tabular}{>{\itshape}r<{*}l} - \hline - italic & normal \\ - column & column \\ - \hline -\end{tabular} -\end{example} - -辅助格式甚至支持插入 \cmd{centering} 等命令改变 \texttt{p} 列格式的对齐方式, -一般还要加额外的命令 \cmd{array\-back\-slash} 以免出错% -\footnote{\cmd{centering} 等对齐命令会破坏表格环境里 \crcmd\ 换行命令的定义, -\cmd{array\-back\-slash} 用来恢复之。如果不加 \cmd{array\-back\-slash} 命令, -也可以用 \cmd{tabular\-newline} 命令代替原来的 \crcmd\ 实现表格换行。}: -\begin{example} -\begin{tabular} -{>{\centering\arraybackslash}p{9em}} - \hline - Some center-aligned long text. \\ - \hline -\end{tabular} -\end{example} - -\pkg{array} 宏包还提供了类似 \texttt{p} 格式的 \texttt{m} 格式和 \texttt{b} 格式, -三者分别在垂直方向上靠顶端对齐、居中以及底端对齐。 -\begin{example} -\newcommand\txt - {a b c d e f g h i} -\begin{tabular}{cp{2em}m{2em}b{2em}} - \hline - pos & \txt & \txt & \txt \\ - \hline -\end{tabular} -\end{example} - -\subsection{列宽}\label{subsec:colwidth} - -在控制列宽方面,\LaTeX\ 表格有着明显的不足:\texttt{l/c/r} 格式的列宽是由文字内容的自然宽度决定的, -而 \texttt{p} 格式给定了列宽却不好控制对齐(可用 \pkg{array} 宏包的辅助格式), -更何况列与列之间通常还有间距,所以直接生成给定总宽度的表格并不容易。 - -\envindex{tabular*} -\LaTeX\ 本身提供了 \env{tabular*} 环境用来排版定宽表格,但是不太方便使用, -比如要用到 \texttt{@} 格式插入额外命令,令单元格之间的间距为 \cmd{fill},但即使这样仍然有瑕疵: -\begin{example} -\begin{tabular*}{14em}% -{@{\extracolsep{\fill}}|c|c|c|c|} - \hline - A & B & C & D \\ \hline - a & b & c & d \\ \hline -\end{tabular*} -\end{example} - -\pkgindex{tabularx} -\envindex[tabularx]{tabularx} -\pkg{tabularx} 宏包为我们提供了方便的解决方案。它引入了一个 \texttt{X} 列格式,类似 \texttt{p} 列格式, -不过会根据表格宽度自动计算列宽,多个 \texttt{X} 列格式平均分配列宽。 -\texttt{X} 列格式也可以用 \pkg{array} 里的辅助格式修饰对齐方式: -\begin{example} -\begin{tabularx}{14em}% -{|*{4}{>{\centering\arraybackslash}X|}} - \hline - A & B & C & D \\ \hline - a & b & c & d \\ \hline -\end{tabularx} -\end{example} - -\subsection{横线}\label{subsec:hline} - -\cmdindex{hline,cline} -我们已经在之前的例子见过许多次绘制表格线的 \cmd{hline} 命令。另外 \cmd{cline}\marg*{\Arg{i}-\Arg{j}} 用来绘制跨越部分单元格的横线: -\begin{example} -\begin{tabular}{|c|c|c|} - \hline - 4 & 9 & 2 \\ \cline{2-3} - 3 & 5 & 7 \\ \cline{1-1} - 8 & 1 & 6 \\ \hline -\end{tabular} -\end{example} - -\pkgindex{booktabs} -\cmdindex[booktabs]{toprule,midrule,bottomrule,cmidrule} -在科技论文排版中广泛应用的表格形式是三线表,形式干净简明。 -三线表由 \pkg{booktabs} 宏包支持,它提供了 \cmd{toprule}、\cmd{midrule} 和 \cmd{bottomrule} 命令用以排版三线表的三条线, -以及和 \cmd{cline} 对应的 \cmd{cmidrule}。除此之外,最好不要用其它横线以及竖线: -\begin{example} -\begin{tabular}{cccc} - \toprule - & \multicolumn{3}{c}{Numbers} \\ - \cmidrule{2-4} - & 1 & 2 & 3 \\ - \midrule - Alphabet & A & B & C \\ - Roman & I & II& III \\ - \bottomrule -\end{tabular} -\end{example} - -\subsection{合并单元格}\label{subsec:tabular-multicol} - -\LaTeX\ 是一行一行排版表格的,横向合并单元格较为容易,由 \cmd{multi\-column} 命令实现: -\begin{command} -\cmd{multicolumn}\marg{n}\marg{column-spec}\marg{item} -\end{command} -其中 \Arg{n} 为要合并的列数,\Arg{column-spec} 为合并单元格后的列格式,只允许出现一个 \texttt{l/c/r} 或 \texttt{p} 格式。 -如果合并前的单元格前后带表格线 \texttt|,合并后的列格式也要带 \texttt| 以使得表格的竖线一致。 -\begin{example} -\begin{tabular}{|c|c|c|} - \hline - 1 & 2 & Center \\ \hline - \multicolumn{2}{|c|}{3} & - \multicolumn{1}{r|}{Right} \\ \hline - 4 & \multicolumn{2}{c|}{C} \\ \hline -\end{tabular} -\end{example} - -上面的例子还体现了,形如 \cmd{multicolumn}\marg*{1}\marg{column-spec}\marg{item} 的命令\textbf{可以用来修改某一个单元格的列格式。} - -\pkgindex{multirow} -\cmdindex[multirow]{multirow} -纵向合并单元格需要用到 \pkg{multirow} 宏包提供的 \cmd{multirow} 命令: -\begin{command} -\cmd{multirow}\marg{n}\marg{width}\marg{item} -\end{command} -\Arg{width} 为合并后单元格的宽度,可以填 \texttt{*} 以使用自然宽度。 - -我们看一个结合 \cmd{cline}、\cmd{multi\-column} 和 \cmd{multi\-row} 命令的例子: -\begin{example} -\begin{tabular}{ccc} - \hline - \multirow{2}{*}{Item} & - \multicolumn{2}{c}{Value} \\ - \cline{2-3} - & First & Second \\ \hline - A & 1 & 2 \\ \hline -\end{tabular} -\end{example} - -\subsection{嵌套表格}\label{subsec:tabular-embed} - -相对于合并单元格,拆分单元格对于 \LaTeX\ 来说并非易事。在单元格中嵌套一个小表格可以起到“拆分单元格”的效果。 -在以下的例子中,注意要用 \cmd{multi\-column} 命令配合 \texttt{@\{\}} 格式把单元格的额外边距去掉,使得嵌套的表格线能和外层的表格线正确相连: - -\begin{example} -\begin{tabular}{|c|c|c|} - \hline - a & b & c \\ \hline - a & \multicolumn{1}{@{}c@{}|} - {\begin{tabular}{c|c} - e & f \\ \hline - e & f \\ - \end{tabular}} - & c \\ \hline - a & b & c \\ \hline -\end{tabular} -\end{example} - -\pkgindex{makecell} -如果不需要为“拆分的单元格”画线,并且只在垂直方向“拆分”的话,\pkg{makecell} 宏包提供的 \cmd{make\-cell} 命令是一个简单的解决方案: - -\begin{example} -\begin{tabular}{|c|c|} - \hline - a & \makecell{d1 \\ d2} \\ - \hline - b & c \\ - \hline -\end{tabular} -\end{example} - -\subsection{行距控制}\label{subsec:tabular-colht} - -\cmdindex{arraystretch} -\LaTeX\ 生成的表格看起来通常比较紧凑。修改参数 \cmd{array\-stretch} 可以得到行距更加宽松的表格 -(相关命令参考 \ref{subsec:newcmd} 小节): -\begin{example} -\renewcommand\arraystretch{1.8} -\begin{tabular}{|c|} - \hline - Really loose \\ \hline - tabular rows.\\ \hline -\end{tabular} -\end{example} - -\index{\@\crcmd\ (\textit{换行})} -另一种增加间距的办法是给换行命令 \crcmd\ 添加可选参数,在这一行下面加额外的间距,适合用于在行间不加横线的表格: -\begin{example} -\begin{tabular}{c} - \hline - Head lines \\[6pt] - tabular lines \\ - tabular lines \\ \hline -\end{tabular} -\end{example} - -但是这种换行方式的存在导致了一个缺陷——\textbf{表格的首个单元格不能直接使用中括号 \texttt{[]}}, -否则 \crcmd\ 往往会将下一行的中括号当作自己的可选参数,因而出错。如果要使用中括号,应当放在花括号 \marg*{} 里面。 -或者也可以选择将换行命令写成 \crcmd\texttt{[0pt]}。 - -\pinyinindex{biaoge}{表格|)} - -\section{图片}\label{sec:figures} - -\pkgindex{graphicx} - -\LaTeX\ 本身不支持插图功能,需要由 \pkg{graphicx} 宏包辅助支持。 - -使用 \texttt{latex + dvipdfmx} 编译命令时,调用 \pkg{graphicx} 宏包时要指定 \texttt{dvipdfmx} 选项% -\footnote{早期常使用 \texttt{latex + dvips} 组合命令,后者将 \texttt{.dvi} 文件转为 \texttt{.ps} 文件(PostScript), -可进一步通过 \texttt{ps2pdf} 工具生成 PDF。\texttt{dvips} 和 \texttt{dvipdfmx} 在图形、颜色、超链接等功能的实现上有差别,而 \LaTeX\ 无法识别 -用户是用 \texttt{dvips} 还是 \texttt{dvipdfmx},所以要指定选项(缺省为 \texttt{dvips})。 -\ref{sec:hyperlinks} 节中的 \pkg{hyperref} 宏包同理。};而使用 \texttt{pdflatex} 或 \texttt{xelatex} 命令编译时不需要。 - -读者可能听说过“\LaTeX\ 只能插入 \texttt{.eps} 格式的图片,需要把 \texttt{.jpg} 转成 \texttt{.eps} 格式”的观点。 -\LaTeX\ 发展到今天,这个观点早已过时。事实上不同的编译命令支持的图片格式范围各异,见表 \ref{tbl:figure-format}。 -这个表格也能解答诸如“为什么 \texttt{.eps} 格式图片在 \texttt{pdflatex} 编译命令下出错”之类的问题。本表格也再一次说明,使用 -\texttt{xelatex} 命令是笔者最推荐的方式。 - -\begin{table}[htp] -\centering -\caption{各种编译方式支持的主流图片格式。}\label{tbl:figure-format} -\begin{tabular}{*{3}{l}} - \hline - \textbf{格式} & \textbf{矢量图} & \textbf{位图} \\ - \hline - \texttt{latex + dvipdfmx} & \texttt{.eps} & n/a \\ - \quad $\llcorner$(调用 \pkg{bmpsize} 宏包 ) & \texttt{.eps .pdf} & \texttt{.jpg .png .bmp} \\[.3\baselineskip] - \texttt{pdflatex} & \texttt{.pdf} & \texttt{.jpg .png} \\ - \quad $\llcorner$(调用 \pkg{epstopdf} 宏包) & \texttt{.pdf .eps} & \texttt{.jpg .png} \\[.3\baselineskip] - \texttt{xelatex} & \texttt{.pdf .eps} & \texttt{.jpg .png .bmp} \\ - \hline -\end{tabular} -\begin{quote}\footnotesize -注:在较新的 \TeX\ 发行版中,\texttt{latex + dvipdfmx} 和 \texttt{pdf\-latex} 命令可不依赖宏包,支持原来需要宏包扩展的图片格式 -(但 \texttt{pdf\-latex} 命令仍不支持除 \texttt{.jpg} 和 \texttt{.png} 以外的位图)。 -\end{quote} -\end{table} - -\cmdindex[graphicx]{includegraphics} -在调用了 \pkg{graphicx} 宏包以后,就可以使用 \cmd{include\-graphics} 命令加载图片了: -\begin{command} -\cmd{includegraphics}\oarg{options}\marg{filename} -\end{command} - -\cmdindex[graphicx]{graphicspath} -其中 \Arg{filename} 为图片文件名,与使用 \cmd{include} 命令类似,文件名有时需要使用相对路径或绝对路径(见 \ref{sec:latex-multi-files} 节)。 -图片文件的扩展名可写可不写。 - -另外 \pkg{graphicx} 宏包还提供了 \cmd{graphics\-path} 命令,用于声明一个或多个图片文件存放的目录, -使用这些目录里的图片时可不用写路径: -\begin{verbatim} -% 假设主要的图片放在 figures 子目录下,标志放在 logo 子目录下 -\graphicspath{{figures/}{logo/}} -\end{verbatim} - -\cmd{includegraphics} 命令的可选参数 \Arg{options} 支持 \Arg{key}=\Arg{value} 形式赋值,常用的参数如下: -\begin{table}[htp] -\centering -\caption{\cmd{includegraphics} 命令的可选参数。}\label{tbl:graphics-options} -\begin{tabular}{lp{18em}} - \hline - \textbf{参数} & \textbf{含义} \\ - \hline - \texttt{width=}\Arg{width} & 将图片缩放到宽度为 \Arg{width} \\ - \texttt{height=}\Arg{height} & 将图片缩放到高度为 \Arg{height} \\ - \texttt{scale=}\Arg{scale} & 将图片相对于原尺寸缩放 \Arg{scale} 倍 \\ - \texttt{angle=}\Arg{angle} & 令图片逆时针旋转 \Arg{angle} 度 \\ - \hline -\end{tabular} -\end{table} - -\section{盒子}\label{sec:box} - -盒子是 \LaTeX\ 排版的基础单元,虽然解释上去有些抽象:每一行是一个盒子, -里面的文字从左到右依次排列;每一页也是一个盒子,各行文字从上到下依次排布……颇有一些活字印刷术的味道。 - -不管如何,\LaTeX\ 提供了一些命令让我们生成一些有特定用途的盒子。 - -\subsection{水平盒子}\label{subsec:mbox} - -\cmdindex{mbox,makebox} -生成水平盒子的命令如下: -\begin{command} -\cmd{mbox}\marg*{\ldots} \\ -\cmd{makebox}\oarg{width}\oarg{align}\marg*{\ldots} -\end{command} - -\cmd{mbox} 生成一个基本的水平盒子,内容只有一行,不允许分段(除非嵌套其它盒子,比如后文的垂直盒子)。 -外表看上去,\cmd{mbox} 的内容与正常的文本无二,不过断行时文字不会从盒子里断开。 - -\cmd{makebox} 更进一步,可以加上可选参数用于控制盒子的宽度 \Arg{width},以及内容的对齐方式 \Arg{align}, -可选居中 \texttt{c}(默认值)、左对齐 \texttt{l}、右对齐 \texttt{r} 和分散对齐 \texttt{s}% -\footnote{分散对齐方式强行拉开单词的间距,往往会报 \texttt{Underfull} \cmd{hbox} 的消息。}。 -\begin{example} -|\mbox{Test some words.}|\\ -|\makebox[10em]{Test some words.}|\\ -|\makebox[10em][l]{Test some words.}|\\ -|\makebox[10em][r]{Test some words.}|\\ -|\makebox[10em][s]{Test some words.}| -\end{example} - -\subsection{带框的水平盒子}\label{subsec:fbox} - -\cmdindex{fbox,framebox} -\cmd{fbox} 和 \cmd{framebox} 让我们可以为水平盒子添加边框。使用的语法与 \cmd{mbox} 和 \cmd{makebox} 一模一样: -\begin{command} -\cmd{fbox}\marg*{\ldots} \\ -\cmd{framebox}\oarg{width}\oarg{align}\marg*{\ldots} -\end{command} -\begin{example} -\fbox{Test some words.}\\ -\framebox[10em][r]{Test some words.} -\end{example} - -\cmdindex{setlength} -\cmdindex{fboxrule,fboxsep} -可以通过 \cmd{setlength} 命令(见 \ref{subsec:lengths} 小节)调节边框的宽度 \cmd{fbox\-rule} 和内边距 \cmd{fbox\-sep}: -\begin{example} -\framebox[10em][r]{Test box}\\[1ex] -\setlength{\fboxrule}{1.6pt} -\setlength{\fboxsep}{1em} -\framebox[10em][r]{Test box} -\end{example} - -\subsection{垂直盒子}\label{subsec:parbox} - -\cmdindex{parbox} -\envindex{minipage} -如果需要排版一个文字可以换行的盒子,\LaTeX\ 提供了两种方式: -\begin{command} -\cmd{parbox}\oarg{align}\oarg{height}\oarg{inner-align}\marg{width}\marg*{\ldots} \\[0.5ex] -\cmd{begin}\marg*{minipage}\oarg{align}\oarg{height}\oarg{inner-align}\marg{width} \\ -\ldots \\ -\cmd{end}\marg*{minipage} -\end{command} - -其中 \Arg{align} 为盒子和周围文字的对齐情况(类似 \env{tabular} 环境); -\Arg{height} 和 \Arg{inner-align} 设置盒子的高度和内容的对齐方式,类似水平盒子 \cmd{makebox} 的设置, -不过 \Arg{inner-align} 接受的参数是顶部 \texttt{t}、底部 \texttt{b}、居中 \texttt{c} 和分散对齐 \texttt{s}。 - -\begin{example} -三字经:\parbox[t]{3em}% -{人之初 性本善 性相近 习相远} -\quad -千字文: -\begin{minipage}[b][8ex][t]{4em} -天地玄黄 宇宙洪荒 -\end{minipage} -\end{example} - -\cmdindex{footnote,footnotetext,footnotemark} -如果在 \env{minipage} 里使用 \cmd{footnote} 命令,生成的脚注会出现在盒子底部,编号是独立的,并且使用小写字母编号。 -这也是 \env{minipage} 环境之被称为“迷你页”(Mini-page)的原因。 -而在 \cmd{parbox} 里无法正常使用 \cmd{footnote} 命令,只能在盒子里使用 \cmd{foot\-note\-mark},在盒子外使用 \cmd{foot\-note\-text}。 -\begin{example} -\fbox{\begin{minipage}{15em}% - 这是一个垂直盒子的测试。 - \footnote{脚注来自 minipage。} -\end{minipage}} -\end{example} - -\subsection{标尺盒子}\label{subsec:rules} - -\cmdindex{rule} -\cmd{rule} 命令用来画一个实心的矩形盒子,也可适当调整以用来画线(标尺): -\begin{command} -\cmd{rule}\oarg{raise}\marg{width}\marg{height} -\end{command} -\begin{example} -Black \rule{12pt}{4pt} box. - -Upper \rule[4pt]{6pt}{8pt} and -lower \rule[-4pt]{6pt}{8pt} box. - -A \rule[-.4pt]{3em}{.4pt} line. -\end{example} - -\section{浮动体}\label{sec:float} - -内容丰富的文章或者书籍往往包含许多图片和表格等内容。这些内容的尺寸往往太大,导致分页困难。 -\LaTeX\ 为此引入了浮动体的机制,令大块的内容可以脱离上下文,放置在合适的位置。 - -\envindex{figure,table} -\LaTeX\ 预定义了两类浮动体环境 \env{figure} 和 \env{table}。习惯上 \env{figure} 里放图片,\env{table} 里放表格, -但并没有严格限制,可以在任何一个浮动体里放置文字、公式、表格、图片等等任意内容。 - -以 \env{table} 环境的用法举例,\env{figure} 同理: -\begin{command} -\cmd{begin}\marg*{table}\oarg{placement} \\ -\ldots \\ -\cmd{end}\marg*{table} -\end{command} - -\Arg{placement} 参数提供了一些符号用来表示浮动体允许排版的位置,如 \texttt{hbp} 允许浮动体排版在当前位置、底部或者单独成页。 -\env{table} 和 \env{figure} 浮动体的默认设置为 \texttt{tbp}。 -\begin{table}[htp] -\centering -\caption{浮动体的位置参数。}\label{tbl:float-placement} -\begin{tabular}{*{2}{l}} - \hline - \textbf{参数} & \textbf{含义} \\ - \hline - \texttt{h} & 当前位置(代码所处的上下文) \\ - \texttt{t} & 顶部 \\ - \texttt{b} & 底部 \\ - \texttt{p} & 单独成页 \\ - \texttt{!} & 在决定位置时忽视限制 \\ - \hline -\end{tabular} -\begin{quote}\footnotesize -注 1:排版位置的选取与参数里符号的顺序无关,\LaTeX\ 总是以 \texttt{h-t-b-p} 的优先级顺序决定浮动体位置。 -也就是说 \texttt{[!htp]} 和 \texttt{[ph!t]} 没有区别。\par -注 2:限制包括浮动体个数(除单独成页外,默认每页不超过 3 个浮动体,其中顶部不超过 2 个,底部不超过 1 个) -以及浮动体空间占页面的百分比(默认顶部不超过 70\%,底部不超过 30\%)。 -\end{quote} -\end{table} - -\envindex{table*,figure*} -双栏排版环境下,\LaTeX\ 提供了 \env{table*} 和 \env{figure*} 环境用来排版跨栏的浮动体。 -它们的用法与 \env{table} 和 \env{figure} 一样,不同之处为双栏的 \Arg{placement} 参数只能用 \texttt{tp} 两个位置。 - -\cmdindex{clearpage} -浮动体的位置选取受到先后顺序的限制。如果某个浮动体由于参数限制、空间限制等原因在当前页无法放置,就要推迟到之后处理, -并使得之后的同类浮动体一并推迟。\cmd{clearpage} 命令会在另起一页之前,先将所有推迟处理的浮动体排版成页, -此时 \texttt{htbp} 等位置限制被完全忽略。 - -\pkgindex{float} - -\pkg{float} 宏包为浮动体提供了 \texttt{H} 位置参数,不与 \texttt{htbp} 及 \texttt{!} 混用。使用 \texttt{H} 位置参数时, -会取消浮动机制,将浮动体视为一般的盒子插入当前位置。这在一些特殊情况下很有用(如使用 \pkg{multicol} 宏包排版分栏内容的时候), -但尺寸过大的浮动体可能使得分页比较困难。 - -\subsection{浮动体的标题}\label{subsec:caption} - -\cmdindex{caption,label} -图表等浮动体提供了 \cmd{caption} 命令加标题,并且自动给浮动体编号: -\begin{command} -\cmd{caption}\marg*{\ldots} -\end{command} -\cmd{caption} 的用法非常类似于 \cmd{section} 等命令,可以用带星号的命令 \cmd{caption*} 生成不带编号的标题, -也可以使用带可选参数的形式 \cmd{caption}\oarg*{\ldots}\marg*{\ldots},使得在目录里使用短标题。 -\cmd{caption} 命令之后还可以紧跟 \cmd{label} 命令标记交叉引用。 - -\pkgindex{caption} -\cmd{caption} 生成的标题形如 ``Figure 1: \ldots''{}(\env{figure} 环境)或 ``Table 1: \ldots''{}(\env{table} 环境)。 -可通过修改 \cmd{figurename} 和 \cmd{tablename} 的内容来修改标题的前缀(详见第 \ref{sec:latex-settings} 节)。 -标题样式的定制功能由 \pkg{caption} 宏包提供,详见该宏包的帮助文档,在此不作赘述。 - -\cmdindex{listoftables,listoffigures} -\env{table} 和 \env{figure} 两种浮动体分别有各自的生成目录的命令: -\begin{command} -\cmd{listoftables} \\ -\cmd{listoffigures} -\end{command} - -它们类似 \cmd{tableofcontents} 生成单独的章节。 - -\subsection{并排和子图表}\label{subsec:subfig} - -我们时常有在一个浮动体里面放置多张图的用法。最简单的用法就是直接并排放置, -也可以通过分段或者换行命令 \crcmd\ 排版多行多列的图片。以下为示意代码,效果大致如图 \ref{fig:parallel-fig} 所示。 -\begin{verbatim} -\begin{figure}[htbp] - \centering - \includegraphics[width=...]{...} - \qquad - \includegraphics[width=...]{...} \\[..pt] - \includegraphics[width=...]{...} - \caption{...} -\end{figure} -\end{verbatim} - -\begin{figure}[htp] - \centering - \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 10ex\hfil}} - \qquad - \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} - \par\bigskip - \fcolorbox[gray]{0}{0.96}{\parbox{20em}{\vrule width 0pt height 12ex\hfil}} - \caption{并排放置图片的示意。}\label{fig:parallel-fig} -\end{figure} - -由于标题是横跨一行的,用 \cmd{caption} 命令为每个图片单独生成标题就需要借助前文提到的 \cmd{parbox} -或者 \env{minipage} 环境,将标题限制在盒子内。效果见图 \ref{fig:parallel-cap1} 和图 \ref{fig:parallel-cap2}。 -\begin{verbatim} -\begin{figure}[htbp] - \centering - \begin{minipage}{...} - \centering - \includegraphics[width=...]{...} - \caption{...} - \end{minipage} - \qquad - \begin{minipage}{...} - \centering - \includegraphics[width=...]{...} - \caption{...} - \end{minipage} -\end{figure} -\end{verbatim} - -\begin{figure}[htp] - \centering - \begin{minipage}{12em} - \centering - \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} - \caption{并排图1。}\label{fig:parallel-cap1} - \end{minipage} - \qquad - \begin{minipage}{12em} - \centering - \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} - \caption{并排图2。}\label{fig:parallel-cap2} - \end{minipage} -\end{figure} - -\pkgindex{subfig} -\cmdindex[subfig]{subfloat} -当我们需要更进一步,给每个图片定义小标题时,就要用到 \pkg{subfig} 宏包的功能了。 -这里仅举一例,效果见图 \ref{fig:subfig}。更详细的用法请参考 \pkg{subfig} 宏包的帮助文档。 -\begin{verbatim} -\begin{figure}[htbp] - \centering - \subfloat[...]{\label{sub-fig-1}% 为子图加交叉引用 - \begin{minipage}{...} - \centering - \includegraphics[width=...]{...} - \end{minipage} - } - \qquad - \subfloat[...]{% - \begin{minipage}{...} - \centering - \includegraphics[width=...]{...} - \end{minipage} - } - \caption{...} -\end{figure} -\end{verbatim} - -\begin{figure}[htp] - \centering - \subfloat[并排子图1]{% - \begin{minipage}{12em} - \centering - \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} - \end{minipage}} - \qquad - \subfloat[并排子图2]{% - \begin{minipage}{12em} - \centering - \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} - \end{minipage}} - \caption{使用 \pkg{subfig} 宏包的 \cmd{subfloat} 命令排版子图。}\label{fig:subfig} -\end{figure} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.04.math.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.04.math.tex deleted file mode 100644 index 2c0f6fcf35b..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.04.math.tex +++ /dev/null @@ -1,894 +0,0 @@ -\chapter{排版数学公式}\label{chap:math} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -准备好了!本章将见识到 \LaTeX\ 闻名的强项——排版数学公式。当然你得注意了,本章的内容只是一点皮毛, -虽然对大多数人来说已经够用了,但是如果不能解决你的问题的话也不要大惊小怪,求助于搜索引擎或者有经验的人不失为一个好办法。 -\end{intro} -\DeclareRobustCommand*\amscmd[1]{\textcolor{blue}{\cmd{#1}}} -\DeclareRobustCommand*\amsenv[1]{\textcolor{blue}{\env{#1}}} - -\section{\AmS\ 宏集}\label{sec:ams-bundle} - -\pkgindex{amsmath,amsfonts,amssymb,amsthm} -在介绍数学公式排版之前,简单介绍一下 \AmS\ 宏集。\AmS\ 宏集合是美国数学学会(American Mathematical Society)提供的对 -\LaTeX\ 原生的数学公式排版的扩展,其核心是 \pkg{amsmath} 宏包,对多行公式的排版提供了有力的支持。 -此外,\pkg{amsfonts} 宏包以及基于它的 \pkg{amssymb} 宏包提供了丰富的数学符号;\pkg{amsthm} 宏包扩展了 \LaTeX\ 定理证明格式。 - -本章介绍的许多命令和环境依赖于 \pkg{amsmath} 宏包。这些命令和环境将以\textcolor{blue}{蓝色}示意。 - -\section{公式排版基础}\label{sec:math-basics} - -\subsection{行内和行间公式}\label{subsec:math-inline-display} - -数学公式有两种排版方式:其一是与文字混排,称为\textbf{行内公式};其二是单独列为一行排版,称为\textbf{行间公式}。 - -\pinyinindex{hangneigongshi}{行内公式} -\index{^^d@\texttt\$ (\textit{数学模式})} -行内公式由一对 \texttt\$ 符号包裹: -\begin{example} -The Pythagorean theorem is -$a^2 + b^2 = c^2$. -\end{example} - -\envindex{equation} -\cmdindex{label,ref,nonumber} -\cmdindex[amsmath]{eqref,tag,notag} -单独成行的\textbf{行间公式}在 \LaTeX\ 里由 \env{equation} 环境包裹。 -\env{equation} 环境为公式自动生成一个编号,这个编号可以用 \cmd{label} 和 \cmd{ref} 生成交叉引用, -\pkg{amsmath} 的 \amscmd{eqref} 命令甚至为引用自动加上圆括号;还可以用 \amscmd{tag} 命令手动修改公式的编号, -或者用 \amscmd{notag} 命令取消为公式编号(与之基本等效的命令是 \cmd{nonumber})。 - -\begin{example} -The Pythagorean theorem is: -\begin{equation} -a^2 + b^2 = c^2 \label{pythagorean} -\end{equation} -Equation \eqref{pythagorean} is -called `Gougu theorem' in Chinese. -\end{example} - -\begin{example} -It's wrong to say -\begin{equation} -1 + 1 = 3 \tag{dumb} -\end{equation} -or -\begin{equation} -1 + 1 = 4 \notag -\end{equation} -\end{example} - -\cmdindex{[,]} -\envindex{displaymath} -\envindex[amsmath]{equation*} -如果需要直接使用不带编号的行间公式,则将公式用命令 \cmd{[} 和 \cmd{]} 包裹% -\footnote{\TeX\ 原生排版行间公式的方法是用一对 \texttt{\$\$} 符号包裹,不过无法通过指定 \texttt{fleqn} 选项控制左对齐, -与上下文之间的间距也不好调整,故不太推荐使用。}, -与之等效的是 \env{displaymath} 环境。有的人更喜欢 \amsenv{equation*} 环境,体现了带星号和不带星号的环境之间的区别。 - -\begin{example} -\begin{equation*} -a^2 + b^2 = c^2 -\end{equation*} -For short: -\[ a^2 + b^2 = c^2 \] -Or if you like the long one: -\begin{displaymath} -a^2 + b^2 = c^2 -\end{displaymath} -\end{example} - -我们通过一个例子展示行内公式和行间公式的对比。为了与文字相适应,行内公式在排版大的公式元素(分式、巨算符等)时显得很“局促”: - -\begin{example} -In text: -$\lim_{n \to \infty} -\sum_{k=1}^n \frac{1}{k^2} -= \frac{\pi^2}{6}$. - -In display: -\[ -\lim_{n \to \infty} -\sum_{k=1}^n \frac{1}{k^2} -= \frac{\pi^2}{6} -\] -\end{example} - -行间公式的对齐、编号位置等性质由文档类选项控制,文档类的 \texttt{fleqn} 选项令行间公式左对齐; -\texttt{leqno} 选项令编号放在公式左边。 - -\subsection{数学模式}\label{subsec:math-mode} - -\pinyinindex{shuxuemoshi}{数学模式} -\cmdindex[amsmath]{text} -当你使用 \texttt\$ 开启行内公式输入,或是使用 \cmd{[} 命令、\env{equation} 环境时,\LaTeX\ 就进入了\textbf{数学模式}。 -数学模式相比于文本模式有以下特点: -\begin{enumerate} - \item 数学模式中输入的空格被忽略。数学符号的间距默认由符号的性质(关系符号、运算符等)决定。 - 需要人为引入间距时,使用 \cmd{quad} 和 \cmd{qquad} 等命令。详见 \ref{sec:math-space} 节。 - \item \textbf{不允许有空行(分段)}。行间公式中也无法用 \crcmd\ 命令手动换行。排版多行公式需要用到 \ref{sec:multi-eqns} 节介绍的各种环境。 - \item 所有的字母被当作数学公式中的变量处理,字母间距与文本模式不一致,也无法生成单词之间的空格。 - 如果想在数学公式中输入正体的文本,简单情况下可用 \ref{subsec:math-alpha} 小节中提供的 \cmd{mathrm} 命令。 - 或者用 \pkg{amsmath} 提供的 \amscmd{text} 命令% - \footnote{\amscmd{text} 命令仅适合在公式中穿插少量文字。如果你的情况正好相反,需要在许多文字中穿插使用公式, - 则应该像正常的行内公式那样用,而不是滥用 \amscmd{text} 命令。}。 -\end{enumerate} -\begin{example} -$x^{2} \geq 0 \qquad -\text{for \textbf{all} } -x\in\mathbb{R}$ -\end{example} - -\section{数学符号}\label{sec:math-symbols} - -\def\msym#1{$\csname #1\endcsname$ (\cmd{#1})} - -\pkgindex{amssymb} -本节我们将接触到形形色色的数学符号,它们是 \LaTeX\ 卓越的数学公式排版能力的基础。\LaTeX\ 默认提供了常用的数学符号, -\pkg{amssymb} 宏包提供了一些次常用的符号。大多数常用的数学符号都能在本章末尾的 \ref{sec:math-tables} 节列出的各个表格里查到。 -更多符号可查阅参考文献\cite{symbols}。 - -\subsection{一般符号}\label{subsec:math-general} - -\pinyinindex{xilazimu}{希腊字母 (数学符号)} -\msymindex{infty} -希腊字母符号的名称就是其英文名称,如 \msym{alpha}、\msym{beta} 等等。 -大写的希腊字母为首字母大写的命令,如 \msym{Gamma}、\msym{Delta} 等等。 -无穷大符号为 \msym{infty}。更多符号命令可参考表 \ref{tbl:math-greek} 和 \ref{tbl:math-misc} 等。 - -\msymindex{dots,ldots,cdots} -省略号有 \msym{dots} 和 \msym{cdots} 两种形式。它们有各自合适的用途: -\begin{example} -$a_1, a_2, \dots, a_n$ \\ -$a_1 + a_2 + \cdots + a_n$ -\end{example} - -\cmd{ldots} 和 \cmd{dots} 是完全等效的,它们既能用在公式中,也用来在文本里作为省略号(详见 \ref{subsec:punct} 小节)。 -除此之外,在矩阵中可能会用到竖排的 \msym{vdots} 和斜排的 \msym{ddots}。 - -\subsection{指数、上下标和导数}\label{subsec:math-scripts} - -\index{^@\texttt\textasciicircum\ (\textit{数学上标})} -\index{_@\texttt\textunderscore\ (\textit{数学下标})} -在 \LaTeX\ 中用 \texttt\textasciicircum 和 \texttt\textunderscore 标明上下标。注意上下标的内容(子公式)一般需要\textbf{用花括号包裹}, -否则上下标只对后面的一个符号起作用。 -\begin{example} -$p^3_{ij} \qquad -m_\mathrm{Knuth}\qquad -\sum_{k=1}^3 k $\\[5pt] -$a^x+y \neq a^{x+y}\qquad -e^{x^2} \neq {e^x}^2$ -\end{example} - -\pinyinindex{daoshu}{导数符号\texttt' ($a'$)} -导数符号\texttt'(${}'$)是一类特殊的上标,可以适当连用表示多阶导数,也可以在其后连用上标: -\begin{example} -$f(x) = x^2 \quad f'(x) -= 2x \quad f''^{2}(x) = 4$ -\end{example} - -\subsection{分式和根式}\label{subsec:frac-sqrt} - -\mathindex{frac} -\cmdindex[amsmath]{dfrac,tfrac} -分式使用 \cmd{frac}\marg*{分子}\marg*{分母} 来书写。分式的大小在行间公式中是正常大小,而在行内被极度压缩。 -\pkg{amsmath} 提供了方便的命令 \amscmd{dfrac} 和 \amscmd{tfrac},令用户能够在行内使用正常大小的分式,或是反过来。 -\begin{example} -In display style: -\[ -3/8 \qquad \frac{3}{8} -\qquad \tfrac{3}{8} -\] -In text style: -$1\frac{1}{2}$~hours \qquad -$1\dfrac{1}{2}$~hours -\end{example} - -\mathindex{sqrt} -一般的根式使用 \cmd{sqrt}\marg*{...};表示 $n$ 次方根时写成 \cmd{sqrt}\oarg*{\textit{n}}\marg*{...}。 -\begin{example} -$\sqrt{x} \Leftrightarrow x^{1/2} -\quad \sqrt[3]{2} -\quad \sqrt{x^{2} + \sqrt{y}}$ -\end{example} - -\cmdindex[amsmath]{binom} -特殊的分式形式,如二项式结构,由 \pkg{amsmath} 宏包的 \amscmd{binom} 命令生成: -\begin{example} -Pascal's rule is -\[ -\binom{n}{k} =\binom{n-1}{k} -+ \binom{n-1}{k-1} -\] -\end{example} - -\subsection{关系符}\label{subsec:math-rel} - -\msymindex{ne,ge,le,approx,equiv,propto,sim} -\LaTeX\ 常见的关系符号除了可以直接输入的 $=$,$>$,$<$,其它符号用命令输入,常用的有不等号 \msym{ne}、 -大于等于号 \msym{ge} 和小于等于号 \msym{le}% -\footnote{倾斜的关系符号 \msym{leqslant} 和 \msym{geqslant} 由 \pkg{amssymb} 提供,见表 \ref{tbl:ams-rel}。}、 -约等号 \msym{approx}、等价 \msym{equiv}、正比 \msym{propto}、相似 \msym{sim} 等等。 -更多符号命令可参考表 \ref{tbl:math-rel} 以及表 \ref{tbl:ams-rel}。 - -\mathindex{stackrel} -\LaTeX\ 还提供了自定义二元关系符的命令 \cmd{stackrel},用于将一个符号叠加在原有的二元关系符之上: -\begin{example} -\[ -f_n(x) \stackrel{*}{\approx} 1 -\] -\end{example} - -\subsection{算符}\label{subsec:math-op} - -\msymindex{times,div,cdot,pm,mp} -\LaTeX\ 中的算符大多数是二元算符,除了直接用键盘可以输入的 $+$、$-$、$*$、$/$,其它符号用命令输入, -常用的有乘号 \msym{times}、 除号 \msym{div}、点乘 \msym{cdot}、加减号 \msym{pm} / \msym{mp} 等等。 -更多符号命令可参考表 \ref{tbl:math-op} 以及表 \ref{tbl:ams-op}。 - -\msymindex{nabla,partial} -\msym{nabla} 和 \msym{partial} 也是常用的算符,虽然它们不属于二元算符。 - -\pinyinindex{shuxuehanshu}{数学函数} -\LaTeX\ 将数学函数的名称作为一个算符排版,字体为直立字体。其中有一部分符号在上下位置可以书写一些内容作为条件, -类似于后文所叙述的巨算符。 - -\begin{table}[htp] -\centering -\caption{\LaTeX\ 作为算符的函数名称一览。}\label{tbl:math-functions} -\begin{tabular}{*{5}{p{5em}}} -\hline -\multicolumn{5}{c}{\textbf{不带上下限的算符}} \\ -\hline -\cmd{sin} & \cmd{arcsin} & \cmd{sinh} & \cmd{exp} & \cmd{dim} \\ -\cmd{cos} & \cmd{arccos} & \cmd{cosh} & \cmd{log} & \cmd{ker} \\ -\cmd{tan} & \cmd{arctan} & \cmd{tanh} & \cmd{lg} & \cmd{hom} \\ -\cmd{cot} & \cmd{arg} & \cmd{coth} & \cmd{ln} & \cmd{deg} \\ -\cmd{sec} & \cmd{csc} & \\ -\hline -\multicolumn{5}{c}{\textbf{带上下限的算符}} \\ -\hline -\cmd{lim} & \cmd{limsup} & \cmd{liminf} & \cmd{sup} & \cmd{inf} \\ -\cmd{min} & \cmd{max} & \cmd{det} & \cmd{Pr} & \cmd{gcd} \\ -\hline -\end{tabular} -\end{table} - -\begin{example} -\[ - \lim_{x \rightarrow 0} - \frac{\sin x}{x}=1 -\] -\end{example} - -\mathindex{pmod,bmod} -对于求模表达式,\LaTeX\ 提供了 \cmd{pmod} 和 \cmd{bmod} 命令,前者相当于一个二元运算符,后者作为同余表达式的后缀: -\begin{example} -$a\bmod b \\ - x\equiv a \pmod{b}$ -\end{example} - -\cmdindex[amsmath]{DeclareMathOperator} -如果表 \ref{tbl:math-functions} 中的算符不够用的话,\pkg{amsmath} 允许用户用 \amscmd{Declare\-Math\-Operator} -定义自己的算符,其中带星号的命令定义带上下限的算符: -\begin{verbatim} -\DeclareMathOperator{\argh}{argh} -\DeclareMathOperator*{\nut}{Nut} -\end{verbatim} - -\begin{example} -\[\argh 3 = \nut_{x=1} 4x\] -\end{example} - -\subsection{巨算符}\label{subsec:math-bigop} - -\msymindex{int,oint,sum,prod} -积分号 \msym{int}、求和号 \msym{sum} 等符号称为\textbf{巨算符}。巨算符在行内公式和行间公式的大小和形状有区别。 -\begin{example} -In text: -$\sum_{i=1}^n \quad -\int_0^{\frac{\pi}{2}} \quad -\oint_0^{\frac{\pi}{2}} \quad -\prod_\epsilon $ \\ -In display: -\[\sum_{i=1}^n \quad -\int_0^{\frac{\pi}{2}} \quad -\oint_0^{\frac{\pi}{2}} \quad -\prod_\epsilon \] -\end{example} - -\mathindex{limits,nolimits} -巨算符的上下标位置可由 \cmd{limits} 和 \cmd{nolimits} 控制,前者令巨算符类似 $\lim$ 或求和算符 $\sum$,上下标位于上下方; -后者令巨算符类似积分号,上下标位于右上方和右下方。 -\begin{example} -In text: -$\sum\limits_{i=1}^n \quad -\int\limits_0^{\frac{\pi}{2}} \quad -\prod\limits_\epsilon $ \\ -In display: -\[\sum\nolimits_{i=1}^n \quad -\int\limits_0^{\frac{\pi}{2}} \quad -\prod\nolimits_\epsilon \] -\end{example} - -\cmdindex[amsmath]{substack} -\envindex[amsmath]{subarray} -\pkg{amsmath} 宏包还提供了 \amscmd{substack},能够在下限位置书写多行表达式;\amsenv{subarray} -环境更进一步,令多行表达式可选择居中 (c) 或左对齐 (l): -\begin{example} -\[ -\sum_{\substack{0\le i\le n \\ - j\in \mathbb{R}}} -P(i,j) = Q(n) -\] -\[ -\sum_{\begin{subarray}{l} - 0\le i\le n \\ - j\in \mathbb{R} -\end{subarray}} -P(i,j) = Q(n) -\] -\end{example} - -\subsection{数学重音和上下括号}\label{subsec:math-accents} - -\maccindex{dot,ddot,vec,hat} -数学符号可以像文字一样加重音,比如求导符号 $\dot{r}$ (\cmd{dot}\marg*{r})、 $\ddot{r}$ (\cmd{ddot}\marg*{r})、 -表示向量的箭头 $\vec{r}$ (\cmd{vec}\marg*{r}) 、表示单位向量的符号 $\hat{\mathbf{e}}$ (\cmd{hat}\marg*{\cmd{mathbf}\marg*{e}}) 等, -详见表 \ref{tbl:math-accents}。使用时要注意重音符号的作用区域,一般应当对某个符号而不是“符号加下标”使用重音: -\begin{example} -$\bar{x_0} \quad \bar{x}_0$\\[5pt] -$\vec{x_0} \quad \vec{x}_0$\\[5pt] -$\hat{\mathbf{e}_x} \quad - \hat{\mathbf{e}}_x$ -\end{example} - -\waccindex{overline,underline} -\waccindex{widehat,overrightarrow} -\LaTeX\ 也能为多个字符加重音,包括直接画线的 \cmd{overline} 和 \cmd{underline} 命令(可叠加使用)、宽重音符号 \cmd{widehat}、 -表示向量的箭头 \cmd{overrightarrow} 等。后两者详见表 \ref{tbl:math-accents} 和 \ref{tbl:math-arrow-accents} 等。 -\begin{example} -$0.\overline{3} = -\underline{\underline{1/3}}$ \\[5pt] -$\hat{XY} \qquad \widehat{XY}$\\[5pt] -$\vec{AB} \qquad -\overrightarrow{AB}$ -\end{example} - -\waccindex{overbrace,underbrace} -\cmd{overbrace} 和 \cmd{underbrace} 命令用来生成上/下括号,各自可带一个上/下标公式。 -\begin{example} -$\underbrace{\overbrace{(a+b+c)}^6 -\cdot \overbrace{(d+e+f)}^7} -_\text{meaning of life} = 42$ -\end{example} - -\subsection{箭头}\label{subsec:math-arrows} - -\msymindex{to,rightarrow,leftarrow,uparrow,downarrow} -常用的箭头包括 \cmd{rightarrow} ($\rightarrow$,或 \cmd{to})、\cmd{leftarrow}($\leftarrow$,或 \cmd{gets})等。 -更多箭头详见表 \ref{tbl:math-arrows}。 - -\cmdindex[amsmath]{xleftarrow,xrightarrow} -\pkg{amsmath} 的 \amscmd{xleft\-arrow} 和 \amscmd{xright\-arrow} 命令提供了长度可以伸展的箭头,并且可以为箭头增加上下标: -\begin{example} -\[ a\xleftarrow{x+y+z} b \] -\[ c\xrightarrow[x 0. -\end{array} \right. \] -\end{example} - -\envindex[amsmath]{cases} -不过上述例子可以用 \pkg{amsmath} 提供的 \amsenv{cases} 环境更轻松地完成: -\begin{example} -\[ |x| = -\begin{cases} --x & \text{if } x < 0,\\ -0 & \text{if } x = 0,\\ -x & \text{if } x > 0. -\end{cases} \] -\end{example} - -\envindex[amsmath]{matrix,pmatrix,bmatrix,Bmatrix,vmatrix,Vmatrix} -我们当然也可以用 \env{array} 环境排版各种矩阵。\pkg{amsmath} 宏包还直接提供了多种排版矩阵的环境,包括不带定界符的 \amsenv{matrix}, -以及带各种定界符的矩阵 \amsenv{pmatrix}($\bigl($)、\amsenv{bmatrix}($\bigl[$)、\amsenv{Bmatrix}($\bigl\{$)、 -\amsenv{vmatrix}($\bigl\vert$)、\amsenv{Vmatrix}($\bigl\Vert$)。使用这些环境时,无需给定列格式% -\footnote{事实上这些矩阵内部也是用 \env{array} 环境生成的,列格式默认为 \texttt{*\{\Arg{n}\}\{c\}},\Arg{n} 默认为 10; -\amsenv{cases} 内部是一个列格式为 \texttt{@\{\}l@\{\cmd{quad}\}l@\{\}} 的 \env{array} 环境。}: -\begin{example} -\[ -\begin{matrix} -1 & 2 \\ 3 & 4 -\end{matrix} \qquad -\begin{bmatrix} -x_{11} & x_{12} & \ldots & x_{1n}\\ -x_{21} & x_{22} & \ldots & x_{2n}\\ -\vdots & \vdots & \ddots & \vdots\\ -x_{n1} & x_{n2} & \ldots & x_{nn}\\ -\end{bmatrix} -\] -\end{example} - -在矩阵中的元素里排版分式时,一来要用到 \amscmd{dfrac} 等命令,二来行与行之间有可能紧贴着,这时要用到 -\ref{subsec:tabular-colht} 小节的方法来调节间距: -\begin{example} -\[ -\mathbf{H}= -\begin{bmatrix} -\dfrac{\partial^2 f}{\partial x^2} & -\dfrac{\partial^2 f} - {\partial x \partial y} \\[8pt] -\dfrac{\partial^2 f} - {\partial x \partial y} & -\dfrac{\partial^2 f}{\partial y^2} -\end{bmatrix} -\] -\end{example} - -\section{公式中的间距}\label{sec:math-space} - -\cmdindex{quad,qquad} -\index{,@\cmd{,}} % The only one which cannot use \cmdindex, oops.. -\mathindex{:,;,"!} -前文提到过,绝大部分时候,数学公式中各元素的间距是根据符号类型自动生成的,需要我们手动调整的情况极少。 -我们已经认识了两个生成间距的命令 \cmd{quad} 和 \cmd{qquad}。在公式中我们还可能用到的间距包括 \cmd{,}、\cmd{:}、\cmd{;} -以及负间距 \cmd{!},其中 \cmd{quad} 、 \cmd{qquad} 和 \cmd{,} 在文本和数学环境中可用,后三个命令只用于数学环境。 -文本中的 \cmd{\textvisiblespace} 也能使用在数学公式中。 - -\newdimen\testdimen \testdimen=\fontdimen6\textfont2 \divide\testdimen18\relax -\begin{center} -\begin{tabularx}{0.9\textwidth}{*{3}{>{\raggedright\arraybackslash}X}|*{3}{>{\raggedright\arraybackslash}X}} - \hline - 无额外间距 & & $a a$ & - \cmd{,} & \demowidth{3\testdimen} & $a\,a$ \\ - \cmd{quad} & \demowidth{18\testdimen} & $a\quad a$ & - \cmd{:} & \demowidth{4\testdimen} & $a\:a$ \\ - \cmd{qquad} & \demowidth{36\testdimen} & $a\qquad a$ & - \cmd{;} & \demowidth{5\testdimen} & $a\;a$ \\ - \cmd{\textvisiblespace} & \demowidth{\fontdimen2\textfont0} & $a\ a$ & - \cmd{!} & $-$\demowidth{3\testdimen} & $a\!a$ \\ - \hline -\end{tabularx} -\end{center} - -一个常见的用途是修正积分的被积函数$f(x)$和微元$\mathrm{d}x$之间的距离。注意微元里的$\mathrm{d}$用的是直立体: -\begin{example} -\[ -\int_a^b f(x)\mathrm{d}x -\qquad -\int_a^b f(x)\,\mathrm{d}x -\] -\end{example} - -另一个用途是生成多重积分号。如果我们直接连写两个 \cmd{int},之间的间距将会过宽,此时可以使用负间距 \cmd{!} 修正之。 -不过 \pkg{amsmath} 提供了更方便的多重积分号,如二重积分 \amscmd{iint}、三重积分 \amscmd{iiint} 等。 -\begin{example} -\newcommand\diff{\,\mathrm{d}} -\begin{gather*} -\int\int f(x)g(y) -\diff x \diff y \\ -\int\!\!\!\int -f(x)g(y) \diff x \diff y \\ -\iint f(x)g(y) \diff x \diff y \\ -\iint\quad \iiint\quad \idotsint -\end{gather*} -\end{example} - -\section{数学符号的字体控制}\label{sec:math-fonts} - -\subsection{数学字母字体}\label{subsec:math-alpha} - -\mathindex{mathrm,mathsf,mathtt,mathit,mathbf,mathcal,mathnormal} -\cmdindex[amssymb]{mathbb,mathfrak} -\cmdindex[mathrsfs]{mathscr} -\LaTeX\ 允许一部分数学符号切换字体,主要是拉丁字母、数字等等。 -表 \ref{tbl:math-fonts} 给出了切换字体的命令。某一些命令需要字体宏包的支持。 -\begin{example} -$\mathcal{R} \quad \mathfrak{R} -\quad \mathbb{R}$ -\[\mathcal{L} -= -\frac{1}{4}F_{\mu\nu}F^{\mu\nu}\] -$\mathfrak{su}(2)$ and -$\mathfrak{so}(3)$ Lie algebra -\end{example} - -\begin{table}[htp] -\centering -\caption{数学字母字体。} \label{tbl:math-fonts} -\begin{tabular}{*{3}{l}} -\hline -\textbf{示例} & \textbf{命令} & \textbf{依赖的宏包}\\ -\hline -$\mathnormal{ABCDE abcde 1234}$ & \cmd{mathnormal}\marg*{\ldots}& \\ -$\mathrm{ABCDE abcde 1234}$ & \cmd{mathrm}\marg*{\ldots} & \\ -$\mathit{ABCDE abcde 1234}$ & \cmd{mathit}\marg*{\ldots} & \\ -$\mathbf{ABCDE abcde 1234}$ & \cmd{mathbf}\marg*{\ldots} & \\ -$\mathsf{ABCDE abcde 1234}$ & \cmd{mathsf}\marg*{\ldots} & \\ -$\mathtt{ABCDE abcde 1234}$ & \cmd{mathtt}\marg*{\ldots} & \\ -$\CMcal{ABCDE}$ & \cmd{mathcal}\marg*{\ldots} & 只大写字母 \\ -\hline -$\EuScript{ABCDE}$ & \cmd{mathcal}\marg*{\ldots} & \pkg{eucal},只大写字母 \\ -$\mathscr{ABCDE}$ & \cmd{mathscr}\marg*{\ldots} & \pkg{mathrsfs},只大写字母\\ -$\mathfrak{ABCDE abcde 1234}$ & \cmd{mathfrak}\marg*{\ldots} & \pkg{amssymb} 或 \pkg{eufrak} \\ -$\mathbb{ABCDE}$ & \cmd{mathbb}\marg*{\ldots} & \pkg{amssymb},只大写字母 \\ -\hline -\end{tabular} -\end{table} - -\subsection{数学符号的尺寸}\label{subsec:math-styles} - -\mathindex{displaystyle,textstyle,scriptstyle,scriptscriptstyle} -数学符号按照符号排版的位置规定尺寸,从大到小包括行间公式尺寸、行内公式尺寸、上下标尺寸、次级上下标尺寸。 -除了字号有别之外,行间和行内公式尺寸下的巨算符也使用不一样的大小。\LaTeX\ 为每个数学尺寸指定了一个切换的命令,见 \ref{tbl:math-size}。 -\begin{table}[htp] -\centering -\caption{数学符号尺寸。}\label{tbl:math-size} -\begin{tabular}{lll} - \hline - \textbf{命令} & \textbf{尺寸} & \textbf{示例} \\ - \hline -\cmd{displaystyle} & 行间公式尺寸 & $\displaystyle\sum a $\\ -\cmd{textstyle} & 行内公式尺寸 & $\textstyle\sum a $ \\ -\cmd{scriptstyle} & 上下标尺寸 & $\scriptstyle a$ \\ -\cmd{scriptscriptstyle} & 次级上下标尺寸 & $\scriptscriptstyle a$\\ - \hline -\end{tabular} -\end{table} - -例如行间公式的分式内,分子分母使用行内公式尺寸,巨算符采用行内尺寸的形式。对比一下分子分母使用 \cmd{display\-style} 命令与否的区别: -\begin{example} -\[ -P = \frac - {\sum_{i=1}^n (x_i- x)(y_i- y)} - {\displaystyle \left[ - \sum_{i=1}^n (x_i-x)^2 - \sum_{i=1}^n (y_i-y)^2 - \right]^{1/2} } -\] -\end{example} - -\subsection{加粗的数学符号}\label{subsec:math-bold} - -在 \LaTeX\ 中为符号切换数学字体并不十分自由,只能通过 \cmd{mathbf} 等有限的命令切换字体。比如想得到粗斜体的符号,就没有现成的命令% -\footnote{国内使用粗斜体符号表示矢量,见 GB3102-11.93。};再比如 \cmd{mathbf} 只能改变拉丁字母,希腊字母就没有用。 - -\cmdindex{boldmath} -\LaTeX\ 提供了一个命令 \cmd{boldmath} 令用户可以将整套数学字体切换为粗体版本。但这个命令\textbf{只能在公式外使用}: -\begin{example} -$\mu, M \qquad -\mathbf{\mu}, \mathbf{M}$ -\qquad {\boldmath$\mu, M$} -\end{example} - -\cmdindex[amsmath]{boldsymbol} -\pkg{amsmath} 提供了一个 \amscmd{boldsymbol} 命令(由调用的 \pkg{amsbsy} 宏包提供),用于打破 \cmd{boldmath} 的限制, -在公式内部将一部分符号切换为粗体。 -\begin{example} -$\mu, M \qquad -\boldsymbol{\mu}, \boldsymbol{M}$ -\end{example} - -\pkgindex{bm} -\cmdindex[bm]{bm} -然而定界符、巨算符等一些符号本身没有粗体版本,\amscmd{boldsymbol} 也得不到粗体。 -\LaTeX\ 工具宏集之一的 \pkg{bm} 宏包可以用 \cmd{bm} 命令生成“伪粗体”,一定程度上解决了不带粗体版本的符号的问题。这里不做过多介绍, -详情请参考 \pkg{bm} 宏包的帮助文档。 - -\section{定理环境}\label{sec:theorems} - -\subsection{\LaTeX\ 原始的定理环境}\label{subsec:latex-theorems} - -\cmdindex{newtheorem} -使用 \LaTeX\ 排版数学和其他科技文档时,会接触到大量的定理、证明等内容。 -\LaTeX\ 提供了一个基本的命令 \cmd{newtheorem} 提供定理环境的定义: -\begin{command} -\cmd{newtheorem}\marg{theorem environment}\marg{title}\oarg{section-level} \\ -\cmd{newtheorem}\marg{theorem environment}\oarg{counter}\marg{title} -\end{command} - -\Arg{theorem environment} 为定理环境的名称。原始的\LaTeX\ 里\textbf{没有现成的定理环境}, -不加定义而直接使用很可能会出错。\Arg{title} 是定理环境的标题(“定理”,“公理”等)。 - -定理的序号由两个可选参数之一决定,它们\textbf{不能同时使用}: -\begin{itemize} - \item \Arg{section level} 为章节级别,如 \texttt{chapter}、\texttt{section} 等,定理序号成为章节的下一级序号; - \item \Arg{counter} 为用 \cmd{newcounter} 自定义的计数器名称(详见 \ref{sec:counters} 节),定理序号由这个计数器管理。 -\end{itemize} -如果两个可选参数都不用的话,则使用默认的与定理环境同名的计数器。 - -在以下示例代码中,我们定义了一个 \env{mythm} 环境,其序号设为 \texttt{section} 的下一级序号。 -注意 \env{mythm} 环境的可选参数以及 \cmd{label} 的用法: -\begin{example} -\newtheorem{mythm}{My Theorem}[section] -\begin{mythm}\label{thm:light} -The light speed in vacuum -is $299,792,458\,\mathrm{m/s}$. -\end{mythm} -\begin{mythm}[Energy-momentum relation] -The relationship of energy, -momentum and mass is -\[E^2 = m_0^2 c^4 + p^2 c^2\] -where $c$ is the light speed -described in theorem \ref{thm:light}. -\end{mythm} -\end{example} - -\subsection{\pkg{amsthm} 宏包}\label{subsec:amsthm} - -\LaTeX\ 默认的定理环境格式为粗体标签、斜体正文、定理名用小括号包裹。如果需要修改格式, -则要依赖其它的宏包,如 \pkg{amsthm}、\pkg{ntheorem} 等等。本小节简单介绍一下 \pkg{amsthm} 的用法。 - -\pkgindex{amsthm} -\cmdindex[amsthm]{theoremstyle} -\pkg{amsthm} 提供了 \cmd{theo\-rem\-style} 命令支持定理格式的切换, -在用 \cmd{new\-theo\-rem} 命令定义定理环境之前使用。 -\pkg{amsthm} 预定义了三种格式用于 \cmd{theo\-rem\-style}:\texttt{plain} 和 \LaTeX\ 原始的格式一致; -\texttt{defi\-ni\-tion} 使用粗体标签、正体内容;\texttt{remark} 使用斜体标签、正体内容。 - -另外 \pkg{amsthm} 还支持用带星号的 \cmd{new\-theo\-rem*} 定义不带序号的定理环境: -\begin{verbatim} -\theoremstyle{definition} \newtheorem{law}{Law} -\theoremstyle{plain} \newtheorem{jury}[law]{Jury} -\theoremstyle{remark} \newtheorem*{mar}{Margaret} -\end{verbatim} -\theoremstyle{definition} \newtheorem{law}{Law} -\theoremstyle{plain} \newtheorem{jury}[law]{Jury} -\theoremstyle{remark} \newtheorem*{mar}{Margaret} - -以上例子定义的 \env{jury} 环境与 \env{law} 环境共用编号,\env{mar} 环境不编号: -\begin{example} -\begin{law}\label{law:box} -Don't hide in the witness box. -\end{law} -\begin{jury}[The Twelve] -It could be you! So beware and -see law~\ref{law:box}.\end{jury} -\begin{jury} -You will disregard the last -statement.\end{jury} -\begin{mar}No, No, No\end{mar} -\begin{mar}Denis!\end{mar} -\end{example} - -\pkg{amsthm} 还支持使用 \cmd{new\-theorem\-style} 命令自定义定理格式, -更为方便使用的是 \pkg{ntheorem} 宏包。感兴趣的读者可参阅它们的帮助文档。 - -\subsection{证明环境和证毕符号}\label{subsec:proof} - -\envindex[amsthm]{proof} -\pkg{amsthm} 还提供了一个 \env{proof} 环境用于排版定理的证明过程。\env{proof} 环境末尾 -自动加上一个 \qedsymbol\ 证毕符号: -\begin{example} -\begin{proof} -For simplicity, we use -\[ -E=mc^2 -\] -That's it. -\end{proof} -\end{example} - -\cmdindex[amsthm]{qedhere} -如果行末是一个不带编号的公式,\qedsymbol\ 符号会另起一行, -这时可使用 \cmd{qedhere} 命令将 \qedsymbol\ 符号放在公式末尾: -\begin{example} -\begin{proof} -For simplicity, we use -\[ -E=mc^2 \qedhere -\] -\end{proof} -\end{example} - -\cmd{qedhere} 对于 \amsenv{align*} 等命令也有效: -\begin{example} -\begin{proof} -Assuming $\gamma -= 1/\sqrt{1-v^2/c^2}$, then -\begin{align*} -E &= \gamma m_0 c^2 \\ -p &= \gamma m_0v \qedhere -\end{align*} -\end{proof} -\end{example} - -在使用带编号的公式时,建议最好\textbf{不要在公式末尾使用} \cmd{qedhere} 命令。 -对带编号的公式使用 \cmd{qedhere} 命令会使 \qedsymbol\ 符号放在一个难看的位置,紧贴着公式: -\begin{example} -\begin{proof} -For simplicity, we use -\begin{equation} -E=mc^2.\qedhere -\end{equation} -\end{proof} -\end{example} - -在 \amsenv{align} 等环境中使用 \cmd{qedhere} 命令会使 \qedsymbol\ 盖掉公式的编号;使用 \env{equation} 嵌套 \amsenv{aligned} 等环境时, -\cmd{qedhere} 命令会将 \qedsymbol\ 直接放在公式后。这些位置都不太正常。 - -证毕符号 \qedsymbol\ 本身被定义在命令 \cmd{qedsymbol} 中,如果有使用实心符号作为证毕符号的需求,需要自行用 \cmd{re\-new\-comm\-and} -命令修改(用法见 \ref{subsec:newcmd} 小节)\footnote{注意,这个改法\textbf{只对 \pkg{amsthm} 宏包适用}。 -其它宏包如 \pkg{ntheorem} 等须参考帮助文档里提供的修改方法。}。 -我们可以利用在 \ref{subsec:rules} 小节介绍的标尺盒子来生成一个适当大小的“实心矩形”: -\begin{example} -\renewcommand{\qedsymbol}% - {\rule{1ex}{1.5ex}} -\begin{proof} -For simplicity, we use -\[ -E=mc^2 \qedhere -\] -\end{proof} -\end{example} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.05.style.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.05.style.tex deleted file mode 100644 index 20a39c10e36..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.05.style.tex +++ /dev/null @@ -1,696 +0,0 @@ -\chapter{排版样式设定}\label{chap:styles} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -至此你已经基本学会排版内容丰富的文档,标题、目录、章节、公式、列表、图片、表格等等应有尽有。但是你可能已经有点不甘心了, -因为似乎你排版出来的文档是千篇一律的模样——\LaTeX\ 默认的字体、单调的页眉页脚、不太令你满意的页边距,等等。 -本章的内容将带你一览如何修改 \LaTeX\ 的排版样式。 -\end{intro} - -\section{字体和字号}\label{sec:font} - -\LaTeX\ 根据文档的逻辑结构(章节、脚注等)来选择默认的字体样式以及字号。 -需要更改字体样式或字号的话,可以使用表 \ref{tbl:fonts} 和表 \ref{tbl:sizes} 中列出的命令。 -\begin{example} -{\small The small and -\textbf{bold} Romans ruled} -{\Large all of great big -{\itshape Italy}.} -\end{example} - -\LaTeXe\ 相比于较早的 \LaTeX\ 版本(2.09版或更早)在字体样式和字号的设定上有很大改进,令字体的各种属性相互独立(“正交”), -用户可以改变字体的大小,而仍然保留字体原有的粗体或者斜体的特性。 - -\subsection{字体样式}\label{subsec:fontshape} - -\pinyinindex{ziti}{字体} -\pinyinindex{fenzu}{分组} -\LaTeX\ 提供了两组修改字体的命令,见表 \ref{tbl:fonts}。其中诸如 \cmd{bfseries} 形式的命令将会影响之后所有的字符, -如果想要让它在局部生效,需要用花括号\textbf{分组},也就是写成 \marg*{\cmd{bfseries}\ \Arg{some text}} 这样的形式; -对应的 \cmd{textbf} 形式带一个参数,只改变参数内部的字体,更为常用。 - -在公式中,直接使用 \cmd{textbf} 等命令不会起效,甚至报错。\LaTeX\ 已有修改数学字体的命令,详见 \ref{subsec:math-alpha} 小节。 - -\begin{table}[htp] -\caption{字体命令。} \label{tbl:fonts} -\centering -\begin{tabular}{*{4}{l}} -\hline -\cmd{rmfamily}\cmdindex{rmfamily} & \cmd{textrm}\cmdindex{textrm}\marg*{\ldots} & \textrm{roman} & 衬线字体(罗马体)\\ -\cmd{sffamily}\cmdindex{sffamily} & \cmd{textsf}\cmdindex{textsf}\marg*{\ldots} & \textsf{sans serif} & 无衬线字体 \\ -\cmd{ttfamily}\cmdindex{ttfamily} & \cmd{texttt}\cmdindex{texttt}\marg*{\ldots} & \texttt{typewriter} & 等宽字体 \\[\medskipamount] -\cmd{mdseries}\cmdindex{mdseries} & \cmd{textmd}\cmdindex{textmd}\marg*{\ldots} & \textrm{medium} & 正常粗细(中等) \\ -\cmd{bfseries}\cmdindex{bfseries} & \cmd{textbf}\cmdindex{textbf}\marg*{\ldots} & \textbf{bold face} & 粗体 \\[\medskipamount] -\cmd{upshape}\cmdindex{upshape} & \cmd{textup}\cmdindex{textup}\marg*{\ldots} & \textup{upright} & 直立体 \\ -\cmd{itshape}\cmdindex{itshape} & \cmd{textit}\cmdindex{textit}\marg*{\ldots} & \textit{italic} & 意大利斜体 \\ -\cmd{slshape}\cmdindex{slshape} & \cmd{textsl}\cmdindex{textsl}\marg*{\ldots} & \textsl{slanted} & 倾斜体 \\ -\cmd{scshape}\cmdindex{scshape} & \cmd{textsc}\cmdindex{textsc}\marg*{\ldots} & \textsc{Small Caps} & 小字母大写 \\[\medskipamount] -\cmd{em}\cmdindex{em} & \cmd{emph}\cmdindex{emph}\marg*{\ldots} & \emph{emphasized} & 强调,默认斜体 \\ -\cmd{normalfont}\cmdindex{normalfont} & \cmd{textnormal}\cmdindex{textnormal}\marg*{\ldots} & \textnormal{normal font} & 默认字体 \\ -\hline -\end{tabular} -\end{table} - -\subsection{字号}\label{subsec:fontsize} - -\pinyinindex{zihao}{字号} -字号命令实际大小依赖于所使用的文档类及其选项。表 \ref{tbl:ptsizes} 列出了这些命令在标准文档类中的绝对大小,单位为 pt。 - -\begin{table}[htp] -\centering -\caption{字号。} \label{tbl:sizes} -\begin{tabular}{ll} -\hline -\cmd{tiny}\cmdindex{tiny} & \tiny tiny font \\ -\cmd{scriptsize}\cmdindex{scriptsize} & \scriptsize very small font\\ -\cmd{footnotesize}\cmdindex{footnotesize} & \footnotesize quite small font \\ -\cmd{small}\cmdindex{small} & \small small font \\ -\cmd{normalsize}\cmdindex{normalsize} & \normalsize normal font \\ -\cmd{large}\cmdindex{large} & \large large font \\ -\hline -\end{tabular}% -\qquad\begin{tabular}{ll@{}} -\hline -\cmd{Large}\cmdindex{Large} & \Large larger font \\[5pt] -\cmd{LARGE}\cmdindex{LARGE} & \LARGE very large font \\[5pt] -\cmd{huge}\cmdindex{huge} & \huge huge \\[5pt] -\cmd{Huge}\cmdindex{Huge} & \Huge largest \\ -\hline -\end{tabular} -\end{table} - -\begin{table}[htp] -\centering -\caption{标准文档类中的字号大小。}\label{tbl:ptsizes} -\begin{tabular}{*{4}{l}} -\hline -\textbf{字号} & \textbf{10pt 选项(默认)} & \textbf{11pt 选项} & \textbf{12pt 选项} \\ -\hline -\cmd{tiny}\cmdindex{tiny} & 5pt & 6pt & 6pt\\ -\cmd{scriptsize}\cmdindex{scriptsize} & 7pt & 8pt & 8pt\\ -\cmd{footnotesize}\cmdindex{footnotesize} & 8pt & 9pt & 10pt \\ -\cmd{small}\cmdindex{small} & 9pt & 10pt & 10.95pt \\ -\cmd{normalsize}\cmdindex{normalsize} & 10pt & 10.95pt & 12pt \\ -\cmd{large}\cmdindex{large} & 12pt & 12pt & 14.4pt \\ -\cmd{Large}\cmdindex{Large} & 14.4pt & 14.4pt & 17.28pt \\ -\cmd{LARGE}\cmdindex{LARGE} & 17.28pt & 17.28pt & 20.74pt\\ -\cmd{huge}\cmdindex{huge} & 20.74pt & 20.74pt & 24.88pt\\ -\cmd{Huge}\cmdindex{Huge} & 24.88pt & 24.88pt & 24.88pt\\ -\hline -\end{tabular} -\end{table} - -使用字号命令的时候,通常也需要用花括号进行分组,如同 \cmd{rmfamily} 那样。 -\begin{example} -He likes {\LARGE large and -{\small small} letters}. -\end{example} - -\cmdindex{fontsize} -\LaTeX\ 还提供了一个基础的命令 \cmd{fontsize} 用于设定任意大小的字号: -\begin{command} -\cmd{fontsize}\marg{size}\marg{base line-skip} -\end{command} - -\cmdindex{selectfont} -\cmd{fontsize} 用到两个参数,\Arg{size} 为字号,\Arg{base line-skip} 为基础行距。 -表 \ref{tbl:ptsizes} 中的命令也都各自设定了与字号对应的基础行距,大小为字号的 1.2 倍。 -如果不是在导言区,\cmd{fontsize} 的设定需要 \cmd{selectfont} 命令才能立即生效, -而表 \ref{tbl:sizes} 的字号设定都是立即生效的。 - -\subsection{选用字体宏包}\label{subsec:font-pkgs} - -至此已经介绍了如何改变字体样式如粗体、斜体等等,以及如何改变字号, -但你依然用着 \LaTeX\ 默认的那套、由高德纳设计制作的 Computer Modern 字体。 -有的人可能很喜欢 Times、Palatino,或者更好看的字体。这些字体样式的自由设置在 \LaTeX\ 里还不太容易。 - -幸好大部分时候,许多字体宏包为我们完成了整套配置,我们可以在调用宏包之后,照常使用 \cmd{bfseries} 或 \cmd{ttfamily} 等我们熟悉的命令。 -表 \ref{tbl:font-pkgs} 列出了较为常用的字体宏包,其中相当多的宏包还配置了数学字体,或者文本、数学字体兼而有之。 -更多的的字体配置参考 \cite{survey,fontcatalogue}。 - -\subsection{字体编码}\label{subsec:font-encs} - -字体编码对于 \LaTeX\ 用户来讲是一个比较晦涩的概念。它规定了一个字体里包含的符号,并将若干符号用 \LaTeX\ 命令定义。 -注意字体编码并不与我们在 \ref{subsec:ascii} 等小节叙述的 ASCII 编码等一一对应。 - -常见的正文字体编码有 \texttt{OT1} 和 \texttt{T1} 等。\LaTeX\ 默认使用兼容 plain \TeX\ 的 \texttt{OT1} 编码,使用起来有诸多限制: -高德纳在设计 Computer Modern 字体时认为一些符号,如大于号、小于号等,原则上都应该在公式里出现,所以在正文字体里这些符号所在的位置被其它符号所占据 -(\texttt{OT1} 字体编码、\cmd{rmfamily} 和 \cmd{sffamly} 字体族下, \texttt< 和 \texttt> 排版\ !` 和\ ?` 两个倒立的标点符号, -正常的大于号和小于号可用命令 \cmd{textgreater} 和 \cmd{textless} 输入;\cmd{ttfamily} 字体族下是正常的大于号和小于号)。 -扩展的 \texttt{T1} 字体编码则更加靠近 ASCII 文本编码,不会出现上述的大于号、小于号的问题。 - -\pkgindex{fontenc} -切换字体编码要用到 \pkg{fontenc} 宏包: -\begin{command} -\cmd{usepackage}\oarg*{T1}\marg*{fontenc} -\end{command} - -\pkg{fontenc} 宏包是用来配合传统的 \LaTeX\ 字体的,如表 \ref{tbl:font-pkgs} 中的一些传统字体宏包。如果使用 \texttt{xelatex} 编译方式, -并使用 \pkg{fontspec} 宏包调用 \texttt{ttf} 或 \texttt{otf} 格式字体,就不要再使用 \pkg{fontenc} 宏包。 -使用表 \ref{tbl:font-pkgs} 中的字体宏包之前最好查看一下宏包的帮助文档,了解使用方法和注意事项。 - -\begin{table}[!p] -\centering\small -\caption{常见的 \LaTeX\ 字体宏包。}\label{tbl:font-pkgs} -\begin{tabular}{lp{30em}} - \hline - \multicolumn{2}{c}{\textbf{文本 / 数学字体搭配的宏包}} \\ - \hline - \pkg{lmodern} & Latin Modern 字体,对 Computer Modern 字体的扩展 \\ - \pkg{cmbright} & 仿 Computer Modern 风格的无衬线字体 \\ - \pkg{euler} & Euler 风格数学字体,也出自于高德纳之手 \\ - \pkg{ccfonts} & Concrete 风格字体 \\ - \pkg{txfonts} & Times 风格的字体宏包 \\ - \pkg{pxfonts} & Palatino 风格的字体宏包 \\ - \pkg{stix} & Times 风格的字体宏包 \\ - \pkg{newtxtext},\pkg{newtxmath} & \pkg{txfonts} 的改进版本,分别设置文本和数学字体 \\ - \pkg{newpxtext},\pkg{newpxmath} & \pkg{pxfonts} 的改进版本,分别设置文本和数学字体 \\ - \pkg{mathptmx} & \pkg{psnfss} 字体宏集之一,Times 风格,较为陈旧,不推荐使用 \\ - \pkg{mathpazo} & \pkg{psnfss} 字体宏集之一,Palatino 风格,较为陈旧,不推荐使用 \\ - \pkg{fourier} & fourier 风格数学字体,配合 Utopia 正文字体 \\ - \pkg{fouriernc} & fourier 风格数学字体,配合 New Century Schoolbook 正文字体 \\ - \pkg{arev} & Arev 无衬线字体宏包,Vera Sans 风格 \\ - \pkg{mathdesign} & 配合 Charter / Garamond / Utopia 正文字体的数学字体宏包 \\ - \hline - \multicolumn{2}{c}{\textbf{文本字体宏包}} \\ - \multicolumn{2}{l}{\footnotesize 以下字体包括传统的 \LaTeX\ 字体格式以及 TrueType / OpenType 格式。} \\ - \hline - \pkg{cm-unicode} & Computer Modern 风格的 Unicode 字体,支持多种西方语言 \\ - \pkg{dejavu} & DejaVu 开源字体 \\ - \pkg{droid} & Droid 开源字体 \\ - \pkg{inconsolata} & Inconsolata 开源等宽字体 \\ - \pkg{libertine} & Linux Libertine / Linux Biolium 开源字体 \\ - \pkg{roboto} & Roboto 开源无衬线字体 \\ - \pkg{sourcesanspro} & Source Sans Pro 开源无衬线字体 \\ - \pkg{sourcecodepro} & Source Code Pro 开源等宽字体 \\ - \hline - \multicolumn{2}{c}{\textbf{符号宏包}} \\ - \hline - \pkg{mathabx} & 数学符号宏包之一 \\ - \pkg{MnSymbol} & 数学符号宏包之一,配合 Minion Pro 文本字体 \\ - \pkg{fdsymbol} & 数学符号宏包之一 \\ - \pkg{pifont} & Zapf Dingbats 符号宏包 \\ - \hline -\end{tabular} -\end{table} - -\subsection{使用 \pkg{fontspec} 宏包更改字体 (\texttt{xelatex})}\label{subsec:fontspec} - -\index{xelatex@\texttt{xelatex} 命令} -\texttt{xelatex} 编译命令能够支持直接调用系统和 \TeX\ 发行版中的 \texttt{.ttf} 或 \texttt{.otf} 格式字体% -\footnote{Linux 下的 \TeX\ Live 为了令 \hologo{XeTeX} 使用 OpenType 字体,需要额外的配置。详见附录 \ref{app:install}。}。相比于上一小节,我们有了更多修改字体的余地。 - -\pkgindex{fontspec} -\cmdindex[fontspec]{setmainfont,setsansfont,setmonofont} -\texttt{xelatex} 命令下支持用户调用字体的宏包是 \pkg{fontspec}。宏包提供了几个设置全局字体的命令,设置 \cmd{rmfamily} 等对应命令的默认字体% -\footnote{新版本 \pkg{fontspec} 的命令支持(并且推荐)把必选参数 \Arg{font name} 放在可选参数 \Arg{font features} 的前面。}: -\begin{command} -\cmd{setmainfont}\oarg{font features}\marg{font name} \\ -\cmd{setsansfont}\oarg{font features}\marg{font name} \\ -\cmd{setmonofont}\oarg{font features}\marg{font name} -\end{command} -其中 \Arg{font name} 使用字体的文件名(带扩展名)或者字体的英文名称。\Arg{font features} 用来手动配置对应的粗体或斜体 -,比如为 Windows 下的无衬线字体 Arial 配置粗体和斜体(通常情况下自动检测并设置对应的粗体和斜体,无需手动指定): -\begin{verbatim} -\setsansfont[BoldFont={Arial Bold}, ItalicFont={Arial Italic}]{Arial} -\end{verbatim} -\Arg{font features} 还能配置字体本身的各种特性,这里不再赘述,感兴趣的读者请参考 \pkg{fontspec} 宏包的帮助文档。 - -需要注意的是:\pkg{fontspec} 宏包会覆盖数学字体设置。需要调用表 \ref{tbl:font-pkgs} 中列出的一些数学字体宏包时, -应当在调用 \pkg{fontspec} 宏包时指定 \texttt{no-math} 选项。\pkg{fontspec} 宏包可能被其它宏包或文档类(如 \pkg{xeCJK}、\pkg{ctex} 文档类)自动调用时, -则在文档开头的 \cmd{document\-class} 命令里指定 \texttt{no-math} 选项。 - -\subsection{使用 \pkg{xeCJK} 宏包更改中文字体}\label{subsec:CJKfont} - -\pkgindex{xeCJK} -\cmdindex[xeCJK]{setCJKmainfont,setCJKsansfont,setCJKmonofont} -前文已经介绍过的 \pkg{xeCJK} 宏包使用了和 \pkg{fontspec} 宏包非常类似的语法设置中文字体: -\begin{command} -\cmd{setCJKmainfont}\oarg{font features}\marg{font name} \\ -\cmd{setCJKsansfont}\oarg{font features}\marg{font name} \\ -\cmd{setCJKmonofont}\oarg{font features}\marg{font name} -\end{command} - -由于中文字体少有对应的粗体或斜体,\Arg{font features} 里多用其他字体来配置, -比如将宋体对应的 \texttt{BoldFont} 配置为黑体,而 \texttt{ItalicFont} 配置为楷体。 - -\section{段落格式和间距}\label{sec:par-lengths} - -\subsection{长度和长度变量}\label{subsec:lengths} - -在前面的一些章节,我们已经见到一些长度和长度变量的用法。本节首先统一介绍长度和长度变量。 - -长度的数值 \Arg{length} 由数字和单位组成。常用的单位见表 \ref{tbl:length-unit}。 - -\def\unitindex#1{\index{#1@\texttt{#1} (\textit{长度单位})}} - -\begin{table}[htp] -\centering -\caption{\TeX\ / \LaTeX\ 中的长度单位。}\label{tbl:length-unit} -\begin{tabular}{ll} - \hline - \texttt{pt}\unitindex{pt} & 点阵宽度,1/72.27\texttt{in} \\ - \texttt{bp}\unitindex{bp} & 点阵宽度,1/72\texttt{in} \\ - \texttt{in}\unitindex{in} & 英寸 \\ - \texttt{cm}\unitindex{cm} & 厘米 \\ - \texttt{mm}\unitindex{mm} & 毫米 \\ - \hline - \texttt{em}\unitindex{em} & 当前字号下大写字母 M 的宽度,常用于水平距离的设定 \\ - \texttt{ex}\unitindex{ex} & 当前字号下小写字母 x 的高度,常用于垂直距离的设定 \\ - \hline -\end{tabular} -\end{table} - -在一些情况下还会用到可伸缩的“弹性长度”,如 \texttt{12pt plus 2pt minus 3pt} -表示基础长度为 \texttt{12pt},可以伸展到 \texttt{14pt} ,也可以收缩到 \texttt{9pt}。 -也可只定义 \texttt{plus} 或者 \texttt{minus} 的部分,如 \texttt{0pt plus 5pt}。 - -长度的数值还可以用长度变量本身或其倍数来表达,如 \texttt{2.5}\cmd{parindent} 等。 - -\cmdindex{newlength,setlength,addtolength} -\LaTeX\ 预定义了大量的长度变量用于控制版面格式。如页面宽度和高度、首行缩进、段落间距等。 -如果需要自定义长度变量,需使用如下命令: -\begin{command} -\cmd{newlength}\marg*{\cmd{\Arg{length command}}} -\end{command} - -长度变量可以用 \cmd{setlength} 赋值,或用 \cmd{addtolength} 增加长度: -\begin{command} -\cmd{setlength}\marg*{\cmd{\Arg{length command}}}\marg{length} \\ -\cmd{addtolength}\marg*{\cmd{\Arg{length command}}}\marg{length} -\end{command} - -\subsection{行距}\label{subsec:linespread} - -\pinyinindex{hangju}{行距} -\cmdindex{linespread} -前文中我们提到过 \cmd{fontsize} 命令可以为字号设定对应的行距,但我们很少那么用。 -更常用的办法是在导言区使用 \cmd{linespread} 命令。 -\begin{command} -\cmd{linespread}\marg{factor} -\end{command} - -其中 \Arg{factor} 作用于基础行距而不是字号。缺省的基础行距是 1.2 倍字号大小(参考 \cmd{font\-size} 命令), -因此使用 \cmd{line\-spread}\marg*{1.5} 意味着最终行距为 1.8 倍的字号大小。 - -\cmdindex{selectfont} -如果不是在导言区全局修改,而想要局部地改变某个段落的行距,需要用 \cmd{select\-font} 命令使 \cmd{line\-spread} 命令的改动立即生效: -\begin{example} -{\linespread{2.0}\selectfont -The baseline skip is set to be -twice the normal baseline skip. -Pay attention to the \verb|\par| -command at the end. \par} - -In comparison, after the -curly brace has been closed, -everything is back to normal. -\end{example} - -\cmdindex{par} -字号的改变是即时生效的,而行距的改变直到文字\textbf{分段}时才生效。 -如果需要改变某一部分文字的行距,那么不能简单地将文字包含在花括号内。注意下面两个例子中 \cmd{par} 命令的位置,包括上一个例子的写法 -(\cmd{par} 相当于分段,见 \ref{subsec:spaces} 小节): -\begin{example} -{\Large Don't read this! - It is not true. - You can believe me!\par} -\end{example} - -\begin{example} -{\Large This is not true either. -But remember I am a liar.}\par -\end{example} - -\subsection{段落格式}\label{subsec:par-shape} - -以下长度分别为段落的左缩进、右缩进和首行缩进: -\begin{command} -\cmd{setlength}\marg*{\cmd{leftskip}}\marg{length} \\ -\cmd{setlength}\marg*{\cmd{rightskip}}\marg{length} \\ -\cmd{setlength}\marg*{\cmd{parindent}}\marg{length} -\end{command} - -它们和设置行距的命令一样,在分段时生效。 - -\cmdindex{indent,noindent} -\begin{command} -\cmd{indent} \\ -\cmd{noindent} -\end{command} - -\LaTeX\ 默认在段落开始时缩进,长度为用上述命令设置的 \cmd{parindent}。如果你在某一段不想使用缩进,可使用某一段开头使用 -\cmd{noindent} 命令。相反地,\cmd{indent} 命令强制开启一段首行缩进的段落。多个 \cmd{indent} 命令可以累加缩进量。 - -\pkgindex{indentfirst} -\LaTeX\ 还默认\textbf{在 \cmd{chapter}、\cmd{section} 等章节标题命令之后的第一段不缩进}% -\footnote{\pkg{ctex} 宏包和文档类默认按照中文习惯保持标题后第一段的首行缩进。}。 -如果不习惯这种设定,可以调用 \pkg{indent\-first} 宏包,令第一段的首行缩进照常。 - -\cmdindex{parskip} -段落间的垂直间距为 \cmd{parskip},如设置段落间距在 \texttt{0.8ex} 到 \texttt{1.5ex} 变动: -\begin{verbatim} -\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} -\end{verbatim} - -\subsection{水平间距}\label{subsec:hspace} - -\cmdindex{hspace} -\LaTeX 默认为将单词之间的“空格”转化为水平间距。如果需要在文中手动插入额外的水平间距,可使用 \cmd{hspace} 命令: -\begin{example} -This\hspace{1.5cm}is a space -of 1.5 cm. -\end{example} - -\cmdindex{hspace*} -\cmd{hspace} 命令生成的水平间距如果位于一行的开头或末尾,则有可能因为断行而被“吞掉”。可使用 \cmd{hspace*} 命令代替 \cmd{hspace} 命令 -得到不会因断行而消失的水平间距。 - -\cmdindex{stretch,fill} -命令 \cmd{stretch}\marg{n} 生成一个特殊弹性长度,参数 \Arg{n} 为权重。它的基础长度为 0pt,但可以无限延伸,直到占满可用的空间。 -如果同一行内出现多个 \cmd{stretch}\marg{n},这一行的所有可用空间将按每个 \cmd{stretch} 命令给定的权重 \Arg{n} 进行分配。 - -命令 \cmd{fill} 相当于 \cmd{stretch}\marg*{1}% -\footnote{注意不要用 \texttt{1.5}\cmd{fill} 这样的用法,它生成的长度只有基础长度 0pt 而没有延伸部分。}。 - -\begin{example} -x\hspace{\stretch{1}} -x\hspace{\stretch{3}} -x\hspace{\fill}x -\end{example} - -\cmdindex{quad,qquad} -在正文中用 \cmd{hspace} 命令生成水平间距时,往往使用 \texttt{em} 作为单位,生成的间距随字号大小而变。 -我们在数学公式中见过 \cmd{quad} 和 \cmd{qquad} 命令,它们也可以用于文本中,分别相当于 \cmd{hspace}\marg*{1em} 和 \cmd{hspace}\marg*{2em}: - -\begin{example} -{\Large big\hspace{1em}y}\\ -{\Large big\quad y}\\ -nor\hspace{2em}mal\\ -nor\qquad mal\\ -{\tiny tin\hspace{1em}y}\\ -{\tiny tin\quad y} -\end{example} - -\subsection{垂直间距}\label{subsec:vspace} - -在页面中,段落、章节标题、行间公式、列表、浮动体等元素之间的间距是 \LaTeX\ 预设的。比如 \cmd{parskip} ,默认设置为 \texttt{0pt plus 1pt}。 - -\cmdindex{vspace,vspace*} -如果我们想要人为地增加段落之间的垂直间距,可以在两个段落之间的位置使用 \cmd{vspace} 命令: -\begin{example} -A paragraph. - -\vspace{2ex} -Another paragraph. -\end{example} - -\cmd{vspace} 命令生成的垂直间距在一页的顶端或底端可能被“吞掉”,类似 \cmd{hspace} 在一行的开头和末尾那样。 -对应地,\cmd{vspace*} 命令产生不会因断页而消失的垂直间距。\cmd{vspace} 也可用 \cmd{stretch} 设置无限延伸的垂直长度。 - -\index{\@\crcmd\ (\textit{换行})} -在段落内的两行之间增加垂直间距,一般通过给断行命令 \crcmd\ 加可选参数,如 \crcmd\texttt{[6pt]} 或 \crcmd\texttt{*[6pt]}。 -\cmd{vspace} 也可以在段落内使用,区别在于 \cmd{vspace} 只引入垂直间距而不断行: -\begin{example} -Use command \verb|\vspace{12pt}| -to add \vspace{12pt} some spaces -between lines in a paragraph. - -Or you can use \verb|\\[12pt]| -to \\[12pt] add vertical space, -but it also breaks the paragraph. -\end{example} - -\cmdindex{bigskip,medskip,smallskip} -另外 \LaTeX\ 还提供了\cmd{bigskip}, \cmd{medskip}, \cmd{smallskip} 来增加预定义长度的垂直间距。 -\begin{example} -\parbox[t]{3em}{TeX\par TeX} -\parbox[t]{3em}{TeX\par\smallskip TeX} -\parbox[t]{3em}{TeX\par\medskip TeX} -\parbox[t]{3em}{TeX\par\bigskip TeX} -\end{example} - -\section{页面和分栏}\label{sec:page-columns} - -我们不妨回顾一下第一章介绍的文档类属性。\LaTeX\ 允许用户通过为文档类指定选项来控制纸张的大小(见 \ref{subsec:classes} 小节), -包括 \texttt{a4paper}、\texttt{letterpaper}等等,并配合字号设置了适合的页边距。 - -\cmdindex{textheight,textwidth} -控制页边距的参数由图 \ref{fig:layouts} 里给出的各种长度变量控制。 -可以用 \cmd{setlength} 命令修改这些长度变量,以达到调节页面尺寸和边距的作用; -反之也可以利用这些长度变量来决定排版内容的尺寸,如在 \env{tabularx} 环境或 \cmd{include\-graphics} 命令的参数里, -设置图片或表格的宽度为 0.8\cmd{textwidth}。 - -\begin{figure}[!p] -\centering -\layoutpicture* -\caption{本文档的页面参数示意图(奇数页;由 \pkg{layout} 宏包生成)。} \label{fig:layouts} -\end{figure} - -页边距等比较直观的参数则必须间接设置。我们根据图 \ref{fig:layouts} 将各个方向的页边距计算公式给出(以奇数页为例): -\begin{align*} -\text{\Arg{left-margin}} &= \text{\ttfamily 1in} - + \text{\cmd{hoffset}} - + \text{\cmd{oddsidemargin}} \\ -\text{\Arg{right-margin}} &= \text{\cmd{paperwidth}} - - \text{\Arg{left-margin}} - - \text{\cmd{textwidth}} \\ -\text{\Arg{top-margin}} &= \text{\ttfamily 1in} - + \text{\cmd{voffset}} - + \text{\cmd{topmargin}} - + \text{\cmd{headheight}} - + \text{\cmd{headsep}} \\ -\text{\Arg{bottom-margin}} &= \text{\cmd{paperheight}} - - \text{\Arg{top-margin}} - - \text{\cmd{textheight}} -\end{align*} -如果需要设置合适的 \Arg{left-margin} 和 \Arg{right-margin},就要通过上述方程组把 \cmd{odd\-sidemargin} 和 \cmd{text\-width} 等参数解出来! - -幸好 \pkg{geometry} 宏包提供了设置页边距等参数的简便方法,能够帮我们完成背后繁杂的计算。 - -\subsection{利用 \pkg{geometry} 宏包设置页面参数}\label{subsec:geometry} - -\pkgindex{geometry} -\pinyinindex{xuanxiang}{选项(宏包/文档类)} -\pkg{geometry} 宏包的调用方式类似于 \pkg{graphicx},在 \texttt{latex} + \texttt{dvipdfmx} 命令下需要指定选项 \texttt{dvipdfm} -(注意这里不是 \texttt{dvipdfmx});\texttt{pdflatex} 和 \texttt{xelatex} 编译命令下不需要。 - -\cmdindex[geometry]{geometry} -你既可以调用 \pkg{geometry} 宏包然后用其提供的 \cmd{geometry} 命令设置页面参数: -\begin{command} -\cmd{usepackage}\marg*{geometry} \\ -\cmd{geometry}\marg{geometry-settings} -\end{command} - -也可以将参数指定为宏包的选项: -\begin{command} -\cmd{usepackage}\oarg{geometry-settings}\marg*{geometry} -\end{command} - -其中 \Arg{geometry-settings} 多以 \Arg{key}=\Arg{value} 的形式组织。 - -比如,符合 Microsoft Word 习惯的页面设定是 A4 纸张,上下边距 1 英寸,左右边距 1.25 英寸,于是我们可以通过如下两种等效的方式之一设定页边距: -\begin{verbatim} -\usepackage[left=1.25in,right=1.25in,% - top=1in,bottom=1in]{geometry} -% or like this: -\usepackage[hmargin=1.25in,vmargin=1in]{geometry} -\end{verbatim} - -又比如,需要设定周围的边距一致为1.25英寸,可以用更简单的语法: -\begin{verbatim} -\usepackage[margin=1.25in]{geometry} -\end{verbatim} - -对于书籍等双面文档,习惯上奇数页右边、偶数页左边留出较多的页边距,而书脊一侧的奇数页左边、偶数页右边页边距较少。我们可以这样设定: -\begin{verbatim} -\usepackage[inner=1in,outer=1.25in]{geometry} -\end{verbatim} - -\pkg{geometry} 宏包本身也能够修改纸张大小、页眉页脚高度、边注宽度等等参数。更详细的用法不再赘述, -感兴趣的用户可查阅 \pkg{geometry} 宏包的帮助文档。 - -\subsection{页面内容的垂直对齐}\label{subsec:raggedbottom} - -\LaTeX\ 默认将页面内容在垂直方向分散对齐。对于有大量图表的文档,许多时候想要做到排版匀称的页面很困难, -垂直分散对齐会造成某些页面的垂直间距过宽,还可能报大量的 \texttt{Underfull} \cmd{vbox} 消息。 -\LaTeX\ 还提供了另一种策略:将页面内容向顶部对齐,给底部留出高度不一的空白。 - -\cmdindex{raggedbottom, flushbottom} -以下命令分别令页面在垂直方向向顶部对齐 / 分散对齐: -\begin{command} -\cmd{raggedbottom} \\ -\cmd{flushbottom} -\end{command} - -\subsection{分栏}\label{subsec:columns} - -\cmdindex{onecolumn,twocolumn} -\LaTeX\ 支持简单的单栏或双栏排版。标准文档类的全局选项 \texttt{onecolumn}、\texttt{twocolumn} -可控制全文分单栏或双栏排版。\LaTeX\ 也提供了切换单/双栏排版的命令: -\begin{command} -\cmd{onecolumn} \\ -\cmd{twocolumn}\oarg{one-column top material} -\end{command} - -\cmd{twocolumn} 支持带一个可选参数,用于排版双栏之上的一部分单栏内容。 - -\cmdindex{newpage,clearpage} -切换单/双栏排版时总是会另起一页(\cmd{clearpage})。 -在双栏模式下使用 \cmd{newpage} 会换栏而不是换页;\cmd{clearpage} 则能够换页。 - -\cmdindex{columnwidth,columnsep,columnseprule} -双栏排版时每一栏的宽度为 \cmd{columnwidth},它由 \cmd{textwidth} 减去 \cmd{columnsep} 的差除以 2 得到。 -两栏之间还有一道竖线,宽度为 \cmd{columnseprule},默认为零,也就是看不到竖线。 - -\pkgindex{multicol} -\envindex[multicol]{multicols} -一个比较好用的分栏解决方案是 \pkg{multicol},它提供了简单的 \env{multicols} 环境 -(注意不要写成 \env{multicol} 环境)自动产生分栏,如以下环境将内容分为 3 栏: -\begin{verbatim} -\begin{multicols}{3} -... -\end{multicols} -\end{verbatim} - -\pinyinindex{fudongti}{浮动体} -\envindex{table,figure} -\pkgindex{float} -\pkg{multicol} 宏包能够在一页之中切换单栏/多栏,也能处理跨页的分栏,且各栏的高度分布平衡。但代价是% -\textbf{在 \env{multicols} 环境中无法正常使用 \env{table} 和 \env{figure} 等浮动体环境},它会直接让浮动体丢失。 -\env{multicols} 环境中只能用跨栏的 \env{table*} 和 \env{figure*} 环境,或者用 \pkg{float} 宏包提供的 \texttt{H} 参数固定浮动体的位置。 - -\section{页眉页脚}\label{sec:pagestyle} - -\subsection{基本的页眉页脚样式}\label{subsec:basic-pagesyle} - -\cmdindex{pagestyle,thispagestyle} -\pinyinindex{yemei}{页眉} -\pinyinindex{yejiao}{页脚} -\LaTeX\ 中提供了命令 \cmd{pagestyle} 来修改页眉页脚的样式: -\begin{command} -\cmd{pagestyle}\marg{page-style} -\end{command} - -命令 \cmd{thispagestyle} 只影响当页的页眉页脚样式: -\begin{command} -\cmd{thispagestyle}\marg{page-style} -\end{command} - -\Arg{page-style} 参数为样式的名称,在 \LaTeX\ 里预定义了四类样式,见表 \ref{tbl:pagestyle}。 - -\begin{table}[htp] -\centering -\caption{\LaTeX\ 预定义的页眉页脚样式。}\label{tbl:pagestyle} -\begin{tabular}{lp{30em}} - \hline - \texttt{empty} & 页眉页脚为空 \\ - \texttt{plain} & 页眉为空,页脚为页码。(\cls{article} 和 \cls{report} 文档类默认;\cls{book} 文档类的每章第一页也为 plain 格式) \\ - \hline - \texttt{headings} & 页眉为章节标题和页码,页脚为空。(\cls{book} 文档类默认) \\ - \texttt{myheadings} & 页眉为页码及 \cmd{markboth} 和 \cmd{markright} 命令手动指定的内容,页脚为空。\\ - \hline -\end{tabular} -\end{table} - -\clsindex{article,report,book} -其中 \texttt{headings} 的情况较为复杂: -\begin{description} - \item[\cls{article} 文档类,\texttt{twoside} 选项] 偶数页为页码和节标题,奇数页为小节标题和页码; - \item[\cls{article} 文档类,\texttt{oneside} 选项] 页眉为节标题和页码; - \item[\cls{book/report} 文档类,\texttt{twoside} 选项] 偶数页为页码和章标题,奇数页为节标题和页码; - \item[\cls{book/report} 文档类,\texttt{oneside} 选项] 页眉为章标题和页码。 -\end{description} - -\cmdindex{pagenumbering} -\cmd{pagenumbering} 命令令我们能够改变页眉页脚中的页码样式: -\begin{command} -\cmd{pagenumbering}\marg{style} -\end{command} - -\cmdindex{frontmatter,mainmatter} -\Arg{style} 为页码样式,默认为 \texttt{arabic}(阿拉伯数字),还可修改为 \texttt{roman}(小写罗马数字)、 -\texttt{Roman}(大写罗马数字)等。注意使用 \cmd{pagenumbering} 命令后会将页码重置为 1。\cls{book} 文档类的 \cmd{front\-matter} 和 \cmd{main\-matter} 内部就使用了 \cmd{page\-numbering} 命令切换页码样式。 -对页码格式的详细说明见 \ref{sec:counters} 节。 - -\subsection{手动更改页眉页脚的内容}\label{subsec:marks} - -\cmdindex{markright,markboth} -对于 headings 或者 myheadings 样式,\LaTeX\ 允许用户使用命令手动修改页眉上面的内容, -特别是因为使用了 \cmd{chapter*} 等命令而无法自动生成页眉页脚的情况: -\begin{command} -\cmd{markright}\marg{right-mark}\\ -\cmd{markboth}\marg{left-mark}\marg{right-mark} -\end{command} - -在双面排版、\texttt{headings / myheadings} 页眉页脚样式下,\Arg{left-mark} 和 \Arg{right-mark} 的内容分别预期出现在左页(偶数页)和右页(奇数页)。 -事实上 \cmd{chapter} 和 \cmd{section} 等章节命令内部也使用 \cmd{mark\-both} 或者 \cmd{mark\-right} 生成页眉。 - -\LaTeX\ 默认将页眉的内容都转为大写字母。如果你不喜欢这样,可以尝试以下代码 -(相关命令的用法参照 \ref{subsec:newcmd} 节)% -\footnote{但是这不能改变页眉的斜体样式(\cmd{slshape}),斜体是定义在 \texttt{headings} 样式里的。 -如果不喜欢斜体,可在 \cmd{mark\-both} 等命令的参数里先使用 \cmd{normal\-font} ,再使用想要的字体样式命令, -或直接尝试使用 \pkg{fancyhdr} 宏包。}: -\begin{verbatim} -\renewcommand\chaptermark[1]{% - \markboth{Chapter \thechapter\quad #1}{}} -\renewcommand\sectionmark[1]{% - \markright{\thesection\quad #1}} -\end{verbatim} - -其中 \cmd{thechapter}、\cmd{thesection} 等命令为章节计数器的数值(详见 \ref{sec:counters} 节)。以上代码适用于 \cls{report/book} 文档类。 -对于 \cls{article} 文档类,与两个页眉相关的命令分别为 \cmd{sec\-tion\-mark} 和 \cmd{sub\-sec\-tion\-mark}。 - -\subsection{\pkg{fancyhdr} 宏包}\label{subsec:fancyhdr} - -\pkgindex{fancyhdr} -\pkg{fancyhdr} 宏包改善了页眉页脚样式的定义方式,允许我们将内容自由安置在页眉和页脚的左、中、右三个位置,还为页眉和页脚各加了一条横线。 - -\cmdindex[fancyhdr]{fancyhead,fancyfoot,fancyhf} -\pkg{fancyhdr} 自定义了样式名称 \texttt{fancy}。使用 \pkg{fancyhdr} 宏包定义页眉页脚之前,通常先用 \cmd{page\-style}\marg*{fancy} 调用这个样式。 -在 \pkg{fancyhdr} 中定义页眉页脚的命令为: -\begin{command} -\cmd{fancyhf}\oarg{position}\marg*{\ldots}\\ -\cmd{fancyhead}\oarg{position}\marg*{\ldots}\\ -\cmd{fancyfoot}\oarg{position}\marg*{\ldots} -\end{command} -其中 \Arg{position} 为 L(左)/C(中)/R(右) 以及与 O(奇数页)/E(偶数页)字母的组合。\cmd{fancyhf} 用于同时定义页眉和页脚, -习惯上使用 \cmd{fancyhf}\marg*{} 来清空页眉页脚的设置。 - -源代码 \ref{code:fancyhdr} 给出了 \pkg{fancyhdr} 基础用法的一个示例,效果为将章节标题放在和 headings 一致的位置,但使用加粗格式; -页码都放在页脚正中;修改横线宽度,“去掉”页脚的横线。 - -\begin{sourcecode}[htp] - \begin{Verbatim} - % 在导言区使用此代码 - \usepackage{fancyhdr} - \pagestyle{fancy} - \renewcommand{\chaptermark}[1]{\markboth{#1}{}} - \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} - \fancyhf{} - \fancyfoot[C]{\bfseries\thepage} - \fancyhead[LO]{\bfseries\rightmark} - \fancyhead[RE]{\bfseries\leftmark} - \renewcommand{\headrulewidth}{0.4pt} % 注意不用 \setlength - \renewcommand{\footrulewidth}{0pt} - \end{Verbatim} - \caption{\pkg{fancyhdr} 宏包的使用方法示例。}\label{code:fancyhdr} -\end{sourcecode} - -\cmdindex[fancyhdr]{fancypagestyle} -\pkg{fancyhdr} 还支持用 \cmd{fancy\-page\-style} 为自定义的页眉页脚样式命名,或者重新定义已有的样式如 \texttt{plain} 等: -\begin{verbatim} -% 自定义 myfancy 样式 -\fancypagestyle{myfancy}{% - \fancyhf{} - \fancyhead{...} - \fancyfoot{...} -} -% 使用样式 -\pagestyle{myfancy} -\end{verbatim} - -更多用法请参考 \pkg{fancyhdr} 宏包的帮助文档。 - - -\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.06.spec.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.06.spec.tex deleted file mode 100644 index 06b06f73358..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.06.spec.tex +++ /dev/null @@ -1,683 +0,0 @@ -\chapter{特色工具和功能}\label{chap:spec} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -本章介绍一些特色的 \LaTeX\ 辅助功能。前两个功能 \hologo{BibTeX} 和 makeindex 依靠一些辅助程序自动生成参考文献、索引等; -之后的使用颜色、超链接等则令我们生成美观易用的电子文档。 -\end{intro} - -\section{参考文献和 \hologo{BibTeX} 工具}\label{sec:bib} - -\subsection{基本的参考文献和引用}\label{subsec:bib-basics} - -\pinyinindex{cankaowenxian}{参考文献} -\LaTeX\ 提供的参考文献和引用方式比较原始,需要用户自行书写参考文献列表(包括格式), -因此较难直接使用。相关的命令我们只作最简单的介绍。 - -\cmdindex{cite} -\LaTeX\ 提供了最基本的 \cmd{cite} 命令用于在正文中引用参考文献: -\begin{command} -\cmd{cite}\marg{citation} -\end{command} - -\Arg{citation} 为引用的参考文献的标签,类似 \cmd{ref} 里的参数;\cmd{cite} 带一个可选参数,为引用的编号后加上额外的内容, -如 \cmd{cite}\oarg*{page 22}\marg*{Paper2013} 可能得到形如 [13, page 22] 这样的引用。 - -\envindex{thebibliography} -\cmdindex{bibitem} -参考文献由 \env{thebibliography} 环境包裹。每条参考文献由 \cmd{bibitem} 开头,其后是参考文献本身的内容: -\begin{command} -\cmd{begin}\marg*{thebibliography}\marg{widest label} \\ -\quad \cmd{bibitem}\oarg{item number}\marg{citation} ...\\ -\cmd{end}\marg*{thebibliography} -\end{command} -其中 \Arg{citation} 是 \cmd{cite} 使用的文献标签, -\Arg{item number} 自定义参考文献的序号,如果省略,则按自然排序给定序号。 -\Arg{widest label} 用以限制参考文献序号的宽度,如 99 意味着不超过两位数字。通常设定为与参考文献的数目一致。 - -\env{thebibliography} 环境自动生成不带编号的一节(\cls{article} 文档类)或一章(\cls{report} / \cls{book} 文档类)。 -在 \cls{article} 文档类的节标题默认为 ``Reference''{},而在 \cls{report / book} 文档类 -的章标题默认为 ``Bibliography''{}。用户可通过 \ref{sec:latex-settings} 节给出的方法定制参考文献的标题。 - -以下为一个使用 \env{the\-biblio\-graphy} 排版参考文献的例子: -\begin{verbatim} -\documentclass{article} -\begin{document} -\section{Introduction} -Partl~\cite{germenTeX} has proposed that \ldots - -\begin{thebibliography}{99} -\bibitem{germenTeX} H.~Partl: \emph{German \TeX}, - TUGboat Volume~9, Issue~1 (1988) -\end{thebibliography} -\end{document} -\end{verbatim} - -\subsection{\hologo{BibTeX} 数据库}\label{subsec:bibtex-data} - -\index{bibtexdb@\protect\hologo{BibTeX} 数据库} -\hologo{BibTeX} 是最为流行的参考文献数据组织格式之一。它的出现让我们摆脱手写参考文献条目的麻烦。我们还可以通过参考文献样式的支持, -让同一份 \hologo{BibTeX} 数据库生成不同样式的参考文献列表。 - -\hologo{BibTeX} 数据库以 \texttt{.bib} 作为扩展名,其内容是若干个文献条目,每个条目的格式为: -\begin{command} -\texttt @\Arg{type}\texttt\{\Arg{citation}, \\ -\qquad\Arg{key1} = \marg{value1}, \\ -\qquad\Arg{key2} = \marg{value2}, \\ -\qquad\ldots\\ -\texttt\} -\end{command} - -其中 \Arg{type} 为文献的类别,如 \texttt{article} 为学术论文,\texttt{book} 为书籍,\texttt{in\-collection} 为论文集中的某一篇,等等。 -\Arg{citation} 为 \cmd{cite} 命令使用的文献标签。在 \Arg{citation} 之后为条目里的各个字段,以 \Arg{key} = \marg{value} 的形式组织。 - -我们在此简单列举学术论文里使用较多的 \hologo{BibTeX} 文献条目类别: -\begin{description} - \item[\texttt{article}] 学术论文,必需字段有 author, title, journal, year; 可选字段包括 volume, number, pages, doi 等; - \item[\texttt{book}] 书籍,必需字段有 author/editor, title, publisher, year; 可选字段包括 volume/number, series, address 等; - \item[\texttt{incollection}] 论文集中的一篇,必需字段有 author, title, booktitle, publisher, year; 可选字段包括 editor, volume/number, chapter, pages, address 等; - \item[\texttt{inbook}] 书中的一章,必需字段有 author/editor, title, chapter/pages, publisher, year; 可选字段包括 volume/number, series, address 等。 -\end{description} - -例如 \texttt{article} 类别的参考文献数据条目写法如下: -\begin{verbatim} -@article{Alice13, - title = {Demostration of bibliography items}, - author = {Alice Axford and Bob Birkin and Charlie Copper and Danny Dannford}, - year = {2013}, - month = {Mar}, - journal = {Journal of \TeX perts}, - volume = {36}, - number = {7}, - pages = {114-120}} -\end{verbatim} -所有类别的文献条目格式请参考 \CTAN|biblio/bibtex/base/btxdoc.pdf|。 - -多数时候,我们无需自己手写 \hologo{BibTeX} 文献条目。从 Google Scholar 或者期刊/数据库的网站上都能够导出 \hologo{BibTeX} 文献条目, -老牌的文献管理软件 EndNote 也支持生成 \hologo{BibTeX} 格式的数据库。开源软件 JabRef 甚至支持 \hologo{BibTeX} 文献条目的导入、导出和管理。 - -\subsection{\hologo{BibTeX} 样式}\label{subsec:bibtex-style} - -参考文献的写法在不同文献里千差万别,包括作者、标题、年份等各项的顺序和字体样式、文献在列表中的排序规则等。 -\hologo{BibTeX} 用样式(style)来管理参考文献的写法。\hologo{BibTeX} 提供了几个预定义的样式,如 plain, unsrt, alpha 等。 -如果使用期刊模板的话,可能会提供自用的样式。 -样式文件以 \texttt{.bst} 为扩展名。 - -\cmdindex{bibliographystyle} -使用样式文件的方法是在源代码内(一般在导言区)使用 \cmd{biblio\-graphy\-style} 命令: -\begin{command} -\cmd{bibliographystyle}\marg{bst-name} -\end{command} -这里 \Arg{bst-name} 为 \texttt{.bst} 样式文件的名称,\textbf{不要带 \texttt{.bst} 扩展名}。 - -我们以 \ref{subsec:bibtex-data} 小节给出的数据条目为例,使用 \cmd{biblio\-graphy\-style} 命令选择不同的参考文献样式, -效果大致如表 \ref{tbl:bibtex-style} 所示。 - -\begin{table}[htp] -\caption{\hologo{BibTeX} 样式的排版效果。}\label{tbl:bibtex-style} -\hrule -\begin{trivlist}\item\relax -\textbf{plain}\\{} -[1] Alice Axford, Bob Birkin, Charlie Copper, and Danny Dannford. -\newblock Demostration of bibliography items. -\newblock {\em Journal of \TeX perts}, 36(7):114--120, Mar 2013. - -\medskip -\textbf{alpha}\\{} -[ABCD13] Alice Axford, Bob Birkin, Charlie Copper, and Danny Dannford. -\newblock Demostration of bibliography items. -\newblock {\em Journal of \TeX perts}, 36(7):114--120, Mar 2013. - -\medskip -\textbf{abbrv}\\{} -[1] A.~Axford, B.~Birkin, C.~Copper, and D.~Dannford. -\newblock Demostration of bibliography items. -\newblock {\em Journal of \TeX perts}, 36(7):114--120, Mar 2013. - -\medskip -\textbf{amsplain}(\AmS\ 文档类 \textsf{amsart} 等配套的样式)\\{} -[1] Alice Axford, Bob Birkin, Charlie Copper, and Danny Dannford, \emph{Demostration of bibliography - items}, Journal of \TeX perts \textbf{36} (2013), no.~7, 114--120. - -\medskip -\textbf{elsarticle-num}(Elsevier 提供的 \textsf{elsarticle} 文档类配套的样式)\\{} -[1] A.~Axford, B.~Birkin, C.~Copper, D.~Dannford, Demostration of bibliography items, - Journal of \TeX perts 36~(7) (2013) 114--120. - -\medskip -\textbf{IEEEtran}(\textsf{IEEEtran} 模板文档类配套的样式)\\{} -[1] A.~Axford, B.~Birkin, C.~Copper, and D.~Dannford, ``Demostration of - bibliography items,'' \emph{Journal of \TeX perts}, vol.~36, no.~7, pp. - 114--120, Mar 2013. -\end{trivlist} -\hrule -\end{table} - -\subsection{使用 \hologo{BibTeX} 排版参考文献}\label{subsec:bibtex-use} - -\index{bibtex@\protect\hologo{BibTeX} 工具} -现在我们来看如何利用 \hologo{BibTeX} 数据库生成参考文献和引用。 - -第一步:准备一份 \hologo{BibTeX} 数据库,假设数据库文件名为 \texttt{books.bib}, -和 \LaTeX\ 源代码\textbf{一般位于同一个目录下}。 - -第二步:在源代码中添加必要的命令。假设源代码名为 \texttt{demo.tex}(见源代码 \ref{code:bibtex-demo})。 -\begin{enumerate} -\item \cmdindex{bibliographystyle} -首先需要使用命令 \cmd{bibliographystyle} 设定参考文献的格式。 - -\item \cmdindex{cite,nocite} -其次,在正文中引用参考文献。\hologo{BibTeX} 程序在生成参考文献列表的时候,通常只列出用了 \cmd{cite} 命令引用的那些。 -如果需要列出未被引用的文献,则需要 \cmd{nocite}\marg{citation} 命令;而 \cmd{nocite}\marg*{*} 则让所有未被引用的文献都列出。 - -\item \cmdindex{bibliography} -再次,在需要列出参考文献的位置,使用 \cmd{biblio\-graphy} 命令代替 \env{the\-biblio\-graphy} 环境: -\begin{command} -\cmd{bibliography}\marg{bib-name} -\end{command} - -其中 \Arg{bib-name} 是 \hologo{BibTeX} 数据库的文件名,\textbf{不要带 \texttt{.bib} 扩展名}。 -\end{enumerate} - -\begin{sourcecode}[htp] -\begin{Verbatim} -\documentclass{article} -\bibliographystyle{plain} -\begin{document} -\section{Some words} -Some excellent books, for example, \cite{citation1} -and \cite{citation2} \ldots - -\bibliography{books} -\end{document} -\end{Verbatim} -\caption{利用 \texttt{books.bib} 生成参考文献的源代码 \texttt{demo.tex}。}\label{code:bibtex-demo} -\end{sourcecode} - -注意:\cmd{bibliographystyle} 和 \cmd{bibliography} 命令缺一不可,没有这两个命令,使用 \hologo{BibTeX} 生成参考文献列表的时候会报错。 - -第三步:写好了以上两个文件之后,我们就可以开始编译了。 -\begin{enumerate} - \item 首先使用 \texttt{pdflatex} 或 \texttt{xelatex} 等命令编译 \LaTeX\ 源代码 \texttt{demo.tex}; - \item 接下来用 \texttt{bibtex} 命令处理 \texttt{demo.aux} 辅助文件记录的参考文献格式、引用条目等信息。 - \texttt{bibtex} 命令处理完毕后会生成 \texttt{demo.bbl} 文件,内容就是一个 \env{thebibliography} 环境; - \item 再使用 \texttt{pdflatex} 或 \texttt{xelatex} 等命令把源代码 \texttt{demo.tex} 编译\textbf{两遍},读入参考文献并正确生成引用。 -\end{enumerate} - -整个过程使用的命令如下(可以略去扩展名): -\begin{verbatim} -xelatex demo -bibtex demo -xelatex demo -xelatex demo -\end{verbatim} - -使用 \texttt{latex + dvipdfmx} 命令编译时,则 \texttt{dvipdfmx} 命令放在最后,相当于先后使用 -\texttt{latex}, \texttt{bibtex}, \texttt{latex}, \texttt{latex}, \texttt{dvipdfmx}。 - -\subsection{\pkg{natbib} 宏包}\label{subsec:natbib} - -\pkgindex{natbib} -时下许多学术期刊比较喜欢使用人名——年份的引用方式,形如(\emph{Axford et~al.}, 2013)。 -\pkg{natbib} 宏包提供了对这种“自然”引用方式的处理。 - -\cmdindex[natbib]{citep,citet} -除了 \cmd{cite} 之外,\pkg{natbib} 宏包在正文中支持两种引用方式: -\begin{command} -\cmd{citep}\marg{citation} \\ -\cmd{citet}\marg{citation} -\end{command} - -它们分别生成形如(\emph{Axford et~al.}, 2013) 和 \emph{Axford et~al.} (2013) 的人名——年份引用。 -正确排版人名——年份引用还依赖于特定的 \hologo{BibTeX} 样式。\pkg{natbib} 提供了与 \LaTeX\ 预定义样式相对应的几个样式, -包括 \texttt{plainnat}、\texttt{abbrvnat} 和 \texttt{unsrtnat}。学术论文模板是否支持 \pkg{natbib},需要参考其帮助文档。 - -\pkg{natbib} 宏包同样也支持数字引用,并且支持将引用的序号压缩,例如: -\begin{verbatim} -\usepackage[numbers,sort&compress]{natbib} -\end{verbatim} -调用 \pkg{natbib} 宏包时指定以上选项后,连续引用多篇文献时,会生成形如 (3-7) 的引用而不是 (3, 4, 5, 6, 7)。 - -\pkg{natbib} 宏包还有更多选项和用法,比如默认的引用是用小括号包裹的,可指定 \texttt{square} 选项改为中括号; -再比如 \cmd{citep} 命令也支持可选参数,为引用前后都添加额外内容。这里不再赘述,请参考 \pkg{natbib} 宏包的帮助文档。 - - -\subsection{\pkg{biblatex} 宏包}\label{subsec:biblatex} - -\pkgindex{biblatex} -本节的末尾简单介绍一下基于 \pkg{biblatex} 宏包排版参考文献的方式。 -\pkg{biblatex} 宏包是一套基于 \LaTeX\ 宏命令的参考文献解决方案,提供了便捷的格式控制和强大的排序、分类、筛选、多文献表等功能。 -\pkg{biblatex} 宏包也因其对 UTF-8 和中文参考文献的良好支持,被国内较多 \LaTeX\ 模板采用。 - -基于 \pkg{biblatex} 宏包的方式与基于 \hologo{BibTeX} 的传统方式有一定区别,下面从文档结构和命令、编译方式、样式选择等方面逐一介绍: - -\subsubsection{文档结构和 \pkg{biblatex} 相关命令} - -\cmdindex[biblatex]{addbibresource,printbibliography} -\begin{enumerate} - \item 首先是在导言区调用 \pkg{biblatex} 宏包。宏包支持以 \Arg{key}=\Arg{value} 形式指定选项,包括参考文献样式 style、参考文献著录排序的规则 sorting 等。 - \item 接着在导言区使用 \cmd{addbibresource} 命令为 \pkg{biblatex} 引入参考文献数据库。与基于 \hologo{BibTeX} 的传统方式不同的是,这里需要写完整的文件名。 - \item 在正文中使用 \cmd{cite} 命令引用参考文献。除此之外还可以使用丰富的命令达到不同的引用效果,如 \cmd{citeauthor} 和 \cmd{citeyear} 分别单独引用作者和年份,\cmd{textcite} 和 \cmd{parencite} 分别类似 \pkg{natbib} 宏包提供的 \cmd{citet} 和 \cmd{citep} 命令,以及脚注式引用 \cmd{footcite} 等。 - \item 最后在需要排版参考文献的位置使用命令 \cmd{printbibliography}。 -\end{enumerate} - -\begin{sourcecode}[htp] -\begin{Verbatim} -% File: egbibdata.bib -@book{caimin2006, - title = {UML基础和Rose建模教程}, - address = {北京}, - author = {蔡敏 and 徐慧慧 and 黄柄强}, - publisher = {人民邮电出版社}, - year = {2006}, - month = {1} -} - -% File: demo.tex -\documentclass{ctexart} -% 使用符合 GB/T 7714-2015 规范的参考文献样式 -\usepackage[style=gb7714-2015]{biblatex} -% 注意加 .bib 扩展名 -\addbibresource{egbibdata.bib} - -\begin{document} - -见文献\cite{caimin2006}。 - -\printbibliography -\end{document} -\end{Verbatim} -\caption{应用 \pkg{biblatex} 的示例 egbibdata.bib 和 demo.tex。} -\end{sourcecode} - -\subsubsection{编译方式} - -\index{biber} -与基于 \hologo{BibTeX} 的传统方式不同的是,\pkg{biblatex} 宏包使用 \texttt{biber} 程序处理参考文献。因此上述文档的编译步骤为: - -\begin{verbatim} -xelatex demo -biber demo -xelatex demo -xelatex demo -\end{verbatim} - -\subsubsection{\pkg{biblatex} 样式和其它选项} - -\pkg{biblatex} 使用的参考文献样式分为著录样式(bibliography style)和引用样式(citation style),分别以 \texttt{.bbx} 和 \texttt{.cbx} 为扩展名。参考文献的样式在调用宏包时使用 \texttt{style} 选项指定,或者使用 \texttt{bibstyle} 或 \texttt{citestyle} 分别指定: -\begin{verbatim} -% 同时调用 gb7714-2015.bbx 和 gb7714-2015.cbx -\usepackage[style=gb7714-2015]{biblatex} -% 著录样式调用 gb7714-2015.bbx,引用样式调用 biblatex 宏包自带的 authoryear -\usepackage[bibstyle=gb7714-2015,citestyle=authoryear]{biblatex} -\end{verbatim} - -以下总结一些常用的参考文献样式,除 \pkg{biblatex} 宏包自带的样式外,许多样式以单独的宏包在发行版内发布。 - -\begin{description} - \item[\texttt{authoryear}] - \pkg{biblatex} 自带样式,类似 \pkg{natbib} 默认的引用样式效果。 - \item[\texttt{authortitle}] - \pkg{biblatex} 自带样式,采用作者-题名(shorttitle 字段)的引用样式。 - \item[\texttt{verbose}] - \pkg{biblatex} 自带样式,引用样式中包含作者、题名、书名、页码等字段的信息。 - \item[\texttt{alphabetic}] - \pkg{biblatex} 自带样式,著录样式与 \hologo{BibTeX} 的 \texttt{alpha} 样式类似。 - \item[\texttt{trad-alpha}] - \pkg{biblatex-trad} 样式包,移植自 \hologo{BibTeX} 默认的 \texttt{alpha} 样式。另外还包括 \texttt{trad-abbrv}、\texttt{trad-plain} 和 \texttt{trad-unsrt}。 - \item[\texttt{gb7714-2015}] - 符合中文文献著录标准 GB/T 7714-2015 的样式,著录按顺序编码排版。另外还包括按作者-年份顺序排版著录的样式 \texttt{gb7714-2015ay}。 - \item[\texttt{caspervector}] - 以中文文献著录标准 GB/T 7714-2015 为基础的一个样式。 - \item[\texttt{ieee}] - 兼容 \pkg{IEEEtran} 风格的样式,著录按顺序编码排版。另外还包括按作者-年份顺序排版著录的样式 \texttt{ieee-alphabetic}。 -\end{description} - -\section{索引和 makeindex 工具}\label{sec:index} - -\pinyinindex{suoyin}{索引} -\index{makeindex@makeindex 工具} -书籍和大文档通常用索引来归纳关键词,方便用户查阅。\LaTeX\ 借助配套的 makeindex 程序完成对索引的排版。 - -\subsection{使用 makeindex 工具的方法}\label{subsec:makeidx} - -要使用索引,须经过这么几个步骤(仍设源代码名为 \texttt{demo.tex}): - -\pkgindex{makeidx} -\cmdindex[makeidx]{makeindex} -第一步,在 \LaTeX\ 源代码的导言区调用 \pkg{makeidx} 宏包,并使用 \cmd{makeindex} 命令开启索引的收集: -\begin{verbatim} -\usepackage{makeidx} -\makeindex -\end{verbatim} - -\cmdindex{index} -\cmdindex[makeidx]{printindex} -第二步,在正文中需要索引的地方使用 \cmd{index} 命令。\cmd{index} 命令的参数写法详见下一小节; -并在需要输出索引的地方(如所有章节之后)使用 \cmd{printindex} 命令。 - -第三步,编译过程: - -\begin{enumerate} - \item 首先用 \texttt{xelatex} 等命令编译源代码 \texttt{demo.tex}。编译过程中产生索引记录文件 \texttt{demo.idx}; - \item 用 makeindex 程序处理 \texttt{demo.idx},生成用于排版的索引列表文件 \texttt{demo.ind}; - \item 再次编译源代码 \texttt{demo.tex},正确生成索引列表。 -\end{enumerate} - -\subsection{索引项的写法}\label{subsec:index-entry} - -\cmdindex{index} -添加索引项的命令为: -\begin{command} -\cmd{index}\marg{index entry} -\end{command} - -其中 \Arg{index entry} 为索引项,写法由表 \ref{tbl:index-entry} 汇总。其中 \texttt!、\texttt @ 和 \texttt| -为特殊符号,如果要向索引项直接输出这些符号,需要加前缀 \texttt";而 \texttt" 需要输入两个引号 \texttt{""} 才能输出到索引项。 - -\begin{table}[htp] -\centering -\caption{索引项的写法列表。}\label{tbl:index-entry} -\begin{tabular}{lll} - \hline - \textbf{举例} &\textbf{索引项} &\textbf{备注}\\ - \hline - \multicolumn{3}{l}{普通索引} \\[.8ex] - \verb+hello+ & hello, 1 & 普通索引 \\ - \hline - \multicolumn{3}{l}{分级索引,以 \texttt! 分隔,最多支持三级} \\[.8ex] - \verb+hello+ & hello, 1 & 一级索引 \\ - \verb+hello!Peter+ &\quad Peter, 3 & 二级索引 \\ - \verb+hello!Peter!Jack+ &\qquad Jack, 3 & 三级索引 \\ - \hline - \multicolumn{3}{l}{格式化索引,形式为 \Arg{alpha}\texttt @\Arg{format}} \\ - \multicolumn{3}{l}{\Arg{alpha}为纯字母,用来排序} \\ - \multicolumn{3}{l}{\Arg{format}为索引的格式,可以包括 \LaTeX 代码和简单的公式} \\[.8ex] - \verb+Mobius@M\""obius+ & M\"obius, 2 & 输出重音 \\ - \verb+alpha@$\alpha$+ & $\alpha$, 7 & 输出公式 \\ - \verb+bold@\textbf{bold}+ & \textbf{bold}, 12 & 输出粗体 \\ - \hline - \multicolumn{3}{l}{页码范围} \\[.8ex] - \verb+morning|(+ & morning, 6-7 & 范围索引的开头 \\ - \verb+morning|)+ & & 范围索引的结尾 \\ - \hline - \multicolumn{3}{l}{格式化索引页码} \\[.8ex] - \verb+Jenny|textbf+ & Jenny, \textbf{3} & 调用 \cmd{textbf} 加粗页码 \\ - \verb+Joe|see{Jenny}+ & Joe, \textit{see} Jenny & 调用 \cmd{see} 生成特殊形式 \\ - \verb+Joe|seealso{Jenny}+ & Joe, \textit{see also} Jenny & 调用 \cmd{seealso} 生成特殊形式 \\ - \hline -\end{tabular} -\end{table} - -读者可以钻研一下以下给出的一个较为复杂的,结合多级索引、索引格式、页码格式等的用法示例。但在自己使用时, -最好还是遵循“简单的就是最好的”原则,尽量使用表 \ref{tbl:index-entry} 中的写法。 -\begin{verbatim} -Test index. -\index{Test@\textsf{""Test}|(textbf} -\index{Test@\textsf{""Test}!sub@"|sub"||see{Test}} -\newpage -Test index. -\index{Test@\textsf{""Test}|)textbf} -\end{verbatim} - -\section{使用颜色}\label{sec:color} - -\pinyinindex{yanse}{颜色} -原始的 \LaTeX\ 不支持使用各种颜色。\pkg{color} 宏包或者 \pkg{xcolor} 宏包提供了对颜色的支持,给 PDF 输出生成颜色的特殊指令。 - -\subsection{颜色的表达方式}\label{subsec:color-code} - -\pkgindex{color} -\cmdindex[color/xcolor]{color} -调用 \pkg{color} 或 \pkg{xcolor} 宏包后,我们就可以用如下命令切换颜色: -\begin{command} -\cmd{color}\oarg{color-mode}\marg{code} \\ -\cmd{color}\marg{color-name} -\end{command} - -颜色的表达方式有两种,其一是使用色彩模型和色彩代码,代码用 $0\sim1$ 的数字代表成分的比例。 -\pkg{color} 宏包支持 \texttt{rgb}、\texttt{cmyk} 和 \texttt{gray} 模型,\pkg{xcolor} 支持更多的模型如 \texttt{hsb} 等。 -\begin{example} -\large\sffamily -{\color[gray]{0.6} - 60\% 灰色} \\ -{\color[rgb]{0,1,1} - 青色} -\end{example} - -其二是直接使用名称代表颜色,前提是已经定义了颜色名称(没定义的话会报错): -\begin{example} -\large\sffamily -{\color{red} 红色} \\ -{\color{blue} 蓝色} -\end{example} - -\pkgindex{xcolor} -\pkg{color} 宏包仅定义了 8 种颜色名称,\pkg{xcolor} 补充了一些,总共有 19 种,见表 \ref{tbl:colors}。 - -\def\showcolor#1{% - \texttt{#1}\index{yanse@颜色!#1@\texttt{#1}}% - \ \begingroup\fboxsep=0pt\fbox{{\color{#1}\vrule width 1.2em height 1.4ex}}\endgroup} -\def\showxcolor#1{% - \texttt{#1}\index{yanse@颜色!#1@\texttt{#1} (\pkg{xcolor})}% - \ \begingroup\fboxsep=0pt\fbox{{\color{#1}\vrule width 1.2em height 1.4ex}}\endgroup} - -\begin{table}[htp] -\centering -\caption{\pkg{color} 和 \pkg{xcolor} 宏包可用的颜色名称。}\label{tbl:colors} -\renewcommand\arraystretch{1.1} -\begin{tabularx}{0.8\textwidth}{*{4}{>{\raggedleft\arraybackslash}X}} - \hline - \multicolumn{4}{c}{基本的 8 种颜色名称(后三种颜色为 CMYK 模型)} \\ - \showcolor{black} & \showcolor{red} & \showcolor{green} & \showcolor{blue} \\ - \showcolor{white} & \showcolor{cyan} & \showcolor{magenta} & \showcolor{yellow} \\ - \hline - \multicolumn{4}{c}{\pkg{xcolor} 额外可用的颜色名称:} \\ - \showxcolor{darkgray} & \showxcolor{gray} & \showxcolor{lightgray} & \\ - \showxcolor{brown} & \showxcolor{olive} & \showxcolor{orange} & \showxcolor{lime}\\ - \showxcolor{purple} & \showxcolor{teal} & \showxcolor{violet} & \showxcolor{pink} \\ - \hline -\end{tabularx} -\end{table} - -\pkg{xcolor} 还支持将颜色通过表达式混合或互补: -\begin{example} -\large\sffamily -{\color{red!40} 40\% 红色}\\ -{\color{blue}蓝色 -\color{blue!50!black}蓝黑 -\color{black}黑色}\\ -{\color{-red}红色的互补色} -\end{example} - -我们还可以通过命令自定义颜色名称,注意这里的 \Arg{color-mode} 是必选参数: -\begin{command} -\cmd{definecolor}\marg{color-name}\marg{color-mode}\marg{code} -\end{command} - -如果调用 \pkg{color} 或 \pkg{xcolor} 宏包时指定 \texttt{dvipsnames} 选项,就有额外的 68 种颜色名称可用% -\footnote{\pkg{color} 宏包实际要指定 \texttt{dvipsnames} 和 \texttt{usenames} 选项。}。 -\pkg{xcolor} 宏包还支持通过指定其它选项载入更多颜色名称。限于篇幅不展开介绍,详情请参考 \pkg{xcolor} 宏包的手册。 - -\subsection{带颜色的文本和盒子}\label{subsec:colorbox} - -原始的 \cmd{color} 命令类似于字体命令 \cmd{bfseries},它使之后排版的内容全部变成指定的颜色, -所以直接使用时通常要加花括号分组。\pkg{color} / \pkg{xcolor} 宏包都定义了一些方便用户使用的带颜色元素。 - -\cmdindex[color/xcolor]{textcolor} -输入带颜色的文本可以用类似 \cmd{textbf} 的命令: -\begin{command} -\cmd{textcolor}\oarg{color-mode}\marg{code}\marg{text} \\ -\cmd{textcolor}\marg{color-name}\marg{text} -\end{command} - -\cmdindex[color/xcolor]{colorbox} -以下命令构造一个带背景色的盒子,\Arg{material} 为盒子中的内容: -\begin{command} -\cmd{colorbox}\oarg{color-mode}\marg{code}\marg{material} \\ -\cmd{colorbox}\marg{color-name}\marg{material} -\end{command} - -\cmdindex[color/xcolor]{fcolorbox} -以下命令构造一个带背景色和有色边框的盒子,\Arg{fcode} 或 \Arg{fcolor-name} 用于设置边框颜色: -\begin{command} -\cmd{fcolorbox}\oarg{color-mode}\marg{fcode}\marg{code}\marg{material} \\ -\cmd{fcolorbox}\marg{fcolor-name}\marg{color-name}\marg{material} -\end{command} - -\begin{example} -\sffamily -文字用\textcolor{red}{红色}强调\\ -\colorbox[gray]{0.95}{浅灰色背景} \\ -\fcolorbox{blue}{yellow}{% - \textcolor{blue}{蓝色边框+文字,% - 黄色背景} -} -\end{example} - -\cmdindex{fboxrule,fboxsep} -\cmd{fcolorbox} 也可以像 \ref{subsec:fbox} 小节里的 \cmd{fbox} 那样调节 \cmd{fbox\-rule} 和 \cmd{fbox\-sep};对于 \cmd{color\-box}, -调整 \cmd{fbox\-sep} 是有效的。这里不再给出具体的示例。 - -\section{使用超链接}\label{sec:hyperlinks} - -\pinyinindex{chaolianjie}{超链接} -PDF 文档格式是现今最流行的电子文档格式,而电子文档最实用的需求之一就是超链接功能。 -\LaTeX\ 中实现这一功能的是 \pkg{hyperref} 宏包。 - -\subsection{\pkg{hyperref} 宏包}\label{subsec:hyperref} - -\pkgindex{hyperref} -\pkg{hyperref} 宏包涉及到的链接遍布 \LaTeX\ 的每一个角落——目录、引用、脚注、索引、参考文献等等都被封装成超链接。 -但这也使得它与其它宏包发生冲突的可能性大大增加,虽然宏包已经尽力解决各方面的兼容性,但仍不能面面俱到。 -为减少可能的冲突,习惯上将 \pkg{hyperref} 宏包\textbf{放在其它宏包之后调用}。 - -\pinyinindex{xuanxiang}{选项(宏包/文档类)} -与 \pkg{graphicx} 宏包类似,\texttt{latex} + \texttt{dvipdfmx} 命令下调用 \pkg{hyperref} 宏包时,需要指定选项 \texttt{dvipdfmx}; -而 \texttt{pdflatex} 或 \texttt{xelatex} 命令下不需要。 - -\cmdindex[hyperref]{hypersetup} -\pkg{hyperref} 宏包提供了命令 \cmd{hypersetup} 配置各种参数。参数也可以作为宏包选项,在调用宏包时指定: -\begin{command} -\cmd{hypersetup}\marg*{\Arg{option1},\Arg{option2}=\marg*{value},\ldots} \\ -\cmd{usepackage}\oarg*{\Arg{option1},\Arg{option2}=\marg*{value},\ldots}\marg*{hyperref} -\end{command} - -\begin{table}[htp] -\centering -\caption{\pkg{hyperref} 宏包提供的参数设置。}\label{tbl:hyperref-settings} -\begin{tabular}{llp{19.5em}} - \hline - \textbf{参数} & \textbf{默认值} & \textbf{含义} \\ - \hline - \texttt{colorlinks=}\Arg{true\textnormal|false} - & \textit{false} & 设置为 \textit{true} 为链接文字带颜色,反之加上带颜色的边框 \\ - \texttt{hidelinks} & & 取消链接的颜色和边框 \\ - \texttt{pdfborder=}\marg*{\Arg{n} \Arg{n} \Arg{n}} - & 0 0 1 & 超链接边框设置,设为 0 0 0 可取消边框 \\ - \hline - \texttt{bookmarks=}\Arg{true\textnormal|false} \textsuperscript{\dag} - & \textit{true} & 是否生成书签 \\ - \texttt{bookmarksopen=}\Arg{true\textnormal|false} - & \textit{false} & 是否展开书签 \\ - \texttt{bookmarksnumbered=}\Arg{true\textnormal|false} - & \textit{false} & 书签是否带章节编号 \\ - \texttt{CJKbookmarks=}\Arg{true\textnormal|false} - & \textit{false} & 使用 \pkg{CJK} 宏包/ GBK 编码排版中文时必须设定的参数, - 需要将生成的 \texttt{.out} 文件用工具处理编码,或调用 \pkg{xCJK2uni} 宏包 \\ - \texttt{unicode} & & 使用 \pkg{CJKutf8} 宏包/ UTF-8 编码排版中文时必须设定的参数 \\ - \hline - \texttt{pdftitle=}\Arg{string} - & 空 & 标题 \\ - \texttt{pdfauthor=}\Arg{string} - & 空 & 作者 \\ - \texttt{pdfsubject=}\Arg{string} - & 空 & 主题 \\ - \texttt{pdfkeywords=}\Arg{string} - & 空 & 关键词 \\ - \texttt{pdfstartview=}\Arg{Fit\textnormal|FitH\textnormal|FitV} - & \textit{Fit} & 设置 PDF 页面以适合页面/适合宽度/适合高度等方式显示,默认为适合页面 \\ - \hline -\end{tabular} -\begin{quotation} -\small -\textsuperscript{\dag} 该选项只能在调用宏包时指定。 -\end{quotation} -\end{table} - -\subsection{超链接}\label{subsec:url-href} - -\cmdindex[hyperref]{url,nolinkurl} -\pkg{hyperref} 宏包提供了直接书写超链接的命令,用于在 PDF 中生成 URL: -\begin{command} -\cmd{url}\marg{url} \\ -\cmd{nolinkurl}\marg{url} -\end{command} - -\cmd{url} 和 \cmd{nolinkurl} 都生成可以点击的 URL,区别是前者有彩色,后者没有。在 \cmd{url} 命令中作为参数的 URL 里, -\textbf{可直接输入如 \texttt\%、\texttt\& 这样的特殊符号}。 - -\cmdindex[hyperref]{href} -我们也可以像 HTML 中的超链接一样,把一段文字作为超链接: -\begin{command} -\cmd{href}\marg{url}\marg{text} -\end{command} - -\begin{example} -\url{http://wikipedia.org} \\ -\nolinkurl{http://wikipedia.org} \\ -\href{http://wikipedia.org}{Wiki} -\end{example} - -\cmdindex[hyperref]{hyperref} -使用 \pkg{hyperref} 宏包后,文档中所有的引用、参考文献、索引等等都转换为超链接。 -用户也可对某个 \cmd{label} 命令定义的标签 \Arg{label} 作超链接(注意这里的 \Arg{label} 虽然是可选参数的形式,但通常是\textbf{必填的}% -\footnote{不带可选参数的 \cmd{hyperref} 命令带四个必选参数,前三个组成特殊格式的超链接,最后一个同 \Arg{text}。}): -\begin{command} -\cmd{hyperref}\oarg{label}\marg{text} -\end{command} - -默认的超链接在文字外边加上一个带颜色的边框(在打印 PDF 时边框不会打印),可指定 \texttt{color\-links} 参数修改为将文字本身加上颜色, -或修改 \texttt{pdf\-border} 参数调整边框宽度以“去掉”边框;\texttt{hide\-links} 参数则令超链接既不变色也不加边框。 -\begin{verbatim} -\hypersetup{hidelinks} -% or: -\hypersetup{pdfborder={0 0 0}} -\end{verbatim} - -\subsection{PDF 书签}\label{subsec:pdf-bookmark} - -\pinyinindex{PDFshuqian}{PDF 书签} -\pkg{hyperref} 宏包另一个强大的功能是为 PDF 生成书签。对于章节命令 \cmd{chapter}、\cmd{section} 等, -默认情况下会为 PDF 自动生成书签。和交叉引用、索引等类似,生成书签也需要多次编译源代码,第一次编译将书签记录写入 \texttt{.out} 文件, -第二次编译才正确生成书签。 - -书签的一些属性见表 \ref{tbl:hyperref-settings}。 -在 \texttt{latex} + \texttt{dvipdfmx} 或 \texttt{pdflatex} 命令下使用 \pkg{ctex} 宏包或 \pkg{CJK} 宏包时, -为了正确生成中文书签而不出现乱码,需要额外的设置,甚至繁琐的工序(这也是我们推荐使用 \texttt{xelatex} 命令处理中文的原因)。 - -\cmdindex[hyperref]{pdfbookmark} -\pkg{hyperref} 还提供了手动生成书签的命令: -\begin{command} -\cmd{pdfbookmark}\oarg{level}\marg{bookmark}\marg{anchor} -\end{command} -\Arg{bookmark} 为书签名称,\Arg{anchor} 为书签项使用的锚点(类似交叉引用的标签)。可选参数 \Arg{level} 为书签的层级,默认为 0。 - -\cmdindex[hyperref]{texorpdfstring} -章节命令里往往有 \LaTeX\ 命令甚至数学公式,而 PDF 书签是纯文本,对命令和公式的处理很困难,有出错的风险。 -\pkg{hyperref} 宏包已经为我们处理了许多常见命令,如 \cmd{LaTeX} 和字体命令 \cmd{textbf} 等, -对于未被处理的命令或数学公式,就要在章节标题中使用如下命令,分别提供 \LaTeX\ 代码和 PDF 书签可用的纯文本: -\begin{command} -\cmd{texorpdfstring}\marg{\LaTeX\ code}\marg{PDF bookmark text} -\end{command} -比如在章节名称里使用公式 $E=mc^2$,而书签使用字符 \texttt{E=mc\textasciicircum 2}: -\begin{verbatim} -\section{质能公式 \texorpdfstring{$E=mc^2$}{E=mc\textasciicircum 2}} -\end{verbatim} - -\subsection{PDF 文档属性}\label{subsec:pdf-settings} - -\pkg{hyperref} 宏包还提供了一些参数用于改变 PDF 文档的属性,部分见表 \ref{tbl:hyperref-settings}。 - - -\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.07.graphic.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.07.graphic.tex deleted file mode 100644 index 7be4a2ed8bc..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.07.graphic.tex +++ /dev/null @@ -1,472 +0,0 @@ -\chapter{绘图功能}\label{chap:graphics} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -除了排版文字,\LaTeX\ 也支持用代码表示图形。不同的扩展已经极大地丰富了 \LaTeX\ 的图形功能,\TikZ\ 就是其中之一。 -本章将带你了解一些基本的绘图功能。 - -一些特殊的绘图,如交换图、树状图甚至分子式和电路图也能够通过代码绘制, -不过其复杂程度已经超出本手册范围,有兴趣的读者可以查阅一些帮助文档,或者在互联网寻求帮助。 -\end{intro} - -\section{绘图语言简介}\label{sec:pict-lang} - -\LaTeX\ 提供了原始的 \env{picture} 环境,能够绘制一些基本的图形如点、线、矩形、圆、B\'ezier 曲线等等, -不过受制于 \LaTeX\ 本身,它的绘图功能极为有限,效果也不够美观。 - -当前较为流行的、用于 \LaTeX\ 的绘图宏包 / 程序主要有: -\begin{itemize} - \item PSTricks \par - 以 PostSciprt 语法为基础的绘图宏包,具有优秀的绘图能力。它对老式的 \texttt{latex + dvips} 编译命令支持最好, - 而现在的几种编译命令下使用起来都不够方便。 - - \item \TikZ\ \& \pkg{pgf} \par - 德国的 Till Tantau 教授在开发著名的 \LaTeX\ 幻灯片文档类 \cls{beamer} 时一并开发了绘图宏包 \pkg{pgf}, - 目的是令其能够在 \texttt{pdflatex} 或 \texttt{xelatex} 等不同的编译命令下都能使用。 - \TikZ\ 是在 \pkg{pgf} 基础上封装的一个宏包,采用了类似 \hologo{METAPOST} 的语法,提供了方便的绘图命令,绘图能力不输 PSTricks。 - - \item \hologo{METAPOST} \& Asymptote \par - \hologo{METAPOST} 脱胎于高德纳为 \TeX\ 配套开发的字体生成程序 \hologo{METAFONT}, - 具有优秀的绘图能力,并能够调用 \TeX\ 引擎向图片中插入文字和公式。 - Asymptote 在 \hologo{METAPOST} 的基础上更进一步,具有一定的类似 C 语言的编程能力,支持三维图形的绘制。\par - 它们作为独立的程序,通常的用法是将代码写在单独的文件里,编译生成图片供 \LaTeX\ 引用,也可以借助特殊的宏包在 \LaTeX\ 代码里直接使用。 -\end{itemize} - -本手册将介绍 \TikZ\ 绘图宏包里最基本的部分。\TikZ\ 还支持各种自定义的扩展,基于 \TikZ\ 的专门用途的绘图宏包也不胜枚举, -其复杂程度已远远超出入门手册的范围(\TikZ\ 的帮助文档有上千页之厚)。 -对此感兴趣的读者需要自行查阅帮助文档,或者到互联网上参考现成的范例。 - -\section{\TikZ\ 绘图语言}\label{sec:tikz} - -\index{TikZ@\TikZ} -\pkgindex{tikz} -\envindex[tikz]{tikzpicture} -\cmdindex[tikz]{tikz} -在导言区调用 \pkg{tikz} 宏包,就可以用以下命令和环境使用 \TikZ\ 的绘图功能了% -\footnote{\texttt{latex + dvipdfmx} 编译方式要在 \pkg{tikz} 宏包之前调用 \pkg{graphicx} 宏包并指定 \texttt{dvipdfmx} 选项。}: -\begin{command} -\cmd{tikz}\oarg*{\ldots} \Arg{tikz code}\texttt{;} \\[1ex] -\cmd{tikz}\oarg*{\ldots} \marg*{\Arg{tikz code 1}\texttt{;} \Arg{tikz code 2}\texttt{;} \ldots} \\[1ex] -\cmd{begin}\marg*{tikzpicture}\oarg*{\ldots} \\ -\Arg{tikz code 1}\texttt{;} \\ -\Arg{tikz code 2}\texttt{;} \\ -\ldots \\ -\cmd{end}\marg*{tikzpicture} -\end{command} - -前一种用法为 \cmd{tikz} 带单条绘图命令,以分号结束,一般用于在文字之间插入简单的图形; -后两种用法较为常见,使用多条绘图命令,可以在 \env{figure} 等浮动体中使用。 - -\subsection{\TikZ\ 坐标和路径}\label{subsec:tikz-path} - -\TikZ\ 用直角坐标系或者极坐标系描述点的位置。 -\begin{itemize} - \item 直角坐标下,点的位置写作 \texttt{(\Arg{$x$},\Arg{$y$})},坐标 \Arg{$x$} 和 \Arg{$y$} 可以用 \LaTeX\ 支持的任意单位表示, - 缺省为 \texttt{cm}; - \item 极坐标下,点的位置写作 \texttt{(\Arg{$\theta$}:\Arg{r})}。$\theta$ 为极角,单位是度。 -\end{itemize} - -\cmdindex[tikz]{coordinate} -我们还可以为某个点命名:\cmd{coordinate} \texttt{(A) at (\Arg{coordinate})} -然后就可以使用 \texttt{(A)} 作为点的位置了。 - -\begin{example} -\begin{tikzpicture} -\draw (0,0) -- (30:1); -\draw (1,0) -- (2,1); -\coordinate (S) at (0,1); -\draw (S) -- (1,1); -\end{tikzpicture} -\end{example} - -坐标的表示形式还包括“垂足”形式: -\begin{example} -\begin{tikzpicture} -\coordinate (S) at (2,2); -\draw[gray] (-1,2) -- (S); -\draw[gray] (2,-1) -- (S); -\draw[red] (0,0) -- (0,0 -| S); -\draw[blue] (0,0) -- (0,0 |- S); -\end{tikzpicture} -\end{example} - - -\TikZ\ 最基本的路径为两点之间连线,如 \texttt{(\Arg{$x_1$},\Arg{$y_1$}) -{}- (\Arg{$x_2$},\Arg{$y_2$})},可以连用表示多个连线(折线)。 -连续使用连线时,可以使用 \texttt{cycle} 令路径回到起点,生成闭合的路径。 -\begin{example} -\begin{tikzpicture} -\draw (0,0) -- (1,1) -- (2,0) -- cycle; -\end{tikzpicture} -\end{example} - -多条路径可用于同一条画图命令中,以空格分隔: -\begin{example} -\begin{tikzpicture} -\draw (0,0) -- (0,1) - (1,0) -- (1,1) -- (2,0) -- cycle; -\end{tikzpicture} -\end{example} - -其它常用的路径还包括: -\begin{itemize} - \item 矩形、圆和椭圆: -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw (0,0) rectangle (1.5,1); -\draw (2.5,0.5) circle [radius=0.5]; -\draw (4.5,0.5) ellipse - [x radius=1,y radius=0.5]; -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item 直角、圆弧、椭圆弧: -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw (0,0) |- (1,1); -\draw (1,0) -| (2,1); -\draw (4,0) arc (0:135:1); -\draw (6,0) arc (0:135:1 and 0.5); -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item 正弦、余弦曲线(1/4 周期): -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw (0,0) sin (1,1); -\draw (0,1) sin (1,0); -\draw (2,1) cos (3,0); -\draw (2,0) cos (3,1); -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item 抛物线,用 \texttt{bend} 控制顶点: -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw (0,0) parabola (1,2); -\draw (2,0) parabola - bend (2.25,-0.25) (3,2); -\draw (4,0) parabola - bend (4.75,2.25) (5,2); -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item 二次和三次 B\'ezier 曲线,分别使用一个和两个控制点: -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw (0,0) .. controls - (2,1) and (3,1) .. (3,0); -\draw (4,0) .. controls - (5,1) .. (5,0); -\draw[help lines] (0,0) - -- (2,1) -- (3,1) -- (3,0) - (4,0) -- (5,1) -- (5,0); -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item 网格、函数图像,网格可用 \texttt{step} 参数控制网格大小,函数图像用 \texttt{domain} 参数控制定义域: -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw[help lines,step=0.5] - (-1,-1) grid (1,1); -\draw[->] (-1.5,0) -- (1.5,0); -\draw[->] (0,-1.5) -- (0,1.5); -\draw[domain=-1:1] - plot(\x,{\x*\x*2 -1}); -\end{tikzpicture} -\end{example} - -\subsection{\TikZ\ 绘图命令和参数}\label{subsec:tikz-draw} - -\cmdindex[tikz]{draw,fill,filldraw} -除了 \cmd{draw} 命令之外,\TikZ\ 还提供了 \cmd{fill} 命令用来填充图形,\cmd{filldraw} 命令则同时填充和描边。 -除了矩形、圆等现成的闭合图形外,\cmd{fill} 和 \cmd{filldraw} 命令也能够填充人为构造的闭合路径。 -\begin{command} -\cmd{draw}\oarg*{\ldots} \Arg{path}; \\ -\cmd{fill}\oarg*{\ldots} \Arg{path}; \\ -\cmd{filldraw}\oarg*{\ldots} \Arg{path}; -\end{command} - -绘图参数可作为可选参数用在 \env{tikzpiture} 环境或 \cmd{tikz} 命令时,参数会影响到所有具体的绘图命令; -用在单个绘图命令 \cmd{draw}、\cmd{filldraw} 等时,只对这个命令起效。 - -\TikZ\ 有数不清的绘图参数,这些参数令 \TikZ\ 能够绘制丰富多彩的图像,同时也令 \TikZ\ 难以精通。 -以下示例常用的一些绘图参数。 - -\begin{itemize} - \item \texttt{color/draw/fill=\Arg{color}} 为 \cmd{draw} 或 \cmd{fill} 等命令指定颜色。 - \texttt{draw} 和 \texttt{fill} 分别指定填充和描边的颜色,而 \texttt{color} 同时指定, - 可以省略 \texttt{color=} 直接写颜色名称。 -\end{itemize} -\begin{example} -\begin{tikzpicture}[thick] -\draw[blue] (0,0) rectangle (1,1); -\filldraw[fill=yellow,draw=red] - (2,0.5) circle [radius=0.5]; -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item \texttt{thick=\Arg{length}/thin/semithick/\ldots} 指定线条的粗细。 -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw[ultra thin] (0,0)--(0,2); -\draw[very thin] (0.5,0)--(0.5,2); -\draw[thin] (1,0)--(1,2); -\draw[semithick] (1.5,0)--(1.5,2); -\draw[thick] (2,0)--(2,2); -\draw[very thick] (2.5,0)--(2.5,2); -\draw[ultra thick] (3,0)--(3,2); -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item \texttt{solid/dashed/dotted/dash dot/dash dot dot} 指定线条类型(实线、虚线、点划线等)。 - 与 \texttt{dashed} 对应地有 \texttt{densely dashed} 和 \texttt{loosely dashed},后三种类型同理。 -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw[dashed] (0,0) -- (0,2); -\draw[dotted] (0.5,0) -- (0.5,2); -\draw[dash dot] (1,0) -- (1,2); -\draw[dash dot dot] (1.5,0) -- (1.5,2); -\draw[densely dotted] - (2,0) -- (3,2) -- (4,0) -- cycle; -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item \texttt{\Arg{arrow}-\Arg{arrow}} 指定线条首尾的箭头形式。 - 复杂的箭头形式需要使用 \cmd{use\-tikz\-library} \marg*{arrows.meta}。 -\end{itemize} -\begin{example} -\begin{tikzpicture}[thick] -\draw[->] (0,4) -- (3,4); -\draw[->>] (0,3.5) -- (3,3.5); -\draw[->|] (0,3) -- (3,3); -\draw[<-] (0,2.5) -- (3,2.5); -\draw[<->] (0,2) -- (3,2); -\draw[>->|] (0,1.5) -- (3,1.5); -\draw[-stealth] (0,1) -- (3,1); -\draw[-latex] (0,0.5) -- (3,0.5); -\draw[-to] (0,0) -- (3,0); -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item \texttt{rounded corners\oarg*{=\Arg{radius}}/sharp corners} 将路径转向处绘制成圆角/直角。可选参数 \Arg{radius} 控制圆角的半径。 - 可以对某一段路径直接使用。 -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw[rounded corners] - (0,0) rectangle (1,1); -\draw (2,0) -- (2,1) - [rounded corners=.3cm] - -- (3,1) -- (3.5,0) - [sharp corners] -- cycle; -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item \texttt{scale/xshift/yshift/xslant/yslant/rotate} 设定图形的缩放、位移和旋转。 -\end{itemize} -\begin{example} -\begin{tikzpicture} -\draw[help lines](0,0) rectangle (1,1); -\draw[scale=1.5] (0,0) rectangle (1,1); -\draw[rotate=30] (0,0) rectangle (1,1); -\draw[help lines](2,0) rectangle (3,1); -\draw[yshift=4pt](2,0) rectangle (3,1); -\draw[help lines](4,0) rectangle (5,1); -\draw[xslant=0.4](4,0) rectangle (5,1); -\end{tikzpicture} -\end{example} - -为了重复利用绘图参数,减少代码冗余,\TikZ\ 引入了“样式”的概念,可以定义一个样式包含绘图参数, -然后将样式作为一个参数用于绘图: -\begin{example} -\begin{tikzpicture} - [myarrow/.style={blue,thick,->}] -\draw (0,0)--(0,1)--(2,1); -\draw[myarrow] (0,0)--(2,1); -\draw[myarrow,dotted] - (0,0)--(2,0)--(2,1); -\end{tikzpicture} -\end{example} - -\envindex[tikz]{scope} -\TikZ\ 还提供了 \env{scope} 环境,令绘图参数或样式在局部生效: -\begin{example} -\begin{tikzpicture} -\draw (0,0) rectangle (2.5, 2.5); -\begin{scope}[thick,scale=0.5] -\draw (0,0) rectangle (2.5, 2.5); -\end{scope} -\end{tikzpicture} -\end{example} - -\subsection{\TikZ\ 文字结点}\label{subsec:tikz-node} - -\cmdindex[tikz]{node} -\TikZ\ 用 \cmd{node} 命令绘制文字结点: -\begin{command} -\cmd{node}\oarg{options} \texttt{(\Arg{name})} \texttt{at (\Arg{coordinate})} \marg{text}\texttt{;} -\end{command} -\texttt{(\Arg{name})} 为结点命名,类似 \cmd{coordinate};\texttt{at (\Arg{coordinate})} 指定结点的位置。 -这两者和前面的 \Arg{options} 都可以省略,只有 \Arg{text} 是必填的。 -\begin{example} -\begin{tikzpicture} -\node (A) at (0,0) {A}; -\node (B) at (1,0) {B}; -\node (C) at (60:1) {C}; -\draw (A) -- (B) -- (C) -- (A); -\end{tikzpicture} -\end{example} - -\ref{subsec:tikz-draw} 小节中的参数可用于 \cmd{node} 命令的配置。除此之外,\cmd{node} 还有一些特定的参数: -\begin{itemize} - \item \texttt{anchor=\Arg{position}} 令结点的某个角落 \Arg{position} 与 \Arg{coordinate} 对应。 - \item \texttt{centered / above / below / left / right / above left / \ldots \oarg*{=\Arg{length}}} \\ - 与 \texttt{anchor} 等效的选项。可选的 \Arg{length} 为节点相对于 \Arg{coordinate} 的距离。 -\end{itemize} -\begin{example} -\begin{tikzpicture} -\coordinate (A) at (1,1); -\fill (A) circle[radius=2pt]; -\node[draw,anchor=south] at (A) {a}; -\node[draw,below right=4pt] at (A) {b}; -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item \texttt{shape=\Arg{shape}} - 结点的形状,默认可用 \texttt{rectangle} 和 \texttt{circle},可省略 \texttt{shape=} 直接写。在导言区使用命令 - \cmd{use\-tikz\-library}\marg*{shapes.geometric} 可用更多的形状。 - \item \texttt{text=\Arg{color}} - 结点文字的颜色。 - \item \texttt{node font=\Arg{font command}} - 结点文字的字体,形如 \cmd{bfseries} 或 \cmd{itshape} 等。 -\end{itemize} -\begin{example} -\begin{tikzpicture} -\node[circle,fill=blue,text=white, - font={\bfseries}] - (A) at (0,0) {A node}; -\node[rectangle,rounded corners, - draw=gray,font={\sffamily\slshape}] - (B) at (2,0) {B node}; -\end{tikzpicture} -\end{example} - -\begin{itemize} - \item \texttt{inner sep=\Arg{length} / outer sep=\Arg{length}} - 结点边界向外和向内的额外距离。 - \item \texttt{minimum size=\Arg{length} / minimum height=\Arg{length} / minimum width=\Arg{length}} \\ - 结点的最小大小或最小高度/宽度。 -\end{itemize} - -\cmd{node} 命令不仅为文字结点的位置命名,在 \cmd{draw} 等命令中还可以使用某个结点的相对位置, -以“东南西北”的方式命名: -\begin{example} -\begin{tikzpicture} -\draw (0,0) circle[radius=1]; -\fill (0,0) circle[radius=2pt]; -\node[draw] (P) at (15:2) {center}; -\draw[dotted] (0,0) -- (P.west); -\end{tikzpicture} -\end{example} - -\cmd{node} 命令的一种等效用法是在 \cmd{draw} 等命令的路径中使用 \texttt{node},不仅可以对某个位置标记节点,还能够对线标记: -\begin{example} -\begin{tikzpicture} -\draw (2,1.5) node[above] {$A$} - -- node[above left] {$c$} - (0,0) node[left] {$B$} - -- node[below] {$a$} - (2.5,0) node[right] {$C$} - -- node[above right] {$b$} - cycle; -\end{tikzpicture} -\end{example} - -在此举一个较为复杂的例子,综合前面介绍过的各种路径、形状、文字结点和参数设置,见源代码 \ref{code:tikz-example}。 - -\begin{sourcecode}[htp] -\begin{Verbatim} -\begin{tikzpicture} -\draw[-stealth,line width=0.2pt] (-0.5,0) -- (4.5,0); -\draw[-stealth,line width=0.2pt] (0,-0.5) -- (0,2.5); -\coordinate (a) at (0.5,1.9); -\coordinate (b) at (4,1.2); -\node[below] (a0) at (a |- 0,0) {$a$}; -\node[below] (b0) at (b |- 0,0) {$b$}; -\filldraw[fill=gray!20,draw,thick] - (a0) -- (a) .. controls (1,2.8) and (2.7,0.4) .. (b) -- (b0) -- cycle; -\node[above right,outer sep=0.2cm, rounded corners, - fill=green!20,draw=gray,text=blue!60!black,scale=0.6] - at (b) {$\displaystyle \int_a^b {f(x)\,\mathrm{d}x} = F(b) - F(a)$}; -\end{tikzpicture} -\end{Verbatim} -\begin{center} -\begin{tikzpicture} -\draw[-stealth,line width=0.2pt] (-0.5,0) -- (4.5,0); -\draw[-stealth,line width=0.2pt] (0,-0.5) -- (0,2.5); -\coordinate (a) at (0.5,1.9); -\coordinate (b) at (4,1.2); -\coordinate[label=below:$a$] (a0) at (a |- 0,0); -\coordinate[label=below:$b$] (b0) at (b |- 0,0); -\filldraw[fill=gray!20,draw,thick] - (a0) -- (a) .. controls (1,2.8) and (2.7,0.4) .. (b) -- (b0) -- cycle; -\node[above right,outer sep=0.2cm, rounded corners, - fill=green!20,draw=gray,text=blue!60!black,scale=0.6] - at (b) {$\displaystyle \int_a^b {f(x)\,\mathrm{d}x} = F(b) - F(a)$}; -\end{tikzpicture} -\end{center} -\caption{\TikZ\ 绘图示例源代码和效果。}\label{code:tikz-example} -\end{sourcecode} - -\subsection{在 \TikZ\ 中使用循环} - -\cmdindex[tikz]{foreach} -\TikZ\ 通过 \pkg{pgffor} 功能宏包实现了简单的循环功能,语法为: -\begin{command} -\cmd{foreach} \cmd{a} \texttt{in} \marg{list} \marg{commands} -\end{command} -上述语法定义了 \cmd{a} 为变量,在 \marg{commands} 中使用 \cmd{a} 完成循环。 - -\Arg{list} 可以直接将所有值写出来,如 1,2,3,4;也可以写成省略形式,如 1,2,\ldots,10。 -\begin{example} -\begin{tikzpicture} -\draw (0,0)--(5,0); -\foreach \i in {0.0,0.1,...,5.0} - {\draw[very thin] - (\i,0)--(\i,0.15);} -\foreach \I in {0,1,2,3,4,5} - {\draw (\I,0)--(\I,0.25) - node[above] {\I};} -\end{tikzpicture} -\end{example} - -\cmd{foreach} 还可使用变量对参与循环: -\begin{example} -\begin{tikzpicture} -\foreach \n/\t in - {0/\alpha,1/\beta,2/\gamma} - {\node[circle,fill=lightgray,draw] - at (\n,0) {$\t$};} -\end{tikzpicture} -\end{example} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.08.custom.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.08.custom.tex deleted file mode 100644 index 656f9f0ac6b..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap.08.custom.tex +++ /dev/null @@ -1,349 +0,0 @@ -\chapter{自定义 \LaTeX\ 命令和功能}\label{chap:custom} -\addtocontents{los}{\protect\addvspace{10pt}} - -\begin{intro} -读到这一章之前,如果你确保掌握了前几章的知识并熟练运用,你已经能制作出内容和形式都相当丰富的文档了。 -但你可能还不会满足:我要如何制作一个简单但像样的毕业论文/书籍/简历模板,每次可以直接套用, -而不是再在导言区写一堆代码? - -本章的内容将有助于你实现这一个目标,让你能编写可重复利用的模块——宏包和文档类,并在其中自己定义命令和环境。 -不过作为入门手册,这些知识仍是不全面的。如果你不满足于此,需要参考更多资料,比如 \cite{companion,clsguide}。 -\end{intro} - -\section{自定义命令和环境}\label{sec:defs} - -你也许已经意识到了,在本手册中介绍的所有命令都被包含在一个带颜色的矩形背景框中。 -笔者并没有直接使用基础的 \LaTeX\ 命令来实现这个效果,而是创建了一个\textbf{宏包}, -并在其中定义了笔者所需要的命令和环境。现在我只需写成这样简单的形式: - -\begin{example} -\begin{command} -\cmd{dum} -\end{command} -\end{example} - -这个例子中使用了一个新的环境 \env{command}。这个环境负责给命令代码加上一个带颜色的矩形背景框。 -同时还使用了一个命令:\cmd{cmd}, 这个命令负责输出命令的名字,包括前面的反斜杠。 - -一旦笔者想要修改命令代码的样式,比如更换颜色、加边框等等,可以通过改变 \env{command} 环境的定义来很容易地创建新的外观, -而不是挨个修改每个命令示例。 - -\subsection{定义新命令}\label{subsec:newcmd} - -\cmdindex{newcommand} -使用如下命令可以定义你自己的命令: -\begin{command} -\cmd{newcommand}\marg*{\cmd{\Arg{name}}}\oarg{num}\marg{definition} -\end{command} -基本上,这个命令有两个参数,第一个 \Arg{name} 是你想要建立的命令的名称(带反斜杠), -第二个 \Arg{definition} 是命令的定义。方括号里的参数 \Arg{num} 是可选的, -用于指定新命令所需的参数数目(最多 9 个)。如果缺省可选参数,默认就是 0,也就是新建的命令不带任何参数。 - -接下来的两个例子有助你的理解。第一个例子定义了一个新的命令:\cmd{tnss}。 -这个命令是本手册英文名称 ``The Not So Short Introduction to \LaTeXe'' 的简写。 -如果你需要在文档中多次使用本手册的名称,那么使用这个命令是一个非常方便的办法。 - -\begin{example} -\newcommand{\tnss}{The not - so Short Introduction to - \LaTeXe} -This is ``\tnss'' \ldots{} -``\tnss'' -\end{example} - -第二个例子演示了如何定义一个带参数的命令。在命令的定义中,标记 \verb|#1| -代表指定的参数。如果想使用多个参数,可以依次使用 \verb|#2|、……、\verb|#9| 等标记。 - -\begin{example} -\newcommand{\txsit}[1] - {This is the \emph{#1} Short - Introduction to \LaTeXe} -% in the document body: -\begin{itemize} -\item \txsit{not so} -\item \txsit{very} -\end{itemize} -\end{example} - -\cmdindex{renewcommand} -\LaTeX\ 不允许你定义一个与现有命令重名的命令。如果需要修改命令定义的话,使用 \cmd{re\-new\-comm\-and} 命令。它使用与命令 \cmd{new\-comm\-and} -相同的语法。 - -\cmdindex{providecommand} -在某些情况之下,你可能会希望使用 \cmd{pro\-vide\-comm\-and} 命令。在命令不存在时,它相当于 \cmd{new\-comm\-and} -;在命令已经存在时,仍沿用存在的定义。 - -\subsection{定义环境}\label{subsec:newenv} - -\cmdindex{newenvironment} -与 \cmd{new\-comm\-and} 命令类似,有一个命令用于定义新的环境。这个命令是 \cmd{new\-environ\-ment},它的语法如下所示: - -\begin{command} -\cmd{newenvironment}\marg{name}\oarg{num}\marg{before}\marg{after} -\end{command} - -同样地,\cmd{newenvironment} 命令有一个可选的参数。 -在 \Arg{before} 中的内容将在此环境包含的文本之前处理,而在 \Arg{after} 中的内容将在遇到 \cmd{end\marg{name}} 命令时处理。 - -下面的例子演示了 \cmd{newenvironment} 命令的用法: -\begin{example} -\newenvironment{king} -{\rule{1ex}{1ex}% - \hspace{\stretch{1}}} -{\hspace{\stretch{1}}% - \rule{1ex}{1ex}} - -\begin{king} -My humble subjects \ldots -\end{king} -\end{example} - -\cmdindex{renewenvironment} -参数 \Arg{num} 的使用方式与 \cmd{new\-comm\-and} 命令相同。\LaTeX\ 还同样保证你 -不会不小心新建重名的环境。如果你确实希望改变一个现有的环境,你可以使用命令 - \cmd{re\-new\-environ\-ment},它使用和命令 \cmd{new\-environ\-ment} 相同的语法。 - -\section{编写自己的宏包和文档类}\label{sec:packages} - -\subsection{编写简单的宏包}\label{subsec:provide-pkg} - -\cmdindex{usepackage} -如果你定义了很多新的环境和命令,你的文档的导言区将变得相当长,在这种情况下,好的方式是 -建立一个新的 \LaTeX\ 宏包来存放所有你自己定义的命令和环境, -然后在你的文档中使用 \cmd{use\-package} 命令来调用自定义的宏包。 - -\begin{sourcecode}[htp] -\begin{Verbatim} -% Demo Package by Tobias Oetiker -\ProvidesPackage{demopack} -\newcommand{\tnss}{The not so Short Introduction - to \LaTeXe} -\newcommand{\txsit}[1]{The \emph{#1} Short - Introduction to \LaTeXe} -\newenvironment{king}{\begin{quote}}{\end{quote}} -\end{Verbatim} -\caption{宏包的一个最简示例。}\label{code:package} -\end{sourcecode} - -\cmdindex{ProvidesPackage} -写一个宏包的基本工作就是将原本在你的文档导言区里很长的内容拷贝到另一个文件中去, - 这个文件需要以 \texttt{.sty} 作扩展名。你还需要加入一个宏包专用的命令: -\begin{command} -\cmd{ProvidesPackage}\marg{package name} -\end{command} -这个命令应该放在你的宏包的最前面,并且一定要注意:\textbf{\Arg{package name} 需要和宏包的文件名一致。} -\cmd{Provides\-Package} 让 \LaTeX\ 记录宏包的名称,从而在 \cmd{usepackage} 命令再次调用同一个宏包的时候忽略之% -\footnote{但如果你以\emph{不同的选项}多次引入宏包,则有可能会引起错误,见附录 \ref{sec:errors}。}。 -源代码 \ref{code:package} 给出了一个小的宏包示例,其中包含了我们之前定义的一些命令。 - -\subsection{在宏包中调用其它宏包}\label{subsec:require-pkg} - -\cmdindex{RequirePackage} -如果你想进一步把各种宏包的功能汇总到一个文件里,而不是在文档的导言区罗列一大堆宏包的话, -\LaTeX\ 允许你在自己编写的宏包中调用其它宏包,命令为 \cmd{RequirePackage},用法和 \cmd{usepackage} -一致: -\begin{command} -\cmd{RequirePackage}\oarg{options}\marg{package name} -\end{command} - -\subsection{编写自己的文档类}\label{subsec:provide-cls} - -\cmdindex{ProvidesClass} -当你更进一步,需要编写自己的文档类,如论文模板等,问题就稍稍麻烦了一些。首先,自己的文档类以 \texttt{.cls} 作扩展名,开头使用 -\cmd{ProvidesClass} 命令: -\begin{command} -\cmd{ProvidesClass}\marg{class name} -\end{command} -当然了,\marg{class name}也需要和文档类的文件名一致。 - -\cmdindex{LoadClass} -但是有了上述命令和和你之前学到的 \cmd{newcommand} 等,还并不能完成一个文档类的编写,因为诸如 \cmd{chapter}、 -\cmd{section} 等等许多常用的命令都是在文档类中定义的。事实上,许多时候我们只需要像调用宏包那样调用一个基本的文档类, -省去许多不必要的麻烦。在你的文档类中调用其它文档类的命令是 \cmd{LoadClass} ,用法和 \cmd{documentclass} 十分相像: -\begin{command} -\cmd{LoadClass}\oarg{options}\marg{package name} -\end{command} - -\section{计数器}\label{sec:counters} - -\pinyinindex{jishuqi}{计数器} -我们早就见识到了 \LaTeX\ 对文档元素自动计数的能力:章节符号、列表、图表……它们都是依靠 \LaTeX\ 提供的计数器功能完成的。 - -\subsection{定义和修改计数器}\label{subsec:count-defs} - -\cmdindex{newcounter} -定义一个计数器的方法为: -\begin{command} -\cmd{newcounter}\marg{counter name}\oarg{parent counter name} -\end{command} - -\Arg{counter name} 为计数器的名称。计数器可以有上下级的关系,可选参数 \Arg{parent counter name} 定义为 \Arg{counter name} 的上级计数器。 - -\cmdindex{setcounter,addtocounter,stepcounter} -以下命令修改计数器的数值,\cmd{set\-counter} 将数值设为 \Arg{number};\cmd{add\-to\-counter} 将数值加上 \Arg{number}; -\cmd{step\-counter} 将数值加一,并\textbf{将所有下级计数器归零}。 -\begin{command} -\cmd{setcounter}\marg{counter name}\marg{number} \\ -\cmd{addtocounter}\marg{counter name}\marg{number} \\ -\cmd{stepcounter}\marg{counter name} -\end{command} - -\subsection{计数器的输出格式}\label{subsec:count-value} - -计数器 \Arg{counter} 的输出格式由 \cmd{the\Arg{counter}} 表示,如我们在 \ref{sec:pagestyle} 一节见过的 \cmd{thechapter} 等。 -这个值默认以阿拉伯数字形式输出,如果想改成其它形式,需要重定义 \cmd{the\Arg{counter}},如将 equation 计数器的格式定义为大写字母: -\begin{verbatim} -\renewcommand\theequation{\Alph{equation}} -\end{verbatim} - -\cmdindex{arabic,alph,Alph,roman,Roman,fnsymbol} -命令 \cmd{Alph} 控制计数器 \Arg{counter} 的值以大写字母形式显示。下表列出所有可用于修改计数器格式的命令。 -注意:这些命令\textbf{只能用于计数器,不能直接用于数字},如 \cmd{roman}\marg*{1} 这样的命令会出错。 -\begin{table}[htp] -\centering -\caption{计数器输出格式相关命令。}\label{tbl:counter-commands} -\begin{tabular}{lp{22em}l} - \hline - \textbf{命令} & \textbf{样式} & \textbf{范围} \\ - \hline - \cmd{arabic} & 阿拉伯数字(默认) & \\ - \cmd{alph} & 小写字母 & 限 0-26 \\ - \cmd{Alph} & 大写字母 & 限 0-26 \\ - \cmd{roman} & 小写罗马数字 & 限非负整数 \\ - \cmd{Roman} & 大写罗马数字 & 限非负整数 \\ - \cmd{fnsymbol} & 一系列符号,用于 \cmd{thanks} 命令生成的脚注 & 限 0-9 \\ - \hline -\end{tabular} -\begin{quotation} -\small -\makeatletter -注:\cmd{fnsymbol} 使用的符号顺次为: -\@fnsymbol{1} \@fnsymbol{2} \@fnsymbol{3} -\@fnsymbol{4} \@fnsymbol{5} \@fnsymbol{6} -\@fnsymbol{7} \@fnsymbol{8} \@fnsymbol{9} -\makeatother -\end{quotation} -\end{table} - -计数器的输出格式还可以利用其它字符,甚至其它计数器的输出格式与之组合。如标准文档类里对 \cmd{sub\-section} 相关的计数器的输出格式的定义相当于: -\begin{verbatim} -\renewcommand\thesubsection{\thesection.\arabic{subsection}} -\end{verbatim} - -\subsection{\LaTeX\ 中的计数器}\label{subsec:latex-counts} - -\begin{itemize} - \item 所有章节命令 \cmd{chapter}、\cmd{section} 等分别对应计数器 chapter、section 等等,而且有上下级的关系。 - 而计数器 part 是独立的。 - \item 有序列表 \env{enumerate} 的各级计数器为 enumi, enumii, enumiii, enumiv,也有上下级的关系。 - \item 图表浮动体的计数器就是 table 和 figure;公式的计数器为 equation。 - 这些计数器在 \cls{article} 文档类中是独立的,而在 \cls{book} 和 \cls{report} 中以 chapter 为上级计数器。 - \item 页码、脚注的计数器分别是 page 和 footnote。 -\end{itemize} - -我们可以利用前面介绍过的命令,修改计数器的样式以达到想要的效果,比如把页码修改成大写罗马字母,左右加横线,或是给脚注加上方括号: -\begin{verbatim} -\renewcommand\thepage{--~\Roman{page}~--} -\renewcommand\thefootnote{[\arabic{footnote}]} -\end{verbatim} - -\cmdindex{pagenumbering} -我们在 \ref{subsec:basic-pagesyle} 小节中见过命令 \cmd{pagenum\-bering}。 -它的内部机制是修改 page 计数器的格式 \cmd{thepage},并将计数器的值重置为 1。 - -最后介绍两个有用的计数器: - -\subsubsection{secnumdepth} - -\index{secnumdepth@secnumdepth (\textit{计数器})} -\LaTeX\ 标准文档类对章节划分了层级: -\begin{itemize} - \item 在 \cls{article} 文档类里 part 为 0,section 为 1,依此类推; - \item 在 \cls{report}/\cls{book} 文档类里 part 为 -1,chapter 为 0,section 为 1,等等。 -\end{itemize} - -secnumdepth 计数器控制章节编号的深度,如果章节的层级大于 secnumdepth,那么章节的标题、在目录和页眉页脚的标题都不编号 -(照常生成目录和页眉页脚),章节计数器也不计数。 - -可以用 \cmd{setcounter} 命令设置 secnumdepth 为较大的数使得层级比较深的章节也编号, -如设置为 4 令 \cmd{paragraph} 也编号;或者设置一个较小的数以取消编号,如设置为 -1 令 \cmd{chapter} 不编号。 -后者是生成不编号的章节的一个妙招,免去了手动使用 \cmd{add\-contents\-line} 和 \cmd{mark\-both} 的麻烦。 - -secnumdepth 计数器在 \cls{article} 文档类里默认为 3 (subsubsection 一级);在 \cls{report} 和 \cls{book} 文档类里默认为 2 (subsection 一级)。 - -\subsubsection{tocdepth} - -\index{tocdepth@tocdepth (\textit{计数器})} -tocdepth 计数器控制目录的深度,如果章节的层级大于 tocdepth,那么章节将不会自动写入目录项。默认值同 secnumdepth。 - -\section{\LaTeX\ 可定制的一些命令和参数}\label{sec:latex-settings} - -\LaTeX\ 事实上有相当一些可以定制的命令和参数,不过对于修改样式或者开发宏包来说,这些定制项还远远不够。 - -对于用户来讲,容易定制的是这一些项目: - -\begin{itemize} - \item 标题名称/前后缀等。表 \ref{tbl:latex-settings-names} 列出了标准文档类里可定制的项目, - 表中所有的 \LaTeX\ 命令都可以用 \cmd{re\-new\-comm\-and} 来修改。 - \item 长度。前文在叙述各种排版元素时已经涉及到一些,现归纳于表 \ref{tbl:latex-settings-lengths}。 - 表中所有的长度命令可用 \cmd{setlength} 来修改。 - 大多数控制页面尺寸的长度参数在图 \ref{fig:layouts} 给出,此处不再赘述。 -\end{itemize} - -\begin{table}[htp] -\centering -\caption{\LaTeX\ 可定制的标题名称/前后缀。}\label{tbl:latex-settings-names} -\small -\begin{tabular}{llp{24em}} - \hline - \textbf{命令} & \textbf{默认值} & \textbf{含义} \\ - \hline - \cmd{partname} & Part & \cmd{part} 命令生成的标题前缀 \\ - \cmd{chaptername} & Chapter & \cmd{chapter} 命令生成的标题前缀 \\ - \cmd{appendixname} & Appendix & 使用 \cmd{appendix} 命令生成的附录部分的章标题前缀 \\ - \cmd{abstractname} & Abstract & 摘要环境 \env{abstract} 的标题名称 \\[1ex] - \cmd{contentsname} & Contents & \cmd{tableofcontents} 命令生成的目录标题 \\ - \cmd{listfigurename} & List of Figures & \cmd{listoffigures} 命令生成的插图目录标题 \\ - \cmd{listtablename} & List of Tables & \cmd{listoftables} 命令生成的表格目录标题 \\[1ex] - \cmd{tablename} & Table & \env{table} 浮动体中 \cmd{caption} 命令生成的标题前缀 \\ - \cmd{figurename} & Figure & \env{figure} 浮动体中 \cmd{caption} 命令生成的标题前缀 \\[1ex] - \cmd{refname} & References & \env{thebibliography} 环境或 \cmd{biblio\-graphy} - 命令生成的参考文献标题(\cls{article} 文档类) \\ - \cmd{bibname} & Bibliography & \env{thebibliography} 环境或 \cmd{biblio\-graphy} - 命令生成的参考文献标题(\cls{book / report} 文档类)\\ - \cmd{indexname} & Index & \cmd{printindex} 命令生成的索引标题 \\ - \hline -\end{tabular} -\begin{quotation}\footnotesize% -注:形如“第 X 章”和“第 X 部分”的中文章节标题不能直接由修改本表的命令得到,需要使用 \pkg{titlesec} 等宏包定制。 -如果使用 \pkg{ctex} 宏包或文档类,那么标题默认被修改成“第 X 章”和“第 X 部分”的形式,本表中的其它标题也修改为中文标题。详见 \pkg{ctex} 宏包的帮助文档。 -\end{quotation} -\end{table} - -\begin{table}[htp] -\centering -\caption{\LaTeX\ 可定制的长度参数。}\label{tbl:latex-settings-lengths} -\small -\begin{tabular}{lll} - \hline - \textbf{命令} & \textbf{默认值} & \textbf{含义} \\ - \hline - \cmd{fboxrule} & 0.4pt & \cmd{fbox} 或 \cmd{framebox} 等带框盒子的线宽 \\ - \cmd{fboxsep} & 3pt & \cmd{fbox} 或 \cmd{framebox} 等带框盒子的内边距 \\[1ex] - \cmd{arraycolsep} & 5pt & \env{array} 环境的表格项前后的间距 \\ - \cmd{tabcolsep} & 6pt & \env{tabular} 环境的表格项前后的间距 \\ - \cmd{arrayrulewidth} & 0.4pt & 表格线宽 \\ - \cmd{doublerulesep} & 2pt & 连续两根表格线之间的间距 \\[1ex] - \cmd{abovecaptionskip} & 10pt & \cmd{caption} 命令位于图表下方时,与上方图表的间距 \\ - \cmd{belowcaptionskip} & 0pt & \cmd{caption} 命令位于图表上方时,与下方图表的间距 \\[1ex] - \cmd{columnsep} & 10pt & 双栏排版下两栏的间距 \\ - \cmd{columnseprule} & 0pt & 双栏排版下两栏之间竖线的宽度 \\ - \hline -\end{tabular} -\begin{quotation}\footnotesize% -注:\cmd{arraycolsep} 和 \cmd{tabcolsep} 是每个表格项本身前后的间距(表格线前后无间距;\texttt{@} 列格式会消除与前后表格项的间距)。 -两个表格项之间的间距相当于 2\cmd{arraycolsep} 或 2\cmd{tabcolsep}。 -\end{quotation} -\end{table} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.A.install.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.A.install.tex new file mode 100644 index 00000000000..81f5b5b1d3d --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.A.install.tex @@ -0,0 +1,137 @@ +\chapter{安装 \protect\TeX{} 发行版}\label{app:install} + +\begin{intro} +高德纳的 \TeX{} 程序开发于 20 世纪 80 年代,那时候电子计算机的运算能力有限,\TeX{} 还是大型服务器上的玩物。 +而如今个人计算机完全能够胜任排版的工作,并催生了用于个人计算机的工具集合—— \TeX{} 发行版的发展。 + +本章会简单介绍如何安装 \TeX{} 发行版,以及保持发行版的内容紧跟最新。后者非常重要, +因为 \LaTeX{} 宏包是不断更新换代的。 +\end{intro} + +\section{\protect\TeX{} 发行版简介}\label{sec:dists} + +一个\textbf{\TeX{} 发行版}是 \TeX{} 排版引擎、支持排版的文件(基本格式、\LaTeX{} 宏包、字体等)以及一些辅助工具的集合。 +各式各样的 \TeX{} 发行版经过十多年的发展,大浪淘沙,现今的两个主流发行版为: +\begin{itemize} + \item \textbf{\hologo{TeXLive}}\par + \hologo{TeXLive} 由类 UNIX 系统上的 \hologo{teTeX} 发展并取而代之,最终成为跨平台的 \TeX{} 发行版。 + \hologo{TeXLive} 自 2011 年起以年份作为发行版的版本号,保持了一年一更的频率。 + + \hologo{MacTeX} 是 macOS(OS X)系统下的一个定制化的 \hologo{TeXLive} 版本,与 \hologo{TeXLive} 同步更新。 + + \item \textbf{\hologo{MiKTeX}}\par + \hologo{MiKTeX} 是主要用于 Windows 平台的一个稳定发展的 \TeX{} 发行版。 + 在中国大陆曾经发行过“\hologo{CTeX} 套装”,它是一个经过本地化配置的 \hologo{MiKTeX},不过其配置较为过时,也不再有更新支持,使用起来可能有诸多问题,现已不推荐使用。 +\end{itemize} + +\hologo{TeXLive} 和 \hologo{MiKTeX} 都集成了一个简单的 \LaTeX{} 源代码编辑器 TeXworks(\hologo{MacTeX} 则集成了类似的 TeXShop)。 +用户在安装完毕后,可直接使用 TeXworks 编写和编译 \LaTeX{} 源代码。 + +\subsection{安装发行版}\label{subsec:install-dists} + +\subsubsection{\hologo{TeXLive}} + +\hologo{TeXLive} 的光盘镜像发布于 \url{http://www.tug.org/texlive/}% +\footnote{Linux 发行版的软件源也提供 \hologo{TeXLive} 的安装,不过不够完整,更新也不是很及时。建议直接从镜像安装。}。 +下载镜像到本地,挂载到虚拟光驱,或者用压缩工具解压后,在其根目录有几个用于安装的脚本: +\begin{itemize} + \item 用于 Windows 的批处理文件: + \begin{itemize} + \item \texttt{install-tl-windows.bat} 双击启动图形界面安装程序(简单安装); + \item \texttt{install-tl-advanced.bat} 双击启动图形界面安装程序(定制安装); + \item 在命令提示符中输入 \texttt{install-tl-windows.bat -no-gui} 启动文本界面安装程序。 + \end{itemize} + \item 用于 Linux 的 Perl 脚本 \texttt{install-tl} : + \begin{itemize} + \item \texttt{install-tl} 启动文本界面安装程序; + \item \texttt{install-tl -gui=wizard} 启动图形界面安装程序(简单安装); + \item \texttt{install-tl -gui=peritk} 启动图形界面安装程序(定制安装)。 + \end{itemize} +\end{itemize} +另外也可以下载在线安装程序 \texttt{install-tl.zip},包含以上所有安装脚本。安装过程中会从 CTAN 软件源下载所有组件。 + +Linux 下 \hologo{TeXLive} 安装完毕后,一般还需要在 root 权限下进行以下操作,使得 \hologo{XeLaTeX} 能正确通过 \pkg{fontspec} +等宏包使用字体\footnote{\url{http://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf},% +可用 \texttt{texdoc texlive-zh-cn} 在本地打开。}: +\begin{enumerate} + \item 将 \texttt{texlive-fontconfig.conf} 文件复制到 \texttt{/etc/fonts/conf.d/09-texlive.conf}。 + \item 运行 \texttt{fc-cache -fsv}。 +\end{enumerate} + +\subsubsection{\hologo{MiKTeX}} +从 \hologo{MiKTeX} 官网 \url{http://www.miktex.org/} 下载名为 \texttt{basic-miktex-***.exe} 的 Windows 安装程序包。 +下载后直接双击打开,按照程序的提示进行安装即可。 + +\section{安装和更新宏包}\label{sec:pkg-manager} + +\hologo{TeXLive} 和 \hologo{MiKTeX} 分别提供了图形界面的宏包管理器 \hologo{TeXLive} Manager 和 +\hologo{MiKTeX} Package Manager,用于安装、管理和更新宏包。一般情况下,直接在图形界面的工具下按提示操作即可 +(\hologo{MiKTeX} Package Manager 有普通权限和管理员权限的版本,建议总是使用管理员权限的版本)。 + +两者也可以通过各自的命令行工具安装和更新宏包: +\begin{verbatim} +% TeX Live 命令行工具 tlmgr 的使用示例 +% 安装/卸载宏包 +tlmgr install +tlmgr remove +% 更新所有宏包(包括 tlmgr 本身) +tlmgr update --all --self +% 列出所有可更新的宏包 +tlmgr update --list +% 指定更新源地址 +% 形如 https://mirrors.tuna.tsinghua.edu.cn/CTAN +tlmgr repository set /systems/texlive/tlnet +% 查看宏包信息,加 --list 参数可列出宏包的所有文件 +tlmgr info +\end{verbatim} + +\begin{verbatim} +% MiKTeX 命令行工具 mpm 的使用示例 +% 建议始终加 --admin 参数使用 +% 安装/卸载宏包 +mpm --admin --install +mpm --admin --uninstall +% 更新所有宏包 +mpm --admin --update +% 列出所有可更新的宏包 +mpm --admin --find-updates +% 指定更新源地址 +mpm --admin --set-repository=/systems/win32/miktex/tm/packages +% 查看宏包信息 +mpm --admin --print-package-info +\end{verbatim} + +\hologo{TeXLive} 默认安装所有宏包,而 \hologo{MiKTeX} 的安装程序只包含了 \LaTeX{} 的一些基本宏包。从 \hologo{TeXLive} 的光盘镜像和 \hologo{MiKTeX} 的安装包体积可见一斑。 +默认情况下,编译过程中如果遇到宏包未安装而报错的情况下,\hologo{MiKTeX} 会弹出一个对话框,让用户可以选择临时安装宏包,安装成功后继续编译。 + +\subsection{手动安装宏包}\label{subsec:pkg-manual-install} + +\textbf{\textcolor{red}{如非万不得已,尽量不要手动安装宏包}}。绝大多数宏包都已打包到 \hologo{TeXLive} 和 \hologo{MiKTeX} 两大发行版的安装源, +可用宏包管理器安装。如果用户知道某个宏包的名称,但不确定是否在发行版中已打包,可在 CTAN 中搜索。 + +如果确实有手动安装宏包的需要,本小节的内容将有所帮助。在手动安装之前,有必要了解一下 \TeX{} 目录结构(\TeX{} Directory Structure, TDS)。 +它是 \TeX{} 发行版中宏包、字体、帮助文档等文件的组织结构。TDS 有时也称为 TEXMF 树,取 \TeX$+$\hologo{METAFONT} 之意。 + +以 \hologo{TeXLive} 为例,假设系统的 TEXMF 树根目录为 \nolinkurl{C:\\texlive\\2020\\texmf-dist},其下有很多子目录,仅举几例: +\begin{description} + \item[\texttt{tex/latex}] \LaTeX{} 宏包。 + \item[\texttt{doc/latex}] \LaTeX{} 宏包的帮助文档。 + \item[\texttt{source/latex}] \LaTeX{} 宏包的源代码。 + \item[\texttt{bibtex}] \hologo{BibTeX} 工具相关文件,许多宏包配套的 \hologo{BibTeX} 格式文件位于子目录 \texttt{bst} 中。 + \item[\texttt{fonts/tfm}] \TeX{} 使用的字体文件,TFM 格式。 + \item[\texttt{fonts/type1}] PostScript 字体文件(Type1),PFB 格式。 + \item[\texttt{fonts/opentype}] OpenType 格式的字体文件。 +\end{description} + +需要手动安装的宏包,一般已经按照上述目录结构打包完成。手动安装时,尽量不要拷贝到系统的 TEXMF 树,而是拷贝到发行版提供的用户 TEXMF 树,如 +\hologo{TeXLive} 的 \nolinkurl{C:\\texlive\\texmf-local}。安装完成后,还需\textbf{刷新 \TeX{} 发行版的文件名数据库},令新安装的宏包文件能够被系统找到。 +\hologo{TeXLive} 用户须在 Windows 命令行或者 Linux 终端执行命令: +\begin{verbatim} +mktexlsr +\end{verbatim} +\hologo{MiKTeX} 用户的命令为: +\begin{verbatim} +initexmf --update-fndb +\end{verbatim} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.B.error.help.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.B.error.help.tex new file mode 100644 index 00000000000..fb14d48bb34 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/app.B.error.help.tex @@ -0,0 +1,246 @@ +\chapter{排除错误、寻求帮助}\label{chap:error-helps} + +\begin{intro} +\LaTeX{} 入门用户总会为两大问题头疼:我写的代码到底哪里出错了?如果想要实现某种用法该怎么办? +本章首先总结了常见的 \LaTeX{} 错误及应对的办法。 +\end{intro} + +\section{\LaTeX{} 错误}\label{sec:errors} + +当我们用排版引擎编译 \LaTeX{} 代码时,命令行的窗口(终端)会显示大量信息(TeXworks 等编辑器会有一个区域显示这些信息)。 +当编译过程中出现错误时,信息将会停止在出错的地方,等待我们接下来的操作。 + +比如说我们有一个明显出错的例子: +\begin{verbatim} +\documentclass{article} +\begin{document} +Test \LaTEx{} and it's friends. +\end{document} +\end{verbatim} + +编译过程中遇到这个错误将会停顿下来,提示错误,并等待用户输入指令: +\begin{verbatim} +! Undefined control sequence. +l.3 Test \LaTEx + {} and it's friends. +\end{verbatim} + +这种错误信息分两部分,前一部分提示了错误的信息,后一部分指出了错误发生的行号, +以及通过错落的文字告知发生错误的命令所在位置。如上错误显示 \cmd{LaTEx} 位置发生了错误,错误信息是“未定义的控制序列”, +意思是 \cmd{LaTEx} 是 \TeX{} 编译器无法识别的一个命令,很显然是我们把 \cmd{LaTeX} 的大小写写错了。 + +\subsubsection{处理方式} + +出现错误时,编译过程将暂停,等待用户输入命令。用户可以直接敲回车跳过当前的错误,继续编译,相当于丢掉了写错的命令, +将``Test and it's friends.''排版出来。但这个例子过于简单,有些复杂的代码中,有可能会由于一个小问题导致一连串的错误。 +此时可以选择按 \textbf{S/R/Q} 选择跳过接下来的所有错误,或者按 \textbf{X} 直接退出编译,将源代码中的错误修改后重新编译。 + +\subsubsection{常见的 \LaTeX{} 错误信息} + +笔者在此总结一些经常发生、问题比较明确的 \LaTeX{} 错误: + +\long\def\LaTeXerror#1{\begingroup\color{red}\bfseries\ttfamily{}#1\endgroup} + +\begin{itemize} +\item \LaTeXerror{! Undefined control sequences.} + +使用了未定义的命令。拼写错误是原因之一,如把 \cmd{LaTeX} 写作 \cmd{Latex} 这样。 +也有可能是没有调用某个宏包,但用了该宏包定义的命令。 + +\item \LaTeXerror{! LaTeX error: Environment ... undefined.} + +使用了未定义的环境。 + +\item \LaTeXerror{! Missing \$ inserted.} + +缺少数学环境的符号 \texttt\$。多由于将数学符号用在公式之外而导致。 + +\item \LaTeXerror{Runaway argument? \\ + ! Paragraph ended before ... was complete.} + +\item \LaTeXerror{! File ended while scanning definition/use of ...} + +这两个错误主要是由于漏写了包裹命令参数的花括号,导致识别参数时出现错误。许多编辑器的括号配对功能有助于检查和消除这类错误。 + +这类错误还有可能是由于前一次编译中断导致 \texttt{.aux} 等辅助文件不完整,再次编译读入不完整的文件产生错误。解决办法是删除辅助文件并重新编译。 + +\item \LaTeXerror{! Extra alignment tab has been changed to \cmd{cr}.} + +\item \LaTeXerror{! Misplaced \cmd{noalign}.} + +两个错误信息都与表格有关。 +\begin{itemize} + \item 前者的字面意义是“一行中使用的列分隔符 \texttt\& 太多”,有时可能确实是 \texttt\& 的个数和列格式不匹配, + 但多数情况是漏掉了行尾的 \crcmd{} 命令。 + \item 后者常出现于漏掉了行尾的 \crcmd{} 命令而接着使用 \cmd{hline} 命令画横线的时候。 +\end{itemize} + +\item \LaTeXerror{! LaTeX Error: Lonely \cmd{item}-{}-perhaps a missing list environment.} + +\item \LaTeXerror{! LaTeX Error: Something's wrong-{}-perhaps a missing \cmd{item}.} + +两个错误信息都与列表环境和 \cmd{item} 命令有关。前者意味着在没有使用列表环境的情况下用了 \cmd{item}; +后者则相反,是在列表环境中漏了 \cmd{item}。 + +\item \LaTeXerror{! I can't find file `...'.} + +\item \LaTeXerror{! LaTeX Error: File `...' not found.} + +两个错误都意味着缺少文件。 +\begin{itemize} + \item 如果使用 \cmd{input} 或者 \cmd{include} 命令添加文件,出现上述错误的原因当然是文件不存在或者文件名不对; + \item 如果错误提示里的文件名带 \texttt{.cls} 或者 \texttt{.sty} 扩展名,那么很显然,是因为\textbf{没有安装所需的宏包或文档类}。 +\end{itemize} + +\item \LaTeXerror{! LaTeX Error: Missing \cmd{begin}\marg*{document}.} + +字面上是缺少 \cmd{begin}\marg*{docu\-ment},实际上往往是由于在 \cmd{begin}\marg*{docu\-ment} 之前(导言区)输入了文字或某些命令。 + +\item \LaTeXerror{! LaTeX Error: Can be used only in preamble.} + +与上一条相反,由于将必须用于导言区的命令在 \cmd{begin}\marg*{docu\-ment} 之后使用而产生。 + +\item \LaTeXerror{! LaTeX Error: \cmd{begin}\marg*{...} on input line ... ended by \cmd{end}\marg*{...}.} + +环境首尾不匹配。比如 \cmd{begin}\marg*{enumerate} 用了 \cmd{end}\marg*{itemize} 结尾。或者也可能是由于漏写了 \cmd{begin} +或者 \cmd{end} 命令。 + +\item \LaTeXerror{! LaTeX Error: Option clash for package `...'.} + +以\textbf{不同选项}重复调用宏包造成冲突。有可能是因为其它宏包内部事先调用了这个宏包,用户再次带选项调用而导致冲突。 +解决问题的办法是去掉重复调用的宏包。如果宏包允许的话,尽量使用其定义的命令改变设置,减少宏包选项的使用。 + +\item \LaTeXerror{! LaTeX Error: Command ... already defined, \\ + or name \cmd{end}... illegal ...} + +使用 \cmd{newcommand} 或 \cmd{newenvironment} 定义已有的命令/环境时产生的错误。如果自己确实作了定义,可考虑用 +\cmd{re\-new\-command} 或 \cmd{re\-new\-environment} 定义;如果是宏包定义的命令产生了这个错误,则属于隐性的宏包冲突。 + +相比之前的 ``Option Clash''{},隐性宏包冲突是更难以解决的问题,对各种宏包不熟悉的用户,尤其是使用模板的用户而言,往往难以下手。 +用户可尝试查找引起冲突的宏包的帮助文档。详尽的手册里通常会告知用户这个宏包应当在某个宏包的前面/后面调用,或者不能与某个宏包一起调用。 +如果是模板调用了大量宏包导致冲突,可联系模板的作者解决。 + +\item \LaTeXerror{! LaTeX Error: Unknown option `...' for package `...'.} + +调用宏包时指定了不能被其识别的选项。此时应该查找宏包的帮助文档来解决问题。 + +\item \LaTeXerror{! Package `...' error: ...} + +宏包或文档类自定义的错误,由于不正确地使用宏包里的命令而导致。此时应该查找宏包的帮助文档来解决问题。 + +\end{itemize} + +\section{查找帮助文档}\label{sec:texdoc} + +\index{texdoc@\texttt{texdoc} 工具} +无论是 \hologo{TeXLive} 还是 \hologo{MiKTeX},提供了一个命令行模式的程序 \texttt{texdoc}。 +比如对 \ref{subsec:fancyhdr} 小节的 \pkg{fancyhdr} 宏包感兴趣,这时在 Windows 命令提示符或者 Linux 终端输入以下命令, +则会弹出宏包的帮助文档 \texttt{fancyhdr.pdf}: +\begin{verbatim} +texdoc fancyhdr +\end{verbatim} + +除了宏包的帮助文档外,\TeX{} 发行版还包括了各类有用的文档,有一部分在参考文献中给出。 + +如果不熟悉命令行工具的话,\hologo{TeXLive} 提供了一个图形界面的程序 TeXdoc GUI。打开后,可以看到程序里的许多按钮,分别代表某一类的帮助文档。 +除此之外,点击 File Search 弹出搜索框,输入想要搜索的宏包和文件并按回车键,TeXdoc GUI 会弹出它搜索到的所有结果,可点击任意一项来打开文档。 + +当然对于初学者,有一个现实而棘手的问题:\textbf{某个命令到底是 \LaTeX{} 自有的,还是哪个宏包提供的?} +很遗憾地说,除了通过慢慢积累、熟悉较多宏包之外,没有很方便的办法解决这个问题,因为 \LaTeX{} 的宏包实在太丰富了。 +本手册末尾的索引给出了所有在本手册见到的命令和环境,其中哪些命令和环境需要调用哪个宏包才能使用,一目了然。但是这个索引远远不够。 + +解决这个问题有几点可行的办法: +\begin{enumerate} + \item 查询一些综述性的资料,如总结所有 \LaTeX{} 自带命令的文档 \cite{latex2e}、\LaTeX{} 符号大全 \cite{symbols} 等; + \item 在互联网上搜索自己不清楚的命令; + \item 在论坛上提问求助有经验的人。 +\end{enumerate} + +\section{常用宏包简介}\label{sec:pkg-list} + +\def\pkglabel#1{\makebox[60pt][l]{\pkg{#1}}} +\newenvironment{pkglist}% + {\list{}{% + \labelwidth=60pt + \itemindent=0pt + \leftmargin=60pt + \labelsep=0pt + \let\makelabel\pkglabel}}% + {\endlist} + +此处不包含设置字体或数学符号的宏包,它们已经在表 \ref{tbl:font-pkgs} 中列出。 + +\subsection{文字、公式和符号}\label{subsec:text-math-symbols} + +\begin{pkglist} + \item[amsmath] \hologo{AmS} 数学公式扩展。 + \item[mathtools] 数学公式扩展宏包,提供了公式编号定制和更多的符号、矩阵等。 + \item[amsfonts] \hologo{AmS} 扩展符号的基础字体支持。 + \item[amssymb] 在 \pkg{amsfonts} 基础上将 \hologo{AmS} 扩展符号定义成命令。 + \item[bm] 提供将数学符号加粗的命令 \cmd{bm}。 + \item[siunitx] 以国际单位规范排版物理量的单位。 + \item[mhchem] 排版化学式和方程式。 + \item[tipa] 排版国际音标。 +\end{pkglist} + +\subsection{排版元素}\label{subsec:pkg-elements} + +\begin{pkglist} + \item[ulem] 提供排版可断行下划线的命令 \cmd{uline} 以及其它装饰文字的命令。 + \item[endnote] 排版尾注。 + \item[marginnote] 改善的边注排版功能。 + \item[multicol] 提供将内容自由分栏的 \env{multicols} 环境。 + \item[multitoc] 生成多栏排版的目录。 + \item[minitoc] 为章节生成独立的小目录。 + \item[glossaries] 生成词汇表。 + \item[verbatim] 对原始的 \env{verbatim} 环境的改善。提供了命令 \cmd{verbatim\-input} 调用源文件。 + \item[fancyvrb] 提供了代码排版环境 \env{Verbatim} 以及对版式的自定义。 + \item[listings] 提供了排版关键字高亮的代码环境 \env{lst\-listing} 以及对版式的自定义。类似宏包有 \pkg{minted}。 + \item[algorithmic] 一个简单的实现算法排版的宏包。如果要生成浮动体的话,需要搭配 \pkg{algorithm} 宏包使用。 + \item[algorithm2e] 较为复杂的、可定制的算法排版宏包。类似宏包有 \pkg{algorithmicx} 等。 + \item[ntheorem] 定制定理环境。类似宏包包括 \pkg{theorem}、\pkg{thmtools}、\pkg{amsthm} 等。 + \item[mdframed] 排版可自动断页的带边框文字段落,提供边框样式的定制功能。 + \item[tcolorbox] 以 \hologo{TikZ} 为基础提供排版样式丰富的彩色盒子的功能。 +\end{pkglist} + +\subsection{图表和浮动体}\label{subsec:pkg-tab-fig} + +\begin{pkglist} + \item[booktabs] 排版三线表。 + \item[array] 对表格列格式的扩展。 + \item[tabularx] 提供 \env{tabularx} 环境排版定宽表格,支持自动计算宽度的 X 列格式。 + \item[arydshln] 支持排版虚线表格线。 + \item[colortbl] 支持修改表格的行、列、单元格的颜色。 + \item[multirow] 支持合并多行单元格。 + \item[makecell] 支持在单元格里排版多行内容(嵌套一个单列的小表格)。 + \item[diagbox] 排版斜线表头。 + \item[longtable] 提供排版跨页长表格的 \env{longtable} 环境。 + \item[ltxtable] 跨页长表格可使用 \env{tabularx} 的 X 列格式。 + \item[tabu] 提供排版复杂格式表格的 \env{tabu} 环境。与 \pkg{longtable} 一同调用时,提供排版复杂格式跨页长表格的 \env{longtabu} 环境。 + \item[graphicx] 支持插图。 + \item[bmpsize] \texttt{latex} + \texttt{dvipdfmx} 命令下支持 BMP/JPG/PNG 等格式的位图。 + \item[epstopdf] \texttt{pdflatex} 命令下支持 EPS 格式的矢量图。 + \item[wrapfig] 支持简单的文字在图片周围的绕排。 + \item[subfig] 提供子图表和子标题的排版。类似宏包有 \pkg{subfigure} 和 \pkg{subcaption} 等。 + \item[caption] 控制浮动体标题的格式。 + \item[bicaption] 生成双语浮动体标题。 + \item[float] 为浮动体提供不浮动的 H 模式;提供自定义浮动体结构的功能。 +\end{pkglist} + +\subsection{修改版式}\label{subsec:pkg-layout} + +\begin{pkglist} + \item[geometry] 修改页面尺寸、页边距、页眉页脚等参数。 + \item[fancyhdr] 修改页眉页脚格式,令页眉页脚可以左对齐、居中、右对齐。 + \item[titlesec] 修改章节标题 \cmd{chapter}、\cmd{section} 等的格式。 + \item[titletoc] 修改目录中各条目的格式。 + \item[tocloft] 类似 \pkg{titletoc} 的修改目录条目格式的宏包。 + \item[tocbibind] 支持将目录、参考文献、索引本身写入目录项。 + \item[footmisc] 修改脚注 \cmd{footnote} 的格式。 + \item[indentfirst] 令章节标题后的第一段首行缩进。 + \item[enumerate] 提供简单的自定义标签格式的 \env{enumerate} 环境。 + \item[enumitem] 修改列表环境 \env{enumerate} 和 \env{itemize} 等的格式。 + \item[lettrine] 生成段落首字母大写的效果。 +\end{pkglist} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/biblio.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/biblio.tex new file mode 100644 index 00000000000..76f6fc7a80a --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/biblio.tex @@ -0,0 +1,103 @@ +\begin{thebibliography}{20} + +\item[\S] {\bfseries \LaTeX{} 经典书籍:} + +\bibitem{manual} Leslie Lamport. + \newblock \emph{\LaTeX: A Document Preparation System}, 2nd edition. + \newblock Addison-Wesley, Reading, Massachusetts, 1994, ISBN~0-201-52983-1. + +\bibitem{companion} Frank Mittelbach, Michel Goossens, Johannes Braams, David Carlisle, Chris Rowley. + \newblock \emph{The \LaTeX{} Companion}, 2nd edition. + \newblock Addison-Wesley, Reading, Massachusetts, 2004, ISBN~0-201-36299-6. + +\bibitem{graphicscompanion} Michel Goossens, Sebastian Rahtz and Frank Mittelbach. + \newblock \emph{The \LaTeX{} Graphics Companion}, 2nd edition. + \newblock Addison-Wesley, Reading, Massachusetts, 1997, ISBN~0-301-50892-0. + +\bibitem{guide2latex} Helmut Kopka and Patrick~W. Daly, + \newblock \emph{Guide to \LaTeX}, 4th edition. + \newblock Addison-Wesley, Reading, Massachusetts, 2004, ISBN~0-321-17385-6. + +\bibitem{leoliu} 刘海洋. + \newblock \emph{\LaTeX{} 入门}. + \newblock 电子工业出版社, 北京, 2013, ISBN~978-7-121-20208-7. + +\item[\S] {\bfseries \TeX{} 经典书籍,介绍底层的命令和排版方式,有志深入学习 \LaTeX{} 者或参与宏包开发者必读。有一些书籍已经开放网络资源:} +\bibitem{texbook} Donald~E. Knuth. + \newblock \emph{The \TeX book}, Volume~A of \textit{Computers and Typesetting}, 2nd edition. + \newblock Addison-Wesley, Reading, Massachusetts, 1984, ISBN~0-201-13448-9. + +\bibitem{impatient} Paul Abrahams, Kathryn A. Hargreaves, Karl Berry. + \newblock \emph{\TeX{} for the impatient}, 2nd edition. + \newblock Addison-Wesley, Reading, Massachusetts, 1984, ISBN~0-201-51375-7. \\ + \CTAN|info/impatient/book.pdf| (\texttt{texdoc impatient}) + +\bibitem{texbytopic} Victor Eijkhout. + \newblock \emph{\TeX{} by Topic, A \TeX nician's Reference}. + \newblock Addison-Wesley, Reading, Massachusetts, 1992, ISBN~0-201-56882-9. \\ + \CTAN|info/texbytopic/TeXbyTopic.pdf| (\texttt{texdoc texbytopic}) + +\item[\S] {\bfseries \TeX{} 发行版内置的资源(除宏包帮助手册之外的一些文档), + 可以在本地使用 \texttt{texdoc} 命令查找,也可以在 CTAN 上找到:} + +\bibitem{usrguide} \LaTeX3 Project Team. + \newblock \emph{\LaTeXe{} for authors}.\\ + \CTAN|macros/latex/doc/usrguide.pdf| (\texttt{texdoc usrguide}) + +\bibitem{clsguide} \LaTeX3 Project Team. + \newblock \emph{\LaTeXe{} for class and package writers}. \\ + \CTAN|macros/latex/doc/clsguide.pdf| (\texttt{texdoc clsguide}) + +\bibitem{fntguide} \LaTeX3 Project Team. + \newblock \emph{\LaTeXe{} font selection}. \\ + \CTAN|macros/latex/doc/fntguide.pdf| (\texttt{texdoc fntguide}) + +\bibitem{latex2e} Karl Berry, Jim Hefferon, Vincent Bela\"{\i}che. + \newblock \emph{\LaTeXe: An unofficial reference manual}. \\ + \CTAN|info/latex2e-help-texinfo/latex2e.pdf| (\texttt{texdoc latex2e}) + +\bibitem{uk-tex-faq} The UK TeX users group (TUG). + \newblock \emph{The UK TeX FAQ}. + \newblock HTML version on \url{https://texfaq.org/}. \\ + \CTAN|help/uk-tex-faq/newfaq.pdf| (\texttt{texdoc faq}) + +\bibitem{l2tabu} J\"{u}rgen Fenn. + \newblock \emph{An essential guide to \LaTeXe{} usage: Obsolete commands and packages} (English translation). \\ + \CTAN|info/l2tabu/english/l2tabuen.pdf| (\texttt{texdoc l2tabuen}) + +\bibitem{symbols} Scott Pakin. + \newblock \emph{The Comprehensive \LaTeX{} Symbol List}. \\ + \CTAN|info/symbols/comprehensive/symbols-a4.pdf| (\texttt{texdoc symbols-a4}) + +\bibitem{cheatsheet} Winston Chang. + \newblock \emph{\LaTeXe{} Cheat Sheet}. \\ + \CTAN|info/latexcheat/latexcheat/latexsheet.pdf| (\texttt{texdoc latexcheat}) + +\item[\S] {\bfseries CTAN 上的其它网络资源:} + +\bibitem{catalogue} Graham Williams. + \newblock \emph{The \TeX{} Catalogue (Preface CTAN Edition)}.\\ + \CTAN|help/Catalogue/catalogue.html| + +\bibitem{survey} Stephen~G. Hartke. + \newblock \emph{A Survey of Free Math Fonts for \TeX{} and \LaTeX}.\\ + \CTAN|info/Free_Math_Font_Survey/survey.pdf| + +\item[\S] {\bfseries 其它网络渠道可获得的资源:} + +\bibitem{fontcatalogue} Palle J{\o}rgensen. + \newblock \emph{The \LaTeX{} font catalogue}, a font catalogue of \LaTeX{} font packages.\\ + \url{http://www.tug.dk/FontCatalogue/} + +\bibitem{ltxprimer} Indian \TeX{} users group. + \newblock \emph{\LaTeX{} Tutorials: A primer}. \\ + \url{http://www.tug.org/twg/mactex/tutorials/ltxprimer-1.0.pdf} + +\bibitem{lnotes} 黄新刚. + \newblock \emph{雷太赫排版系统简介(\LaTeX{} Notes)}, 第二版. \\ + \url{https://github.com/huangxg/lnotes/raw/master/lnotes2.pdf} \\ + (旧版可用 \texttt{texdoc latex-notes-zh-cn}) + +\end{thebibliography} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.01.basics.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.01.basics.tex new file mode 100644 index 00000000000..ef0471b0f68 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.01.basics.tex @@ -0,0 +1,451 @@ +\chapter{\LaTeX{} 的基本概念}\label{chap:basics} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +欢迎使用 \LaTeX{}!本章开头用简短的篇幅介绍了 \LaTeX{} 的来源, +然后介绍了 \LaTeX{} 源代码的写法,编译 \LaTeX{} 源代码生成文档的方法,以及理解接下来的章节的一些必要知识。 +\end{intro} + +\section{概述}\label{sec:intro} + +\subsection{\protect\TeX}\label{subsec:tex} + +\index{Knuth@Knuth, Donald E. (\textit{高德纳})} +\index{TeX@\TeX} +\TeX{} 是高德纳 (Donald E.~Knuth) 为排版文字和数学公式而开发的软件\cite{texbook}。 +1977 年,正在编写《计算机程序设计艺术》的高德纳意识到每况愈下的排版质量将影响其著作的发行, +为扭转这种状况,他着手开发 \TeX{},发掘当时刚刚用于出版工业的数字印刷设备的潜力。 +1982 年,高德纳发布 \TeX{} 排版引擎,而后在 1989 年又为更好地支持 8-bit 字符和多语言排版而予以改进。 +\TeX{} 以其卓越的稳定性、跨平台能力和几乎没有 bug 的特性而著称。 +它的版本号不断趋近于 $\pi$,当前为 3.14159265。 + +\TeX{} 读作 ``Tech'',与汉字“泰赫”的发音相近,其中 ``ch'' 的发音类似于 ``h''。\TeX{} 的拼写来自希腊词语 +τεχνική (technique,技术) 开头的几个字母,在 ASCII 字符环境中写作 \texttt{TeX}。 + +\subsection{\LaTeX}\label{subsec:latex} + +\index{LaTeX@\LaTeX} +\index{LaTeX2e@\LaTeXe} +\LaTeX{} 是一种使用 \TeX{} 程序作为排版引擎的格式(format),可以粗略地将它理解成是对 \TeX{} 的一层封装。 +\LaTeX{} 最初的设计目标是分离内容与格式,以便作者能够专注于内容创作而非版式设计,并能以此得到高质量排版的作品。 +\LaTeX{} 起初由 Leslie Lamport 博士\cite{manual}开发,目前由 \LaTeX 3 工作组% +\footnote{\url{https://www.latex-project.org}}进行维护。 + +\LaTeX{} 读作 ``Lah-tech'' 或者 ``Lay-tech'',与汉字“拉泰赫”或“雷泰赫”的发音相近,在 ASCII 字符环境写作 \texttt{LaTeX}。 +\LaTeXe{} 是 \LaTeX{} 的当前版本,意思是超出了第二版,但还远未达到第三版,在 ASCII 字符环境写作 \texttt{LaTeX2e}。 + +\subsection{\LaTeX{} 的优缺点}\label{subec:advs} + +经常有人喜欢对比 \LaTeX{} 和以 Microsoft Office Word 为代表的“所见即所得”% +(What You See Is What You Get)字处理工具。 +这种对比是没有意义的,因为 \TeX{} 是一个排版引擎,\LaTeX{} 是其封装,而 Word 是字处理工具。 +二者的设计目标不一致,也各自有自己的适用范围。 + +不过,这里仍旧总结 \LaTeX{} 的一些优点: +\begin{itemize} + \item 具有专业的排版输出能力,产生的文档看上去就像“印刷品”一样。 + \item 具有方便而强大的数学公式排版能力,无出其右者。 + \item 绝大多数时候,用户只需专注于一些组织文档结构的基础命令,无需(或很少)操心文档的版面设计。 + \item 很容易生成复杂的专业排版元素,如脚注、交叉引用、参考文献、目录等。 + \item 强大的可扩展性。世界各地的人开发了数以千计的 \LaTeX{} 宏包用于补充和扩展 \LaTeX{} 的功能。 + 本手册附录中的 \ref{sec:pkg-list} 小节可见一瞥。更多的宏包参考 \textit{The \LaTeX{} companion}\cite{companion}。 + \item 能够促使用户写出结构良好的文档——而这也是 \LaTeX{} 存在的初衷。 + \item \LaTeX{} 和 \TeX{} 及相关软件是跨平台、免费、开源的。 + 无论用户使用的是 Windows,macOS(OS X),GNU/Linux 还是 FreeBSD 等操作系统,都能轻松获得和使用这一强大的排版工具,并且获得稳定的输出。 +\end{itemize} + +\LaTeX{} 的缺点也是显而易见的: +\begin{itemize} + \item 入门门槛高。本手册的副标题叫做 “\pageref{lshort-minutes}~分钟了解 \LaTeXe ”, + 实际上 \pageref{lshort-minutes} 是本手册正文部分(包括附录)的页数。如果你以平均一页一分钟的速度看完了本手册, + 你只是粗窥门径而已,离学会它还很远。 + \item 不容易排查错误。\LaTeX{} 作为一个依靠编写代码工作的排版工具,其使用的宏语言比 C++ 或 Python 等程序设计语言在错误排查方面困难得多。 + 它虽然能够提示错误,但不提供调试的机制,有时错误提示还很难理解。 + \item 不容易定制样式。\LaTeX{} 提供了一个基本上良好的样式,为了让用户不去关注样式而专注于文档结构。 + 但如果想要改进 \LaTeX{} 生成的文档样式则是十分困难。 + \item 相比“所见即所得”的模式有一些不便,为了查看生成文档的效果,用户总要不停地编译。 +\end{itemize} + +\subsection{命令行基础} + +\LaTeX{} 和 \TeX{} 及相关软件大多仅提供了命令行接口,而不像 Word、Adobe InDesign 一样有图形用户界面。 +命令行程序的结构往往比较简单,它们接受用户输入,读取相关文件,进行一些操作和运算后输出目标文件, +有时还会将提示信息、运行结果显示在屏幕上。在 Windows 系统上,如需进入命令行,可在开始菜单中搜索 +“命令提示符”,也可在“运行”窗口中输入 \texttt{cmd} 打开;Linux 或 macOS 等 *nix % +\footnote{类 Unix 操作系统,包含 Linux、macOS(OS X)。} +系统中可搜索“Terminal”打开终端。部分系统也提供了一些快捷方式,具体请参考相关手册。 + +与常规软件类似,命令行程序也都是可执行程序,在 Windows 上后缀名为 \texttt{.exe},而在类 Unix 系统上 +则需要带有 \texttt{x} 权限。在大多数命令行环境中,系统会根据\textbf{环境变量} \texttt{PATH} 中存储 +的路径来搜索可供执行的程序。因此在运行之前,需确保 \LaTeX 、\TeX{} 及相关程序所在路径已包含在 +\texttt{PATH} 中。 + +在命令行中运行程序时,需要先输入程序名,其后可加一系列用空格分隔的参数,并按下 Enter 键执行。 +一般情况下,命令行程序执行完毕会自行退出。若遇到错误或中断,可输入 Ctrl+C 以强制结束。 + +使用命令行程序输入、输出文件时,需确保文件路径正确。通常需要先切换到文件所在目录,再执行有关程序。 +切换路径可以执行 +\begin{command} +\verb|cd| \Arg{path} +\end{command} +注意 \Arg{path} 中的多级目录在 Windows 系统上使用反斜线 \verb|\| 分隔,而在类 Unix 系统上使用正斜线 +\verb|/| 分隔。如果 \Arg{path} 中带有空格,则需加上引号 \verb|"|。此外,在 Windows 系统上如果要切换 +到其他分区,还需加上 \verb|/d| 选项,例如 \verb|cd /d "C:\Program Files (x86)\"|。 + +许多用户会使用 TeXworks 或 TeXstudio 等编辑器来编写 \LaTeX{} 文档。这些编辑器提供的编译功能, +实际上只是对特定命令行程序的封装,而并非魔法。 + +\section{第一次使用 \LaTeX}\label{sec:run} + +源代码~\ref{code:hello-world}~是一份最短的 \LaTeX{} 源代码示例。 + +\begin{sourcecode}[htp] +\begin{Verbatim} +\documentclass{article} +\begin{document} +``Hello world!'' from \LaTeX. +\end{document} +\end{Verbatim} +\caption{\LaTeX{} 的一个最简单的源代码示例。}\label{code:hello-world} +\end{sourcecode} + +这里首先介绍如何编译使用这份源代码,在后续小节中再介绍源代码的细节。 +你可以将这份源代码保存为 \texttt{helloworld.tex},而后编译。具体来说: +\begin{itemize} + \item 如果使用 TeXworks 或 TeXstudio 等编辑器,你可以使用编辑器提供的“编译”按钮或者“排版” + 按钮。建议使用 \hologo{pdfLaTeX} 或 \hologo{XeLaTeX} 作为默认的编译方式(不同编译方式的差别, + 见~\ref{sec:concepts}~节)。 + \item 如果使用命令行方式进行编译,则需打开 Windows 命令提示符或者 *nix 的终端, + 在源代码所在的目录下输入: +\begin{verbatim} +pdflatex helloworld +\end{verbatim} +或者 +\begin{verbatim} +xelatex helloworld +\end{verbatim} +\end{itemize} + +如果编译成功,可以在 \texttt{helloworld.tex} 所在目录看到生成的 \texttt{helloworld.pdf} 以及一些其它文件。 + +源代码~\ref{code:hello-world-chinese}~是在 \LaTeX{} 排版中文的一个最简示例。 +编译的方式与上一份源代码相同,但需使用 \hologo{XeLaTeX} 编译方式% +\footnote{注意两个问题:1. 文档保存为 UTF-8 编码;2. 某些发行版需要补充安装较多宏包(如 \hologo{MiKTeX})。}。 +中文支持的详细内容见 \ref{sec:chinese} 节。 + +\begin{sourcecode}[htp] + \begin{Verbatim} + \documentclass{ctexart} + \begin{document} + “你好,世界!” 来自 \LaTeX{} 的问候。 + \end{document} + \end{Verbatim} + \caption{在\LaTeX{} 中排版中文的最简源代码示例。}\label{code:hello-world-chinese} +\end{sourcecode} + +\section{\LaTeX{} 命令和代码结构}\label{sec:src} + +\LaTeX{} 的源代码为文本文件。这些文本除了文字本身,还包括各种命令, +用在排版公式、划分文档结构、控制样式等等不同的地方。 + +\subsection{\LaTeX{} 命令和环境}\label{subsec:cmds} + +\index{LaTeX macro@\LaTeX{} 命令} +\LaTeX{} 中命令\footnote{也叫作控制序列(control sequence)。}以反斜线 \texttt{\textbackslash} 开头,为以下两种形式之一: +\begin{itemize} + \item 反斜线和后面的一串字母,如 \cmd{LaTeX}。它们以任意非字母符号(空格、数字、标点等)为界限。 + \item 反斜线和后面的单个非字母符号,如 \cmd{\$}。 +\end{itemize} + +要注意 \LaTeX{} 命令是\textbf{对大小写敏感}的,比如输入 \cmd{LaTeX} 命令可以生成错落有致的 \LaTeX{} 字母组合, +但输入 \cmd{Latex} 或者 \cmd{LaTex} 什么都得不到,还会报错;它们与 \cmd{LaTeX} 是不同的命令。 + +字母形式的 \LaTeX{} 命令忽略其后的所有连续空格。 +如果要人为引入空格,需要在命令后面加一对花括号阻止其忽略空格% +\footnote{另外也可以在命令后面紧跟一个 \cmd{\textvisiblespace} 命令(反斜线加空格),代表插入一个间距。 +比如 \cmd{TeX}\cmd{\textvisiblespace}\texttt{user} 的输出效果就是 \TeX{} user。}: +\begin{example} +Shall we call ourselves +\TeX users + +or \TeX{} users? +\end{example} + +\pinyinindex{canshu}{参数} +一些 \LaTeX{} 命令可以接收一些参数,参数的内容会影响命令的效果。 +\LaTeX{} 的参数分为可选参数和必选参数。 +可选参数以方括号 \texttt[ 和 \texttt] 包裹;必选参数一般以花括号 \texttt\{ 和 \texttt\} 包裹% +\footnote{以单个字符作为命令的参数时,可以不加括号。例如,在数学环境下, +\cmd{frac}\texttt{12} 和 \cmd{frac}\texttt{\{1\}\{2\}} 的效果是一样的。}。 +还有些命令可以带一个星号 \texttt*,带星号和不带星号的命令效果有一定差异。 +初次接触这些概念时,可以粗略地把星号看作一种特殊的可选参数。 + +\index{LaTeX environment@\LaTeX{} 环境} +\cmdindex{begin,end} +\LaTeX{} 中还包括\textbf{环境},用以令一些效果在局部生效,或是生成特殊的文档元素。 +\LaTeX{} 环境的用法为一对命令 \cmd{begin} 和 \cmd{end}: +\begin{command} +\cmd{begin}\marg{environment name}\oarg{optional arguments}\marg{mandatory arguments} \\ +\ldots \\ +\cmd{end}\marg{environment name} +\end{command} + +其中 \Arg{environment name} 为环境名,\cmd{begin} 和 \cmd{end} 中填写的环境名应当一致。 +类似命令,\marg{mandatory arguments} 和 \oarg{optional arguments} 为环境所需的必选和可选参数。 +\LaTeX{} 环境可能需要一个或多个必选/可选参数,也可能完全不需要参数。 +部分环境允许嵌套使用。 + +\pinyinindex{fenzu}{分组} +有些命令(如 \cmd{bfseries})会对其后所有内容产生作用。若要限制其作用范围,则需要使用\textbf{分组}。 +\LaTeX{} 使用一对花括号 \verb|{| 和 \verb|}| 作为分组,在分组中使用的命令被限制在分组内,不会影响到分组外的内容% +\footnote{个别命令在分组内仍然会产生全局作用,例如第 \ref{sec:counters} 节介绍的 \cmd{setcounter} 等命令。}。 +上文提到的 \LaTeX{} 环境隐含了一个分组,在环境中的命令被包裹在分组内。 +\ref{subsec:fontshape} 和 \ref{subsec:fontsize} 小节中介绍的修改字体和字号的命令用法,即属此类。 + +\subsection{\LaTeX{} 源代码结构}\label{subsec:struct} + +\cmdindex{documentclass} +\envindex{document} +\pinyinindex{wendanglei}{文档类} +\pinyinindex{hongbao}{宏包} +\LaTeX{} 源代码以一个 \cmd{document\-class} 命令作为开头,它指定了文档使用的\textbf{文档类}。 +\env{document} 环境当中的内容是文档正文。 + +\cmdindex{usepackage} +\pinyinindex{daoyanqu}{导言区} +在 \cmd{documentclass} 和 \cmd{begin}\marg*{document} 之间的位置称为\textbf{导言区}。 +在导言区中一般会使用 \cmd{use\-package} 命令调用\textbf{宏包},还会进行文档的全局设置。 +\begin{verbatim} +\documentclass{...} % ... 为某文档类 +% 导言区 +\begin{document} +% 正文内容 +\end{document} +% 此后内容会被忽略 +\end{verbatim} + +\section{\LaTeX{} 宏包和文档类}\label{sec:latex-pkgs} + +本节将仔细解释在 \ref{subsec:struct} 小节中出现的宏包和文档类的概念以及详细用法。 + +\subsection{文档类}\label{subsec:classes} + +\pinyinindex{wendanglei}{文档类} +\textbf{文档类}规定了 \LaTeX{} 源代码所要生成的文档的性质——普通文章、书籍、演示文稿、 +个人简历等等。\LaTeX{} 源代码的开头须用\cmd{document\-class}指定文档类: +\begin{command} +\cmd{documentclass}\oarg{options}\marg{class-name} +\end{command} + +\clsindex{article,book,report} +\clsindex{ctexart,ctexrep,ctexbook} +其中 \Arg{class-name} 为文档类的名称,如 \LaTeX{} 提供的 \cls{article}, \cls{book}, \cls{report}, +在其基础上派生的一些文档类如支持中文排版的 \cls{ctexart} / \cls{ctexbook} / \cls{ctexrep}, +或者有其它功能的一些文档类,如 \cls{moderncv} / \cls{beamer} 等。 +\LaTeX{} 提供的基础文档类见表 \ref{tbl:ltx-classes},其中前三个习惯上称为“标准文档类”。 + +\begin{table}[htp] +\centering +\caption{\LaTeX{} 提供的基础文档类}\label{tbl:ltx-classes} +\begin{tabular}{lp{30em}} + \hline + \cls{article} & 文章格式的文档类,广泛用于科技论文、报告、说明文档等。\\ + \cls{report} & 长篇报告格式的文档类,具有章节结构,用于综述、长篇论文、简单的书籍等。\\ + \cls{book} & 书籍文档类,包含章节结构和前言、正文、后记等结构。\\ + \hline + \cls{proc} & 基于 \cls{article} 文档类的一个简单的学术文档模板。\\ + \cls{slides} & 幻灯格式的文档类,使用无衬线字体。\\ + \cls{minimal} & 一个极其精简的文档类,只设定了纸张大小和基本字号, + 用作代码测试的最小工作示例(Minimal Working Example)。 \\ + \hline +\end{tabular} +\end{table} + +\pinyinindex{xuanxiang}{选项(宏包/文档类)} +可选参数 \Arg{options} 为文档类指定选项,以全局地规定一些排版的参数,如字号、纸张大小、单双面等等。 +比如调用 \cls{article} 文档类排版文章,指定纸张为 A4 大小,基本字号为 11pt,双面排版: +\begin{verbatim} +\documentclass[11pt,twoside,a4paper]{article} +\end{verbatim} + +\LaTeX{} 的三个标准文档类可指定的选项包括: +\begin{description} +\item[\texttt{10pt, 11pt, 12pt}] \quad 指定文档的基本字号。默认为 \texttt{10pt}。 +\item[\texttt{a4paper, letterpaper, \ldots}] \quad 指定纸张大小,默认为美式信纸 \texttt{letterpaper} ($8.5\times11$英寸)。 +可指定选项还包括 \texttt{a5paper},\texttt{b5paper},\texttt{executivepaper} 和 \texttt{legalpaper}。 +\item[\texttt{twoside, oneside}] \quad 指定单面/双面排版。双面排版时,奇偶页的页眉页脚、页边距不同。 +\cls{article} 和 \cls{report} 默认为 \texttt{oneside},\cls{book} 默认为 \texttt{twoside}。 +\item[\texttt{onecolumn, twocolumn}] \quad 指定单栏/双栏排版。默认为 \texttt{onecolumn}。 +\item[\texttt{openright, openany}] \quad 指定新的一章 \cmd{chapter} 是在奇数页(右侧)开始,还是直接紧跟着上一页开始。 +\cls{report} 默认为 \texttt{openany},\cls{book} 默认为 \texttt{openright}。对 \cls{article} 无效。 +\item[\texttt{landscape}] \quad 指定横向排版。默认为纵向。 +\item[\texttt{titlepage, notitlepage}] 指定标题命令 \cmd{maketitle} 是否生成单独的标题页。 +\cls{article} 默认为 \texttt{notitlepage},\cls{report} 和 \cls{book} 默认为 \texttt{titlepage}。 +\item[\texttt{fleqn}] \quad 令行间公式左对齐。默认为居中对齐。 +\item[\texttt{leqno}] \quad 将公式编号放在左边。默认为右边。 +\item[\texttt{draft, final}] \quad 指定草稿/终稿模式。 +草稿模式下,断行不良的地方会在行尾添加一个黑色方块。默认为 \texttt{final}。 +\end{description} + +\subsection{宏包}\label{subsec:packages} + +\cmdindex{usepackage} +\pinyinindex{hongbao}{宏包} +\pinyinindex{xuanxiang}{选项(宏包/文档类)} +在使用 \LaTeX{} 时,时常需要依赖一些扩展来增强或补充 \LaTeX{} 的功能,比如排版复杂的表格、插入图片、增加颜色甚至超链接等等。 +这些扩展称为\textbf{宏包}。调用宏包的方法非常类似调用文档类的方法: +\begin{command} +\cmd{usepackage}\oarg{options}\marg{package-name} +\end{command} + +\cmd{usepackage}~可以一次性调用多个宏包,在 \Arg{package-name} 中用逗号隔开。这种用法一般不要指定选项% +\footnote{使用多个宏包时指定选项,相当于给每个宏包指定同样的选项。如果有某个宏包不能识别指定的选项,则会出错。}: +\begin{verbatim} +% 一次性调用三个排版表格常用的宏包 +\usepackage{tabularx, makecell, multirow} +\end{verbatim} + +附录 \ref{sec:pkg-list} 汇总了常用的一些宏包。我们在手册接下来的章节中,也会穿插介绍一些最常用的宏包的使用方法。 + +在使用宏包和文档类之前,一定要首先确认它们是否安装在你的计算机中,否则 \cmd{use\-package} 等命令会报错误。 +详见附录 \ref{sec:pkg-manager}。 + +宏包(包括前面所说的文档类)可能定义了许多命令和环境,或者修改了 \LaTeX{} 已有的命令和环境。 +它们的用法说明记在相应宏包和文档类的帮助文档。在 Windows 命令提示符或者 Linux 终端下输入命令可查阅相应文档: +\begin{command} +\texttt{texdoc} \Arg{pkg-name} +\end{command} + +其中 \Arg{pkg-name} 是宏包或者文档类的名称。更多获得帮助的方法见附录 \ref{sec:texdoc}。 + +\section{\LaTeX{} 用到的文件一览}\label{sec:latex-files} + +除了源代码文件 \texttt{.tex} 以外,我们在使用 \LaTeX{} 时还可能接触到各种格式的文件。 +本节简单介绍一下在使用 \LaTeX{} 时能够经常见到的文件。 + +每个宏包和文档类都是带特定扩展名的文件,除此之外也有一些文件出现于 \LaTeX{} 模板中: +\begin{description} + \item[\texttt{.sty}] 宏包文件。宏包的名称与文件名一致。 + \item[\texttt{.cls}] 文档类文件。文档类名称与文件名一致。 + \item[\texttt{.bib}] \hologo{BibTeX} 参考文献数据库文件。 + \item[\texttt{.bst}] \hologo{BibTeX} 用到的参考文献格式模板。详见 \ref{subsec:bibtex-use} 小节。 +\end{description} + +\LaTeX{} 在编译过程中除了生成 \texttt{.dvi} 或 \texttt{.pdf} 格式的文档外% +\footnote{\hologo{XeLaTeX} 还可能生成 \texttt{.xdv} 文件。},还可能会生成相当多的辅助文件和日志。 +一些功能如交叉引用、参考文献、目录、索引等,需要先通过编译生成辅助文件, +然后再次编译时读入辅助文件得到正确的结果,所以复杂的 \LaTeX{} 源代码可能要编译多次: +\begin{description} + \item[\texttt{.log}] 排版引擎生成的日志文件,供排查错误使用。 + \item[\texttt{.aux}] \LaTeX{} 生成的主辅助文件,记录交叉引用、目录、参考文献的引用等。 + \item[\texttt{.toc}] \LaTeX{} 生成的目录记录文件。 + \item[\texttt{.lof}] \LaTeX{} 生成的图片目录记录文件。 + \item[\texttt{.lot}] \LaTeX{} 生成的表格目录记录文件。 + \item[\texttt{.bbl}] \hologo{BibTeX} 生成的参考文献记录文件。 + \item[\texttt{.blg}] \hologo{BibTeX} 生成的日志文件。 + \item[\texttt{.idx}] \LaTeX{} 生成的供 makeindex 处理的索引记录文件。 + \item[\texttt{.ind}] makeindex 处理 \texttt{.idx} 生成的用于排版的格式化索引文件。 + \item[\texttt{.ilg}] makeindex 生成的日志文件。 + \item[\texttt{.out}] \pkg{hyperref} 宏包生成的 PDF 书签记录文件。 +\end{description} + +\section{文件的组织方式}\label{sec:latex-multi-files} + +当编写长篇文档时,例如当编写书籍、毕业论文时,单个源文件会使修改、校对变得十分困难。 +将源文件分割成若干个文件,例如将每章内容单独写在一个文件中,会大大简化修改和校对的工作。 +可参考源代码 \ref{code:book-struct} 的写法。 + +\cmdindex{include} +\LaTeX{} 提供了命令 \cmd{include} 用来在源代码里插入文件: +\begin{command} +\cmd{include}\marg{filename} +\end{command} +\Arg{filename} 为文件名,如果和要编译的主文件不在一个目录中,则要加上相对或绝对路径,例如: +\begin{verbatim} +\include{chapters/a.tex} % 相对路径 +\include{/home/Bob/file.tex} % *nix (包含 Linux、macOS(OS X))绝对路径 +\include{D:/file.tex} % Windows 绝对路径,用正斜线 +\end{verbatim} + +\Arg{filename} 可以不带扩展名,此时默认扩展名为 \texttt{.tex}。 + +\cmdindex{input} +值得注意的是 \cmd{include} 在读入 \Arg{filename} 之前会另起一页。有的时候我们并不需要这样,而是用 +\cmd{input} 命令,它纯粹是把文件里的内容插入: +\begin{command} +\cmd{input}\marg{filename} +\end{command} + +特别要注意的是,使用 \cmd{include} 和 \cmd{input} 命令载入的文件名\textbf{一定不要加空格},否则通常会出错。 + +\cmdindex{includeonly} +另外 \LaTeX{} 提供了一个 \cmd{includeonly} 命令来组织文件,用于\textbf{导言区},指定只载入某些文件: +\begin{command} +\cmd{includeonly}\marg*{\Arg{filename1},\Arg{filename2},\ldots} +\end{command} + +导言区使用了 \cmd{includeonly} 后,正文中不在其列表范围的 \cmd{include} 命令不会起效。 + +\pkgindex{syntonly} +最后介绍一个实用的工具宏包 \pkg{syntonly}。加载这个宏包后,在导言区使用 \cmd{syntaxonly} 命令, +可令 \LaTeX{} 编译后不生成 DVI 或者 PDF 文档,只排查错误,编译速度会快不少: +\begin{verbatim} +\usepackage{syntonly} +\syntaxonly +\end{verbatim} + +如果想生成文档,则用 \texttt\% 注释掉 \cmd{syntaxonly} 命令即可。 + +\section{\LaTeX{} 和 \TeX{} 相关的术语和概念}\label{sec:concepts} + +\pinyinindex{paibanyinqing}{排版引擎} +\index{pdfTeX@\hologo{pdfTeX}} +\index{XeTeX@\hologo{XeTeX}} +在本章的最后有必要澄清几个概念: +\begin{description} + \item[引擎] 全称为排版引擎,是编译源代码并生成文档的程序,如 \hologo{pdfTeX}、\hologo{XeTeX} 等。有时也称为编译器。 + \item[格式] 是定义了一组命令的代码集。\LaTeX{} 就是最广泛应用的一个格式,高德纳本人还编写了一个简单的 \hologo{plainTeX} 格式, + 没有定义诸如 \cmd{document\-class} 和 \cmd{section} 等等命令。 + \item[编译命令] 是实际调用的、结合了引擎和格式的命令。如 \texttt{xelatex} 命令是结合 \hologo{XeTeX} + 引擎和 \LaTeX{} 格式的一个编译命令。 +\end{description} +常见的引擎、格式和编译命令的关系总结于表 \ref{tbl:engine-format-command}。 + +\begin{table}[htp] + \centering + \caption{\TeX{} 引擎、格式及其对应的编译命令。} + \label{tbl:engine-format-command} + \begin{tabular}{cccc} + \hline + & \textbf{文档格式} & \textbf{\hologo{plainTeX} 格式} & \textbf{\LaTeX{} 格式} \\ + \hline + \TeX{} 引擎 & DVI & \texttt{tex} & N/A \\ + \hologo{pdfTeX} 引擎 & DVI & \texttt{etex} & \texttt{latex} \\ + & PDF & \texttt{pdftex} & \texttt{pdflatex} \\ + \hologo{XeTeX} 引擎 & PDF & \texttt{xetex} & \texttt{xelatex} \\ + \hologo{LuaTeX} 引擎 & PDF & \texttt{luatex} & \texttt{lualatex} \\ + \hline + \end{tabular} +\end{table} + +\texttt{latex} 编译命令和 \LaTeX{} 格式往往容易混淆,在讨论关于 \LaTeX{} 的时候需要明确。 +为避免混淆,本手册中的 \LaTeX{} 一律指的是\textbf{格式},\textbf{编译命令}则用等宽字体 \texttt{latex} 表示。 + +在此介绍一下几个编译命令的基本特点: +\begin{description} + \item[\texttt{latex}] + 虽然名为 \texttt{latex} 命令,底层调用的引擎其实是 \hologo{pdfTeX}。 + 该命令生成 \texttt{dvi}(Device Independent)格式的文档, + 用 \texttt{dvipdfmx} 命令可以将其转为 \texttt{pdf}。 + \item[\texttt{pdflatex}] + 底层调用的引擎也是 \hologo{pdfTeX},可以直接生成 \texttt{pdf} 格式的文档。 + \item[\texttt{xelatex}] + 底层调用的引擎是 \hologo{XeTeX},支持 UTF-8 编码和对 TrueType / OpenType 字体的调用。 + 当前较为方便的中文排版解决方案基于 \texttt{xelatex},详见 \ref{sec:chinese} 节。 + \item[\texttt{lualatex}] + 底层调用的引擎是 \hologo{LuaTeX},这个引擎在 \hologo{pdfTeX} 引擎基础上发展而来, + 除了支持 UTF-8 编码和对 TrueType / OpenType 字体的调用外,还支持通过 Lua 语言扩展 \TeX{} 的功能。 + \texttt{lualatex} 编译命令下的中文排版支持需要借助 \pkg{luatexja} 宏包。 +\end{description} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.02.text.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.02.text.tex new file mode 100644 index 00000000000..f0233642b65 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.02.text.tex @@ -0,0 +1,357 @@ +\chapter{用 \LaTeX{} 排版文字}\label{chap:text} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +文字是排版的基础。本章主要介绍如何在 \LaTeX{} 中输入各种文字符号,包括标点符号、连字符、重音等,以及控制文字断行和断页的方式。 + +本章简要介绍了在 \LaTeX{} 中排版中文的方法。随着 \LaTeX{} 和底层 \TeX{} 引擎的发展,旧方式(CCT、\pkg{CJK} 等)日渐退出舞台, +\texttt{xelatex} 和 \texttt{lualatex} 编译命令配合 \cls{ctex} 宏包 / 文档类的方式成为当前的主流中文排版支持方式。 +\end{intro} + +\section{语言文字和编码}\label{sec:encoding} + +\pinyinindex{bianma}{编码} +\LaTeX{} 源代码为文本文件,而文本文件的一个至关重要的性质是它的编码。在此用尽量短的篇幅介绍一下。 + +\subsection{ASCII 编码}\label{subsec:ascii} + +\index{bianma@编码!ASCII} +计算机的基本存储单位是字节(byte),每个字节为八位(8-bit),范围用十六进制写作 \texttt{0x00}--\texttt{0xFF}。 +ASCII (美国通用信息交换码)使用 \texttt{0x00}--\texttt{0x7F} 对文字编码,也就是 7-bit,覆盖了基本的拉丁字母、数字和符号,以及一些不可打印的控制字符(如换行符、制表符等)。 + +由于 \TeX{} 最初设计用于排版以英文为主的西文文档,ASCII 编码完全够用,因而早期版本的 \TeX{} 只支持 7-bit 和 ASCII 编码。 +排版扩展拉丁字符必须使用后文所述的各种符号和重音命令,如 M\"obius 必须通过输入 \verb|M\"obius| 得到。 + +\subsection{扩展编码}\label{subsec:ext-encoding} + +在 ASCII 之后,各种语言文字都发展了自己的编码,比如西欧语言的 Latin-1、日本的 Shift-JIS、中国大陆的 GB 2312--80 和 GBK 等。 +它们中的绝大多数都向下兼容 ASCII,因此无论是在哪种编码下,\TeX{} 以及 \LaTeX{} 的命令和符号都能用。 + +\index{bianma@编码!Latin-1} +\pkgindex{inputenc} +\TeX{} 从 3.0 版开始支持 8-bit,能够处理编码在 \texttt{0x80}--\texttt{0xFF} 范围内的字符。 +西欧(拉丁字母)、俄语系(西里尔字母)等语言文字的编码方案大都利用了 \texttt{0x80}--\texttt{0xFF} 这个范围, +处理起来较为方便。使用 \texttt{latex} 或 \texttt{pdflatex} 编译命令时,对源代码的编码处理由 \pkg{inputenc} 宏包支持。 +比如将源代码保存为 Latin-1 编码,并在导言区调用 \pkg{inputenc} 宏包并指定 \texttt{latin1} 选项后,M\"obius 这样的词语就可以直接通过(用适当输入法)输入 \texttt{M\"obius} 得到了。 + +\index{bianma@编码!GBK} +用于汉字的 GBK 等编码是多字节编码,ASCII 字符为一个字节,汉字等非 ASCII 字符为两个字节,使用 +\texttt{latex} 或 \texttt{pdflatex} 编译命令时需要借助一些宏包进行较为复杂的判断和处理。早期排版中文须使用 \pkg{CJK} 宏包,它是一个用于处理中、日、韩等东亚语言文字编码和字体配置的宏包。但 \pkg{CJK} 宏包的使用非常不方便,目前已不再推荐直接使用。 + +\subsection{UTF-8 编码}\label{subsec:utf8} + +\index{bianma@编码!UTF-8} +Unicode 是一个多国字符的集合,覆盖了几乎全球范围内的语言文字。UTF-8 是 Unicode 的一套编码方案, +一个字符由一个到四个字节编码,其中单字节字符的编码与 ASCII 编码兼容。 + +现行版本的 \LaTeX{} 使用 UTF-8 作为默认编码% +\footnote{在 2018 年 4 月之前,需要调用 \pkg{inputenc} 宏包并指定 \texttt{utf8} 选项才能使用 UTF-8 编码。}。 +将使用拉丁字母的文档保存为 UTF-8 编码后,可以用 \texttt{pdflatex} 直接编译,比如: + +\begin{verbatim} +\documentclass{article} +\begin{document} +Français Português Español Føroyskt +\end{document} +\end{verbatim} + +但是非拉丁字母仍然无法直接在 \LaTeX{} 中使用,如西里尔字母(俄文)、希腊字母、阿拉伯字母以及东亚文字等。 + +\pkgindex{fontspec,babel,polyglossia} +较为现代的 \TeX{} 引擎,如 \hologo{XeTeX} 和 \hologo{LuaTeX},它们均原生支持 UTF-8 编码。 +使用 \texttt{xelatex} 和 \texttt{lualatex} 排版时,将源代码保存为 UTF-8 编码,并借助 +\pkg{fontspec} 宏包(见 \ref{subsec:fontspec} 小节)调用适当的字体,原则上就可以在源代码中输入任意语言的文字。 +注意此时\textbf{不再适用 \pkg{inputenc} 宏包}。但一些复杂语言(如印地语、阿拉伯语等)的排版需要考虑到断词规则、文字方向、标点禁则等诸多细节,因此需要更多的宏包支持,如 \pkg{babel}、 \pkg{polyglossia} 等,此处不再涉及。 + +\section{排版中文}\label{sec:chinese} + +\pkgindex{xeCJK,luatexja} +用 \LaTeX{} 排版中文需要解决两方面问题,一方面是对中文字体的支持,另一方面是对中文排版中的一些细节的处理,包括在汉字之间控制断行、标点符号的禁则(如句号、逗号不允许出现在行首)、中英文之间插入间距等。\pkg{CJK} 宏包对中文字体的支持比较麻烦,已经不再推荐直接使用。 +\hologo{XeTeX} 和 \hologo{LuaTeX} 除了直接支持 UTF-8 编码外,还支持直接调用 TrueType / OpenType 格式的字体。\pkg{xeCJK} 及 \pkg{luatexja} 宏包则在此基础上封装了对汉字排版细节的处理功能。 + +\pkgindex{ctex} +\clsindex{ctexart,ctexbook,ctexrep} +\pkg{ctex} 宏包和文档类\footnote{\hologo{CTeX} 还经常用来指一个过时的 \TeX{} 发行版,注意与这里的 \pkg{ctex} 宏包和文档类区分。}% +进一步封装了 \pkg{CJK}、\pkg{xeCJK}、\pkg{luatexja} 等宏包,使得用户在排版中文时不用再考虑排版引擎等细节。\pkg{ctex} 宏包本身用于配合各种文档类排版中文,而 \pkg{ctex} 文档类对 \LaTeX{} 的标准文档类进行了封装,对一些排版根据中文排版习惯做了调整,包括 \cls{ctexart} / \cls{ctexrep} / \cls{ctexbook}。 +\pkg{ctex} 宏包和文档类能够识别操作系统和 \TeX{} 发行版中安装的中文字体,因此基本无需额外配置即可排版中文文档。下面举一个使用 \pkg{ctex} 文档类排版中文的最简例子: + +\begin{verbatim} +\documentclass{ctexart} +\begin{document} +在\LaTeX{}中排版中文。 +汉字和English单词混排,通常不需要在中英文之间添加额外的空格。 +当然,为了代码的可读性,加上汉字和 English 之间的空格也无妨。 +汉字换行时不会引入多余的空格。 +\end{document} +\end{verbatim} + +\index{xelatex@\texttt{xelatex} 命令} +\index{lualatex@\texttt{lualatex} 命令} +注意源代码须保存为 UTF-8 编码,并使用 \texttt{xelatex} 或 \texttt{lualatex} 命令编译。 +虽然 \pkg{ctex} 宏包和文档类保留了对 GBK 编码以及 \texttt{latex} 和 \texttt{pdflatex} 编译命令的兼容, +笔者建议在使用 \pkg{ctex} 宏包和文档类时总是将源代码保存为 UTF-8 编码,用 \texttt{xelatex} 或 \texttt{lualatex} 命令编译。 + +\section{\LaTeX{} 中的字符}\label{sec:text-symbols} + +\subsection{空格和分段}\label{subsec:spaces} + +\LaTeX{} 源代码中,空格键和 Tab 键输入的空白字符视为“空格”。 +连续的若干个空白字符视为一个空格。一行开头的空格忽略不计。 + +\cmdindex{par} +行末的换行符视为一个空格;但连续两个换行符,也就是空行,会将文字分段。多个空行被视为一个空行。 +也可以在行末使用 \cmd{par} 命令分段。 +\begin{example} +Several spaces equal one. + Front spaces are ignored. + +An empty line starts a new +paragraph.\par +A \verb|\par| command does +the same. +\end{example} + +\subsection{注释}\label{subsec:comments} + +\index{^^e@\texttt\% (\textit{注释})} +\LaTeX{} 用 \texttt\% 字符作为注释。在这个字符之后直到行末,所有的字符都被忽略, +行末的换行符也不引入空格。 +\begin{example} +This is an % short comment +% --- +% Long and organized +% comments +% --- +example: Comments do not bre% +ak a word. +\end{example} + +\subsection{特殊字符}\label{subsec:special-chars} + +以下字符在 \LaTeX{} 里有特殊用途,如 \texttt\% 表示注释, \texttt\$、\texttt\textasciicircum 、\texttt\_ 等用于排版数学公式, +\texttt\& 用于排版表格,等等。直接输入这些字符得不到对应的符号,还往往会出错: +\begin{verbatim} +# $ % & { } _ ^ ~ \ +\end{verbatim} + +如果想要输入以上符号,需要使用以下带反斜线的形式输入,类似编程语言里的“转义”符号: +\begin{example} +\# \$ \% \& \{ \} \_ +\^{} \~{} \textbackslash +\end{example} + +这些“转义”符号事实上是一些 \LaTeX{} 命令。其中 \cmd{\textasciicircum} 和 \cmd{\textasciitilde} +两个命令需要一个参数,加一对花括号的写法相当于提供了空的参数,否则它们可能会将后面的字符作为参数,形成重音效果(详见 \ref{subsec:accents} 节)。 +\crcmd{} 被直接定义成了手动换行的命令,输入反斜线就需要用 \cmd{text\-back\-slash}。 + +\subsection{连字}\label{subsec:ligatures} + +西文排版中经常会出现连字(ligatures),常见的有 ff / fi / fl / ffi / ffl{}。 +\begin{example} +It's difficult to find \ldots\\ +It's dif{}f{}icult to f{}ind \ldots +\end{example} + +\subsection{标点符号}\label{subsec:punct} + +中文的标点符号(绝大多数为非 ASCII 字符)使用中文输入法输入即可,一般不需要过多留意。 +而输入西文标点符号时,有不少地方需要留意。 + +\subsubsection{引号} + +\index{biaodianfuhao@标点符号!`@\protect\verb+`+ (\textit{前引号} `)} +\index{biaodianfuhao@标点符号!``@\protect\verb+'+ (\textit{后引号} ')} +\index{biaodianfuhao@标点符号!'@\protect\verb+``+ (\textit{前双引号} ``)} +\index{biaodianfuhao@标点符号!''@\protect\verb+''+ (\textit{后双引号} '')} +\LaTeX{} 中单引号 ` ' 分别用 \verb|`| 和 \verb|'| 输入;双引号 `` 和 '' 分别用 \verb|``| 和 \verb|''| 输入 +(\verb|"| 可以输入后双引号,但没有直接输入前双引号的字符,习惯上用 \verb|''| 输入以和 \verb|``| 更好地对应)。 +\begin{example} +``Please press the `x' key.'' +\end{example} + +\subsubsection{连字号和破折号} + +\index{biaodianfuhao@标点符号!-@\protect\verb+-+ (\textit{连字号} -)} +\index{biaodianfuhao@标点符号!--@\protect\verb+--+ (\textit{短破折号} --)} +\index{biaodianfuhao@标点符号!---@\protect\verb+---+ (\textit{长破折号} ---)} +\LaTeX{} 中有三种长度的“横线”可用:连字号(hyphen)、短破折号(en-dash)和长破折号(em-dash)。 +它们分别有不同的用途:连字号 - 用来组成复合词;短破折号 -- 用来连接数字表示范围;长破折号 --- 用来连接单词,语义上类似中文的破折号。 +\begin{example} +daughter-in-law, X-rated\\ +pages 13--67\\ +yes---or no? +\end{example} + +\subsubsection{省略号} + +\index{biaodianfuhao@标点符号!ldots@\cmd{ldots} (\textit{省略号} \ldots)} +\index{biaodianfuhao@标点符号!dots@\cmd{dots} (\textit{省略号} \dots)|see{\cmd{ldots}}} +\LaTeX{} 提供了 \cmd{ldots} 命令表示省略号,相对于直接输入三个点的方式更为合理。 +\cmd{dots} 与 \cmd{ldots} 命令等效。 +\begin{example} +one, two, three, \ldots one hundred. +\end{example} + +\subsubsection{波浪号} + +我们在 \ref{subsec:special-chars} 小节中了解了 \cmd{\textasciitilde} 命令,它可以用来输入波浪号, +但位置靠顶端(\cmd{\textasciitilde} 命令主要用作重音,参考下一小节)。西文中较少将波浪号作为标点符号使用,在中文环境中一般直接使用全角波浪号(~)。 + +\subsection{拉丁文扩展与重音}\label{subsec:accents} + +\pinyinindex{zhongyin}{重音} +\LaTeX{} 支持用命令输入西欧语言中使用的各种拉丁文扩展字符,主要为带重音的字母: +\begin{example} +H\^otel, na\"\i ve, \'el\`eve,\\ +sm\o rrebr\o d, !`Se\ norita!,\\ +Sch\"onbrunner Schlo\ss{} +Stra\ss e +\end{example} + +更多可用的符号和重音见表 \ref{tbl:accents}。注意与 \ref{subsec:math-accents} 小节的数学重音区分开来。 + +\def\TSYM #1{#1 & \texttt{\string#1}} +\def\TACC #1#2{#1{#2} & \texttt{\string#1#2}} % accents using a control character +\def\TTACC #1#2{#1{#2} & \texttt{\string#1 #2}} % accents using a control word +\def\WTACC #1#2{#1{#2} & \texttt{\string#1\{#2\}}} % multi-letter accents +\begin{table}[htp] +\centering +\caption{\LaTeX{} 文本中的重音和特殊字符} \label{tbl:accents} +\begin{tabular}{*4{cl}} + \hline + \TACC{\`}{o} & \TACC{\'}{o} & \TACC{\^}{o} & \TACC{\~}{o} \\ + \TACC{\=}{o} & \TACC{\.}{o} & \TACC{\"}{o} & \TTACC{\r}{o}\\ + \TTACC{\u}{o} & \TTACC{\v}{o} & \TTACC{\H}{o} & \TTACC{\c}{o} \\ + \TTACC{\d}{o} & \TTACC{\b}{o} & \WTACC{\t}{oo} \\[6pt] + \TSYM{\oe} & \TSYM{\OE} & \TSYM{\ae} & \TSYM{\AE} \\ + \TSYM{\aa} & \TSYM{\AA} & \TSYM{\ss} \\[6pt] + \TSYM{\o} & \TSYM{\O} & \TSYM{\l} & \TSYM{\L} \\ + \TSYM{\i} & \TSYM{\j} & !` & \verb|!`| & ?` & \verb|?`| \\ + \hline +\end{tabular} +\begin{quote}\footnotesize% +前四行实际上都是带一个参数的命令。\cmd{\textasciicircum}\texttt{o} 也可以写作 +\cmd{\textasciicircum}\marg*{o},以此类推。 +\end{quote} +\end{table} + +\subsection{其它符号}\label{subsec:text-misc} + +\symindex{dag,ddag,P,S,copyright,pounds} +\symindex{textasteriskcentered,textperiodcentered,textbullet,textregistered,texttrademark} +\LaTeX{} 预定义了其它一些文本模式的符号,部分符号可参考表 \ref{tbl:general-syms}。 +\begin{example} +\P{} \S{} \dag{} \ddag{} +\copyright{} \pounds{} + +\textasteriskcentered +\textperiodcentered +\textbullet + +\textregistered{} \texttrademark +\end{example} + +更多的符号多由特定的宏包支持。参考文献 \cite{symbols} 搜集了所有在 \TeX{} 发行版中可用的符号,使用时要留意每个符号所依赖的宏包。 + +\subsection{\LaTeX{} 标志}\label{subsec:latex-mark} + +\cmdindex{TeX,LaTeX,LaTeXe} +我们见到的所有错落有致的 \LaTeX{} 标志都是由以下命令输入的: +\begin{center} +\begin{tabular}{*{2}{l}} + \hline + \TeX & \cmd{TeX} \\ + \LaTeX & \cmd{LaTeX} \\ + \LaTeXe & \cmd{LaTeXe} \\ + \hline +\end{tabular} +\end{center} + +\section{断行和断页}\label{sec:break} + +\LaTeX{} 将文字段落在合适的位置进行断行,尽可能做到每行的疏密程度匀称,单词间距不会过宽或过窄。 +文字段落和公式、图表等内容从上到下顺序排布,并在合适的位置断页,分割成匀称的页面。 +在绝大多数时候,我们无需自己操心断行和断页。但偶尔会遇到需要手工调整的地方。 + +\subsection{单词间距}\label{subsec:interword} + +在西文排版实践中,断行的位置优先选取在两个单词之间,也就是在源代码中输入的“空格”% +\footnote{中文排版实现汉字间断行,则需要宏包(如 \pkg{xeCJK} 等)或特殊的排版引擎(如 up\LaTeX{})的支持。}。 +“空格”本身通常生成一个间距,它会根据行宽和上下文自动调整,文字密一些的地方,单词间距就略窄,反之略宽。 + +\index{~@\texttt\textasciitilde\ (\textit{不断行空格})} +文字在单词间的“空格”处断行时,“空格”生成的间距随之舍去。 +我们可以使用字符 \texttt\textasciitilde 输入一个不会断行的空格(高德纳称之为 tie,“带子”), +通常用在英文人名、图表名称等上下文环境: +\begin{example} +Fig.~2a \\ +Donald~E. Knuth +\end{example} + +\subsection{手动断行和断页}\label{subsec:manual-break} + +\index{\@\crcmd{} (\textit{换行})} \cmdindex{newline} +如果我们确实需要手动断行,可使用如下命令: +\begin{command} +\crcmd \oarg{length} \qquad +\crcmd*\oarg{length} \\ +\cmd{newline} +\end{command} + +它们有两点区别:一是 \crcmd{} 可以带可选参数 \Arg{length},用于在断行处向下增加垂直间距(见 \ref{subsec:vspace} 小节), +而 \cmd{newline} 不带可选参数;二是 \crcmd{} 也在表格、公式等地方用于换行,而 \cmd{newline} 只用于文本段落中。 +带星号的 \crcmd{} 表示禁止在断行处分页。 + +\begin{example} +另外需要注意的是,使用 \verb|\\| +断行命令 \\ 不会令内容另起一段, +而是在段落中直接开始新的一行。 +\end{example} + +\cmdindex{newpage,clearpage} +断页的命令有两个: +\begin{command} +\cmd{newpage} \\ +\cmd{clearpage} +\end{command} + +通常情况下两个命令都起到另起一页的作用,区别在于:第一,在双栏排版模式中 \cmd{newpage} 起到另起一栏的作用,\cmd{clearpage} 则能够另起一页;第二,在涉及到浮动体的排版上行为不同。 +后文的 \ref{sec:float} 节以及 \ref{subsec:columns} 小节会更详细地介绍相关内容。 + +\cmdindex{linebreak,nolinebreak} +有时候我们不满足于 \LaTeX{} 默认的断行和断页位置,需要进行微调,可以用以下命令告诉 \LaTeX{} 哪些地方适合断行或断页,哪些地方不适合: +\begin{command} +\cmd{linebreak}\oarg{n} \quad \cmd{nolinebreak}\oarg{n} \\ +\cmd{pagebreak}\oarg{n} \quad \cmd{nopagebreak}\oarg{n} +\end{command} + +以上命令都带一个可选参数,用数字 \Arg{n} 代表适合/不适合的程度,取值范围为 0--4,不带可选参数时,缺省为 4。 +比如 \cmd{linebreak} 或者 \cmd{linebreak}\texttt{[4]} 意味着此处需要强行断行;\cmd{nopagebreak} 或 \cmd{nopagebreak}\texttt{[4]} +意味着禁止在此处断页。 + +以上命令适合给出优先考虑断行断页/禁止断行断页的位置,但不适合直接拿来断行或断页,使用 \cmd{newline} 或 \cmd{newpage} 等命令是更好的选择。 +因为 \cmd{newline} 和 \cmd{newpage} 会在断行/断页位置填充适当的间距,但 \cmd{linebreak} 和 \cmd{pagebreak} 不能,使用 +这些命令强行断行/断页可能会制造出糟糕的排版效果,并导致 \LaTeX{} 报 \texttt{Underfull \cmd{hbox}} 等警告。 + +\begin{example} +使用 \verb|\newline| 断行的效果 +\newline +与使用 \verb|\linebreak| 断行的效果 +\linebreak +进行对比。 +\end{example} + +\subsection{断词}\label{subsec:hyphen} + +如果 \LaTeX{} 遇到了很长的英文单词,仅在单词之间的“空格”处断行无法生成疏密程度匀称的段落时,就会考虑从单词中间断开。 +对于绝大多数单词,\LaTeX{} 能够找到合适的断词位置,在断开的行尾加上连字符 \char\hyphenchar\font 。 + +\index{-@\cmd{-} (\textit{断词})} +如果一些单词没能自动断词,我们可以在单词内手动使用 \cmd{-} 命令指定断词的位置: +\begin{example} +I think this is: su\-per\-cal\-% +i\-frag\-i\-lis\-tic\-ex\-pi\-% +al\-i\-do\-cious. +\end{example} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.03.elements.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.03.elements.tex new file mode 100644 index 00000000000..4d289d43e3d --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.03.elements.tex @@ -0,0 +1,1145 @@ +\chapter{文档元素}\label{chap:elements} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +在知道了如何输入文字后,我们将在本章了解一个结构化的文档所依赖的各种元素——章节、目录、列表、图表、交叉引用、脚注等等。 +\end{intro} + +\section{章节和目录}\label{sec:secs} + +\subsection{章节标题}\label{subsec:secs} + +\cmdindex{part,chapter,section,subsection,subsubsection,paragraph,subparagraph} +\clsindex{article,book,report} + +一篇结构化的、条理清晰文档一定是层次分明的,通过不同的命令分割为章、节、小节。三个标准文档类 \cls{article}、\cls{report} 和 \cls{book}% +\footnote{千万注意是\textbf{标准文档类},其它文档类,如果不是从标准文档类衍生而来, +很可能没有定义或只定义了一部分命令,如 \cls{beamer} 或 \cls{moderncv} 等。}% +提供了划分章节的命令: +\begin{command} +\cmd{chapter}\marg{title} \quad +\cmd{section}\marg{title} \quad +\cmd{subsection}\marg{title} \\ +\cmd{subsubsection}\marg{title} \quad +\cmd{paragraph}\marg{title} \quad +\cmd{subparagraph}\marg{title} +\end{command} +其中 \cmd{chapter} \textbf{只在 \cls{book} 和 \cls{report} 文档类有定义}。这些命令生成章节标题,并能够自动编号。 +除此之外 \LaTeX{} 还提供了 \cmd{part} 命令,用来将整个文档分割为大的分块,但不影响 \cmd{chapter} 或 \cmd{section} 等的编号。 + +上述命令除了生成带编号的标题之外,还向目录中添加条目,并影响页眉页脚的内容(详见 \ref{sec:pagestyle} 节)。每个命令有两种变体: +\begin{itemize} + \item 带可选参数的变体:\cmd{section}\oarg{short title}\marg{title}\par + 标题使用 \Arg{title} 参数,在目录和页眉页脚中使用 \Arg{short title} 参数; + \item 带星号的变体:\cmd{section*}\marg{title}\par + 标题不带编号,也不生成目录项和页眉页脚。 +\end{itemize} + +较低层次如 \cmd{paragraph} 和 \cmd{subparagraph} 即使不用带星号的变体,生成的标题默认也不带编号,事实上,除 \cmd{part} 外: +\begin{itemize} + \item \cls{article} 文档类带编号的层级为 \cmd{section} / \cmd{subsection} / \cmd{sub\-sub\-section} 三级; + \item \cls{report}/\cls{book} 文档类带编号的层级为 \cmd{chapter} / \cmd{section} / \cmd{sub\-section} 三级。 +\end{itemize} +对此的详细解释和调整方法见 \ref{subsec:latex-counts} 小节。 + +\pkgindex{titlesec} +\LaTeX{} 及标准文档类并未提供为 \cmd{section} 等章节命令定制格式的功能,这一功能由 \pkg{titlesec} 宏包提供。详情请参考宏包的帮助文档。 + +\subsection{目录}\label{sec:toc} + +\cmdindex{tableofcontents} +\pkgindex{tocbibind,tocloft,titletoc} +在 \LaTeX{} 中生成目录非常容易,只需在合适的地方使用命令: +\begin{command} +\cmd{tableofcontents} +\end{command} + +这个命令会生成单独的一章(\cls{book} / \cls{report})或一节(\cls{article}),标题默认为 ``Contents''{},可通过 \ref{sec:latex-settings} 节给出的方法定制标题。 +\cmd{tableof\-contents} 生成的章节默认不写入目录(\cmd{section*} 或 \cmd{chapter*}),可使用 \pkg{tocbibind} 等宏包修改设置。 + +正确生成目录项,一般需要编译两次源代码。 + +\cmdindex{addcontentsline} +有时我们使用了 \cmd{chapter*} 或 \cmd{section*} 这样不生成目录项的章节标题命令, +而又想手动生成该章节的目录项,可以在标题命令后面使用: +\begin{command} +\cmd{addcontentsline}\marg*{toc}\marg{level}\marg{title} +\end{command} + +其中 \Arg{level} 为章节层次 \texttt{chapter} 或 \texttt{section} 等,\Arg{title} 为出现于目录项的章节标题。 + +\pkg{titletoc}、\pkg{tocloft} 等宏包提供了具体定制目录项格式的功能,详情请参考宏包的帮助文档。 + +\subsection{文档结构的划分}\label{sec:matters} + +\cmdindex{appendix} +所有标准文档类都提供了一个 \cmd{appendix} 命令将正文和附录分开% +\footnote{有的参考文档可能使用 \cmd{begin} \marg*{appendix} \ldots \cmd{end} \marg*{appendix} 这样的写法, +虽然有效,但并不规范,只要使用 \cmd{appendix} 命令就够了。}, +使用 \cmd{appendix} 后,最高一级章节改为使用拉丁字母编号,从 A 开始。 + +\clsindex{book} +\cmdindex{frontmatter,mainmatter,backmatter} +\cls{book} 文档类还提供了前言、正文、后记结构的划分命令: +\begin{description} + \item[\cmd{frontmatter}] 前言部分,页码为小写罗马字母格式;其后的 \cmd{chapter} 不编号。 + \item[\cmd{mainmatter}] 正文部分,页码为阿拉伯数字格式,从 1 开始计数;其后的章节编号正常。 + \item[\cmd{backmatter}] 后记部分,页码格式不变,继续正常计数;其后的 \cmd{chapter} 不编号。 +\end{description} + +\cmdindex{include} +以上三个命令还可和 \cmd{appendix} 命令结合,生成有前言、正文、附录、后记四部分的文档。 +源代码 \ref{code:book-struct} 结合 \ref{sec:latex-multi-files} 节的 \cmd{include} 命令 +和其它一些命令示意了一份完整的文档结构。 + +\begin{sourcecode}[htp] +\begin{Verbatim} +\documentclass{book} + +% 导言区,加载宏包和各项设置,包括参考文献、索引等 +\usepackage{makeidx} % 调用 makeidx 宏包,用来处理索引 +\makeindex % 开启索引的收集 +\bibliographystyle{plain} % 指定参考文献样式为 plain + +\begin{document} + +\frontmatter % 前言部分 +\maketitle % 标题页 +\include{preface} % 前言章节 preface.tex +\tableofcontents + +\mainmatter % 正文部分 +\include{chapter1} % 第一章 chapter1.tex +\include{chapter2} % 第二章 chapter2.tex +... +\appendix % 附录 +\include{appendixA} % 附录 A appendixA.tex +... + +\backmatter % 后记部分 +\include{prologue} % 后记 prologue.tex +\bibliography{books} % 利用 BibTeX 工具从数据库文件 books.bib 生成参考文献 +\printindex % 利用 makeindex 工具生成索引 + +\end{document} +\end{Verbatim} +\caption{\cls{book} 文档类的文档结构示例。}\label{code:book-struct} +\end{sourcecode} + +\section{标题页}\label{sec:titlepage} + +\cmdindex{title,author,date,today} +\cmdindex{thanks,and} +\LaTeX{} 支持生成简单的标题页。首先需要给定标题和作者等信息: +\begin{command} +\cmd{title}\marg{title} \quad +\cmd{author}\marg{author} \quad +\cmd{date}\marg{date} +\end{command} +其中前两个命令是必须的(不用 \cmd{title} 会报错;不用 \cmd{author} 会警告),\cmd{date} 命令可选。 +\LaTeX{} 还提供了一个 \cmd{today} 命令自动生成当前日期,\cmd{date} 默认使用 \cmd{today}。 +在 \cmd{title}、\cmd{author} 等命令内可以使用 \cmd{thanks} 命令生成标题页的脚注,用 \cmd{and} 隔开多个人名。 + +\cmdindex{maketitle} +\pinyinindex{biaotiye}{标题页} +在信息给定后,就可以使用 \cmd{maketitle} 命令生成一个简单的标题页了。 +源代码 \ref{code:titlepage} 给出了一个标题页的示例和大致效果。 +\cls{article} 文档类的标题默认不单独成页,而 \cls{report} 和 \cls{book} 默认单独成页。 +可在 \cmd{document\-class} 命令调用文档类时指定 \texttt{titlepage / notitlepage} 选项以修改默认的行为。 + +\begin{sourcecode}[htp] +\begin{Verbatim} +\title{Test title} +\author{ Mary\thanks{E-mail:*****@***.com} + \and Ted\thanks{Corresponding author} + \and Louis} +\date{\today} +\end{Verbatim} +\bigskip +\makeatletter +\begin{minipage}{\textwidth} + \centering + \renewcommand\thempfootnote{\@fnsymbol\c@mpfootnote}% + {\LARGE Test title \par}% + \vskip 1.5em% + {\large + \lineskip .5em% + \begin{tabular}[t]{c}% + Mary\footnote{E-mail:*****@***.com} + \end{tabular} + \hskip 1em \@plus.17fil% + \begin{tabular}[t]{c}% + Ted\footnote{Corresponding author} + \end{tabular} + \hskip 1em \@plus.17fil% + \begin{tabular}[t]{c}% + Louis + \end{tabular}\par}% + \vskip 1em% + {\large \csname CTEX@todayold\endcsname}% +\end{minipage} +\makeatother +\caption{\LaTeX{} 默认的标题页示例和效果。}\label{code:titlepage} +\end{sourcecode} + +\envindex{titlepage} +\LaTeX{} 标准类还提供了一个简单的 \env{titlepage} 环境,生成不带页眉页脚的一页。用户可以在这个环境中使用各种排版元素自由发挥, +生成自定义的标题页以替代 \cmd{maketitle} 命令。甚至可以利用 \env{titlepage} 环境重新定义 \cmd{maketitle}: +\begin{verbatim} +\renewcommand{\maketitle}{\begin{titlepage} +... % 用户自定义命令 +\end{titlepage}} +\end{verbatim} + +事实上,为标准文档类指定了 \texttt{titlepage} 选项以后,使用 \cmd{maketitle} 命令生成的标题页就是一个 \env{titlepage} 环境。 + +以上是 \LaTeX{} 标准文档类的标题页相关命令用法。在各种文档模板中经常有自定义的标题页, +有可能需要除了 \cmd{title} 和 \cmd{author} 以外的命令给定信息,用法也可能与标准文档类的不一致 +(甚至有些模板可能没有定义 \env{titlepage} 等环境)。使用文档模板前\textbf{一定要仔细阅读文档模板的帮助文档}。 + +\section{交叉引用}\label{sec:crossref} + +\cmdindex{label} +交叉引用是 \LaTeX{} 强大的自动排版功能的体现之一。在能够被交叉引用的地方,如章节、公式、图表、定理等位置使用 \cmd{label} 命令: +\begin{command} +\cmd{label}\marg{label-name} +\end{command} + +\cmdindex{ref,pageref} +之后可以在别处使用 \cmd{ref} 或 \cmd{pageref} 命令,分别生成交叉引用的编号和页码: +\begin{command} +\cmd{ref}\marg{label-name} \quad +\cmd{pageref}\marg{label-name} +\end{command} +\begin{example} +A reference to this subsection +\label{sec:this} looks like: +``see section~\ref{sec:this} on +page~\pageref{sec:this}.'' +\end{example} + +为了生成正确的交叉引用,一般也需要多次编译源代码。 + +\cmd{label} 命令可用于记录各种类型的交叉引用,使用位置分别为: +\begin{description} + \item[章节标题] 在章节标题命令 \cmd{section} 等之后紧接着使用。 + \item[行间公式] 单行公式在公式内任意位置使用;多行公式在每一行公式的任意位置使用。 + \item[有序列表] 在 \env{enumerate} 环境的每个 \cmd{item} 命令之后、下一个 \cmd{item} 命令之前任意位置使用。 + \item[图表标题] 在图表标题命令 \cmd{caption} 之后紧接着使用。 + \item[定理环境] 在定理环境内部任意位置使用。 +\end{description} + +在使用不记编号的命令形式(\cmd{section*}、\cmd{caption*}、带可选参数的 \cmd{item} 命令等)时不要使用 \cmd{label} 命令, +否则生成的引用编号不正确。 + +\section{脚注和边注}\label{sec:footnote-marginpar} + +\cmdindex{footnote} +使用 \cmd{footnote} 命令可以在页面底部生成一个脚注: +\begin{command} +\cmd{footnote}\marg{footnote} +\end{command} + +假如我们输入以下文字和命令: +\begin{verbatim} +“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnote{出自《千字文》。} +\end{verbatim} + +在正文中则为:% +“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnote{出自《千字文》。} + +\cmdindex{footnotemark,footnotetext} +有些情况下(比如在表格环境、各种盒子内)使用 \cmd{footnote} 并不能正确生成脚注。我们可以分两步进行, +先使用 \cmd{foot\-note\-mark} 为脚注计数,再在合适的位置用 \cmd{foot\-note\-text} 生成脚注。比如: + +\begin{verbatim} +\begin{tabular}{l} +\hline +“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnotemark \\ +\hline +\end{tabular} +\footnotetext{表格里的名句出自《千字文》。} +\end{verbatim} + +效果为: + +\leavevmode\begin{tabular}{l} +\hline +“天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。”\footnotemark \\ +\hline +\end{tabular} +\footnotetext{表格里的名句出自《千字文》。} + +\cmdindex{marginpar} +使用 \cmd{marginpar} 命令可在边栏位置生成边注: +\begin{command} +\cmd{marginpar}\oarg{left-margin}\marg{right-margin} +\end{command} +如果只给定了 \Arg{right-margin},那么边注在奇偶数页文字相同;如果同时给定了 \Arg{left-margin}, +则偶数页使用 \Arg{left-margin} 的文字。 + +例如以下代码: +\begin{verbatim} +\marginpar{\footnotesize 边注较窄,不要写过多文字,最好设置较小的字号。} +\end{verbatim} +其效果见边栏。\marginpar{\footnotesize 边注较窄,不要写过多文字。最好设置较小的字号。} + +\section{特殊环境}\label{sec:envs} + +\subsection{列表}\label{subsec:lists} + +\envindex{enumerate,itemize} +\cmdindex{item} +\LaTeX{} 提供了基本的有序和无序列表环境 \env{enumerate} 和 \env{itemize},两者的用法很类似,都用 \cmd{item} 标明每个列表项。 +\env{enumerate} 环境会自动对列表项编号。 +\begin{command} +\cmd{begin}\marg*{enumerate} \\ +\cmd{item} \ldots \\ +\cmd{end}\marg*{enumerate} +\end{command} + +其中 \cmd{item} 可带一个可选参数,将有序列表的计数或者无序列表的符号替换成自定义的符号。 +列表可以嵌套使用,最多嵌套四层。 +\begin{example} +\begin{enumerate} + \item An item. + \begin{enumerate} + \item A nested item.\label{itref} + \item[*] A starred item. + \end{enumerate} + \item Reference(\ref{itref}). +\end{enumerate} +\end{example} + +\begin{example} +\begin{itemize} + \item An item. + \begin{itemize} + \item A nested item. + \item[+] A `plus' item. + \item Another item. + \end{itemize} + \item Go back to upper level. +\end{itemize} +\end{example} + +\envindex{description} +关键字环境 \env{description} 的用法与以上两者类似,不同的是 \cmd{item} 后的可选参数用来写关键字,以粗体显示,一般是必填的: +\begin{command} +\cmd{begin}\marg*{description} \\ + \cmd{item}\oarg{item title} \ldots \\ +\cmd{end}\marg*{description} +\end{command} + +\begin{example} +\begin{description} + \item[Enumerate] Numbered list. + \item[Itemize] Non-numbered list. +\end{description} +\end{example} + +各级无序列表的符号由命令 \cmd{labelitemi} 到 \cmd{labelitemiv} 定义,可以简单地重新定义它们: +\begin{example} +\renewcommand{\labelitemi}{\ddag} +\renewcommand{\labelitemii}{\dag} +\begin{itemize} + \item First item + \begin{itemize} + \item Subitem + \item Subitem + \end{itemize} + \item Second item +\end{itemize} +\end{example} + +有序列表的符号由命令 \cmd{labelenumi} 到 \cmd{labelenumiv} 定义, +重新定义这些命令需要用到 \ref{sec:counters} 节的计数器相关命令: +\begin{example} +\renewcommand{\labelenumi}% + {\Alph{enumi}>} +\begin{enumerate} + \item First item + \item Second item +\end{enumerate} +\end{example} + +默认的列表间距比较宽,\LaTeX{} 本身也未提供方便的定制功能,可用 \pkg{enumitem} 宏包定制各种列表间距。 +\pkg{enumitem} 宏包还提供了对列表标签、引用等的定制。有兴趣的读者可参考其帮助文档。 + +\subsection{对齐环境}\label{subsec:flush} + +\envindex{center,flushleft,flushright} +\env{center}、\env{flush\-left} 和 \env{flush\-right} 环境分别用于生成居中、左对齐和右对齐的文本环境。 +\begin{command} +\cmd{begin}\marg*{center} \ldots\ \cmd{end}\marg*{center} \\ +\cmd{begin}\marg*{flushleft} \ldots\ \cmd{end}\marg*{flushleft} \\ +\cmd{begin}\marg*{flushright} \ldots\ \cmd{end}\marg*{flushright} +\end{command} + +\begin{example} +\begin{center} +Centered text using a +\verb|center| environment. +\end{center} +\begin{flushleft} +Left-aligned text using a +\verb|flushleft| environment. +\end{flushleft} +\begin{flushright} +Right-aligned text using a +\verb|flushright| environment. +\end{flushright} +\end{example} + +\cmdindex{centering,raggedleft,raggedright} +除此之外,还可以用以下命令直接改变文字的对齐方式: +\begin{command} +\cmd{centering} \quad +\cmd{raggedright} \quad +\cmd{raggedleft} +\end{command} + +\begin{example} +\centering +Centered text paragraph. + +\raggedright +Left-aligned text paragraph. + +\raggedleft +Right-aligned text paragraph. +\end{example} + +三个命令和对应的环境经常被误用,有直接用所谓 \cmd{flushleft} 命令或者 \env{raggedright} 环境的,都是不甚严格的用法(即使它们可能有效)。 +有一点可以将两者区分开来:\env{center} 等环境会在上下文产生一个额外间距,而 \cmd{centering} 等命令不产生,只是改变对齐方式。 +比如在浮动体环境 \env{table} 或 \env{figure} 内实现居中对齐,用 \cmd{centering} 命令即可,没必要再用 \env{center} 环境。 + +\subsection{引用环境}\label{subsec:quote} + +\envindex{quote,quotation} +\LaTeX{} 提供了两种引用的环境:\env{quote} 用于引用较短的文字,首行不缩进;\env{quotation} 用于引用若干段文字,首行缩进。 +引用环境较一般文字有额外的左右缩进。 +\begin{example} +Francis Bacon says: +\begin{quote} +Knowledge is power. +\end{quote} +\end{example} + +\begin{example} +《木兰诗》: +\begin{quotation} +万里赴戎机,关山度若飞。 +朔气传金柝,寒光照铁衣。 +将军百战死,壮士十年归。 + +归来见天子,天子坐明堂。 +策勋十二转,赏赐百千强。…… +\end{quotation} +\end{example} + +\envindex{verse} +\env{verse} 用于排版诗歌,与 \env{quotation} 恰好相反,\env{verse} 是首行悬挂缩进的。 +\begin{example} +Rabindranath Tagore's short poem: +\begin{verse} +Beauty is truth's smile +when she beholds her own face in +a perfect mirror. +\end{verse} +\end{example} + +\subsection{摘要环境}\label{subsec:abstract} + +\envindex{abstract} +摘要环境 \env{abstract} 默认只在标准文档类中的 \cls{article} 和 \cls{report} 文档类可用, +一般用于紧跟 \cmd{maketitle} 命令之后介绍文档的摘要。如果文档类指定了 \texttt{titlepage} 选项,则单独成页; +反之,单栏排版时相当于一个居中的小标题加一个 \env{quotation} 环境,双栏排版时相当于 \cmd{section*} 定义的一节。 + +\subsection{代码环境}\label{subsec:verbatim} + +\envindex{verbatim} +有时我们需要将一段代码原样转义输出,这就要用到代码环境 \env{verbatim},它以等宽字体排版代码,回车和空格也分别起到换行和空位的作用; +带星号的版本更进一步将空格显示成“\textvisiblespace”。 +\begin{example} +\begin{verbatim} +#include +int main() +{ + std::cout << "Hello, world!" + << std::endl; + return 0; +} +\end{verbatim} +\end{example} + +\begin{example} +\begin{verbatim*} +for (int i=0; i<4; ++i) + printf("Number %d\n",i); +\end{verbatim*} +\end{example} + +\cmdindex{verb} +要排版简短的代码或关键字,可使用 \cmd{verb} 命令: +\begin{command} +\cmd{verb}\Arg{delim}\Arg{code}\Arg{delim} +\end{command} + +\Arg{delim} 标明代码的分界位置,前后必须一致,除字母、空格或星号外,可任意选择使得不与代码本身冲突,习惯上使用 \texttt| 符号。 + +同 \env{verbatim} 环境,\cmd{verb} 后也可以带一个星号,以显示空格: +\begin{example} +\verb|\LaTeX| \\ +\verb+(a || b)+ \verb*+(a || b)+ +\end{example} + +\cmd{verb} 命令对符号的处理比较复杂,一般\textbf{不能用在其它命令的参数里},否则多半会出错。 + +\pkg{verbatim} 宏包优化了 \env{verbatim} 环境的内部命令,并提供了 \cmd{verbatiminput} 命令用来直接读入文件生成代码环境。 +\pkg{fancyvrb} 宏包提供了可定制格式的 \env{Verbatim} 环境;\pkg{listings} 宏包更进一步,可生成关键字高亮的代码环境, +支持各种程序设计语言的语法和关键字。详情请参考各自的帮助文档。 + +\section{表格}\label{sec:tabular} + +\pinyinindex{biaoge}{表格|(} +\LaTeX{} 里排版表格不如 Word 等所见即所得的工具简便和自由,不过对于不太复杂的表格来讲,完全能够胜任。 + +\envindex{tabular} +\cmdindex{hline} +\index{&@\texttt\& (\textit{单元格/对齐})} +\index{\@\crcmd{} (\textit{换行})} +排版表格最基本的 \env{tabular} 环境用法为: +\begin{command} +\cmd{begin}\marg*{tabular}\oarg{align}\marg{column-spec}\\ + \Arg{item1} \texttt\& \Arg{item2} \texttt\& \ldots\ \crcmd \\ + \cmd{hline} \\ + \Arg{item1} \texttt\& \Arg{item2} \texttt\& \ldots\ \crcmd \\ +\cmd{end}\marg*{tabular} +\end{command} +其中 \Arg{column-spec} 是列格式标记,在接下来的内容将仔细介绍;\texttt\& 用来分隔单元格; +\crcmd{} 用来换行;\cmd{hline} 用来在行与行之间绘制横线。 + +直接使用 \env{tabular} 环境的话,会\textbf{和周围的文字混排}。此时可用一个可选参数 \Arg{align} 控制垂直对齐: +\verb|t| 和 \verb|b| 分别表示按按表格顶部、底部对齐,其他参数或省略不写(默认)表示居中对齐。 +\begin{example} +\begin{tabular}{|c|} + center-\\ aligned \\ +\end{tabular}, +\begin{tabular}[t]{|c|} + top-\\ aligned \\ +\end{tabular}, +\begin{tabular}[b]{|c|} + bottom-\\ aligned\\ +\end{tabular} tabulars. +\end{example} + +但是通常情况下 \env{tabular} 环境很少与文字直接混排,而是会放在 \env{table} 浮动体环境中,并用 \cmd{caption} 命令加标题。 + +\subsection{列格式}\label{subsec:tabular-cols} + +\env{tabular} 环境使用 \Arg{column-spec} 参数指定表格的列数以及每列的格式。基本的列格式见表 \ref{tbl:table-column-spec}。 +\begin{table}[htp] +\centering +\caption{\LaTeX{} 表格列格式}\label{tbl:table-column-spec} +\begin{tabular}{*{2}{l}} + \hline + \textbf{列格式} & \textbf{说明} \\ + \hline + \ttfamily l/c/r & 单元格内容左对齐/居中/右对齐,不折行 \\ + \ttfamily p\marg{width} & 单元格宽度固定为 \Arg{width},可自动折行 \\ + \ttfamily | & 绘制竖线 \\ + \ttfamily @\marg{string} & 自定义内容 \Arg{string} \\ + \hline +\end{tabular} +\end{table} + +\begin{example} +\begin{tabular}{lcr|p{6em}} + \hline + left & center & right + & par box with fixed width\\ + L & C & R & P \\ + \hline +\end{tabular} +\end{example} + +表格中每行的单元格数目不能多于列格式里 \texttt{l/c/r/p} 的总数(可以少于这个总数),否则出错。 + +\texttt{@} 格式可在单元格前后插入任意的文本,但同时它也消除了单元格前后额外添加的间距。 +\texttt{@} 格式可以适当使用以充当“竖线”。特别地,\texttt{@}\marg*{} 可直接用来消除单元格前后的间距: +\begin{example} +\begin{tabular}{@{} r@{:}lr @{}} + \hline + 1 & 1 & one \\ + 11 & 3 & eleven \\ + \hline +\end{tabular} +\end{example} + +另外 \LaTeX{} 还提供了简便的将格式参数重复的写法 \texttt*\marg{n}\marg{column-spec},比如以下两种写法是等效的: +\begin{verbatim} +\begin{tabular}{|c|c|c|c|c|p{4em}|p{4em}|} +\begin{tabular}{|*{5}{c|}*{2}{p{4em}|}} +\end{verbatim} + +\pkgindex{array} +有时需要为整列修饰格式,比如整列改变为粗体,如果每个单元格都加上 \cmd{bfseries} 命令会比较麻烦。 +\pkg{array} 宏包提供了辅助格式 \texttt> 和 \texttt<,用于给列格式前后加上修饰命令: +\begin{example} +\begin{tabular}{>{\itshape}r<{*}l} + \hline + italic & normal \\ + column & column \\ + \hline +\end{tabular} +\end{example} + +辅助格式甚至支持插入 \cmd{centering} 等命令改变 \texttt{p} 列格式的对齐方式, +一般还要加额外的命令 \cmd{array\-back\-slash} 以免出错% +\footnote{\cmd{centering} 等对齐命令会破坏表格环境里 \crcmd{} 换行命令的定义, +\cmd{array\-back\-slash} 用来恢复之。如果不加 \cmd{array\-back\-slash} 命令, +也可以用 \cmd{tabular\-newline} 命令代替原来的 \crcmd{} 实现表格换行。}: +\begin{example} +\begin{tabular} +{>{\centering\arraybackslash}p{9em}} + \hline + Some center-aligned long text. \\ + \hline +\end{tabular} +\end{example} + +\pkg{array} 宏包还提供了类似 \texttt{p} 格式的 \texttt{m} 格式和 \texttt{b} 格式, +三者分别在垂直方向上靠顶端对齐、居中以及底端对齐。 +\begin{example} +\newcommand\txt + {a b c d e f g h i} +\begin{tabular}{cp{2em}m{2em}b{2em}} + \hline + pos & \txt & \txt & \txt \\ + \hline +\end{tabular} +\end{example} + +\subsection{列宽}\label{subsec:colwidth} + +在控制列宽方面,\LaTeX{} 表格有着明显的不足:\texttt{l/c/r} 格式的列宽是由文字内容的自然宽度决定的, +而 \texttt{p} 格式给定了列宽却不好控制对齐(可用 \pkg{array} 宏包的辅助格式), +更何况列与列之间通常还有间距,所以直接生成给定总宽度的表格并不容易。 + +\envindex{tabular*} +\LaTeX{} 本身提供了 \env{tabular*} 环境用来排版定宽表格,但是不太方便使用, +比如要用到 \texttt{@} 格式插入额外命令,令单元格之间的间距为 \cmd{fill},但即使这样仍然有瑕疵: +\begin{example} +\begin{tabular*}{14em}% +{@{\extracolsep{\fill}}|c|c|c|c|} + \hline + A & B & C & D \\ \hline + a & b & c & d \\ \hline +\end{tabular*} +\end{example} + +\pkgindex{tabularx} +\envindex[tabularx]{tabularx} +\pkg{tabularx} 宏包为我们提供了方便的解决方案。它引入了一个 \texttt{X} 列格式,类似 \texttt{p} 列格式, +不过会根据表格宽度自动计算列宽,多个 \texttt{X} 列格式平均分配列宽。 +\texttt{X} 列格式也可以用 \pkg{array} 里的辅助格式修饰对齐方式: +\begin{example} +\begin{tabularx}{14em}% +{|*{4}{>{\centering\arraybackslash}X|}} + \hline + A & B & C & D \\ \hline + a & b & c & d \\ \hline +\end{tabularx} +\end{example} + +\subsection{横线}\label{subsec:hline} + +\cmdindex{hline,cline} +我们已经在之前的例子见过许多次绘制表格线的 \cmd{hline} 命令。另外 \cmd{cline}\marg*{\Arg{i}-\Arg{j}} 用来绘制跨越部分单元格的横线: +\begin{example} +\begin{tabular}{|c|c|c|} + \hline + 4 & 9 & 2 \\ \cline{2-3} + 3 & 5 & 7 \\ \cline{1-1} + 8 & 1 & 6 \\ \hline +\end{tabular} +\end{example} + +\pkgindex{booktabs} +\cmdindex[booktabs]{toprule,midrule,bottomrule,cmidrule} +在科技论文排版中广泛应用的表格形式是三线表,形式干净简明。 +三线表由 \pkg{booktabs} 宏包支持,它提供了 \cmd{toprule}、\cmd{midrule} 和 \cmd{bottomrule} 命令用以排版三线表的三条线, +以及和 \cmd{cline} 对应的 \cmd{cmidrule}。除此之外,最好不要用其它横线以及竖线: +\begin{example} +\begin{tabular}{cccc} + \toprule + & \multicolumn{3}{c}{Numbers} \\ + \cmidrule{2-4} + & 1 & 2 & 3 \\ + \midrule + Alphabet & A & B & C \\ + Roman & I & II& III \\ + \bottomrule +\end{tabular} +\end{example} + +\subsection{合并单元格}\label{subsec:tabular-multicol} + +\LaTeX{} 是一行一行排版表格的,横向合并单元格较为容易,由 \cmd{multi\-column} 命令实现: +\begin{command} +\cmd{multicolumn}\marg{n}\marg{column-spec}\marg{item} +\end{command} +其中 \Arg{n} 为要合并的列数,\Arg{column-spec} 为合并单元格后的列格式,只允许出现一个 \texttt{l/c/r} 或 \texttt{p} 格式。 +如果合并前的单元格前后带表格线 \texttt|,合并后的列格式也要带 \texttt| 以使得表格的竖线一致。 +\begin{example} +\begin{tabular}{|c|c|c|} + \hline + 1 & 2 & Center \\ \hline + \multicolumn{2}{|c|}{3} & + \multicolumn{1}{r|}{Right} \\ \hline + 4 & \multicolumn{2}{c|}{C} \\ \hline +\end{tabular} +\end{example} + +上面的例子还体现了,形如 \cmd{multicolumn}\marg*{1}\marg{column-spec}\marg{item} 的命令\textbf{可以用来修改某一个单元格的列格式。} + +\pkgindex{multirow} +\cmdindex[multirow]{multirow} +纵向合并单元格需要用到 \pkg{multirow} 宏包提供的 \cmd{multirow} 命令: +\begin{command} +\cmd{multirow}\marg{n}\marg{width}\marg{item} +\end{command} +\Arg{width} 为合并后单元格的宽度,可以填 \texttt{*} 以使用自然宽度。 + +我们看一个结合 \cmd{cline}、\cmd{multi\-column} 和 \cmd{multi\-row} 命令的例子: +\begin{example} +\begin{tabular}{ccc} + \hline + \multirow{2}{*}{Item} & + \multicolumn{2}{c}{Value} \\ + \cline{2-3} + & First & Second \\ \hline + A & 1 & 2 \\ \hline +\end{tabular} +\end{example} + +\subsection{嵌套表格}\label{subsec:tabular-embed} + +相对于合并单元格,拆分单元格对于 \LaTeX{} 来说并非易事。在单元格中嵌套一个小表格可以起到“拆分单元格”的效果。 +在以下的例子中,注意要用 \cmd{multi\-column} 命令配合 \texttt{@\{\}} 格式把单元格的额外边距去掉,使得嵌套的表格线能和外层的表格线正确相连: + +\begin{example} +\begin{tabular}{|c|c|c|} + \hline + a & b & c \\ \hline + a & \multicolumn{1}{@{}c@{}|} + {\begin{tabular}{c|c} + e & f \\ \hline + e & f \\ + \end{tabular}} + & c \\ \hline + a & b & c \\ \hline +\end{tabular} +\end{example} + +\pkgindex{makecell} +如果不需要为“拆分的单元格”画线,并且只在垂直方向“拆分”的话,\pkg{makecell} 宏包提供的 \cmd{make\-cell} 命令是一个简单的解决方案: + +\begin{example} +\begin{tabular}{|c|c|} + \hline + a & \makecell{d1 \\ d2} \\ + \hline + b & c \\ + \hline +\end{tabular} +\end{example} + +\subsection{行距控制}\label{subsec:tabular-colht} + +\cmdindex{arraystretch} +\LaTeX{} 生成的表格看起来通常比较紧凑。修改参数 \cmd{array\-stretch} 可以得到行距更加宽松的表格 +(相关命令参考 \ref{subsec:newcmd} 小节): +\begin{example} +\renewcommand\arraystretch{1.8} +\begin{tabular}{|c|} + \hline + Really loose \\ \hline + tabular rows.\\ \hline +\end{tabular} +\end{example} + +\index{\@\crcmd{} (\textit{换行})} +另一种增加间距的办法是给换行命令 \crcmd{} 添加可选参数,在这一行下面加额外的间距,适合用于在行间不加横线的表格: +\begin{example} +\begin{tabular}{c} + \hline + Head lines \\[6pt] + tabular lines \\ + tabular lines \\ \hline +\end{tabular} +\end{example} + +但是这种换行方式的存在导致了一个缺陷——\textbf{表格的首个单元格不能直接使用中括号 \texttt{[]}}, +否则 \crcmd{} 往往会将下一行的中括号当作自己的可选参数,因而出错。如果要使用中括号,应当放在花括号 \marg*{} 里面。 +或者也可以选择将换行命令写成 \crcmd\texttt{[0pt]}。 + +\pinyinindex{biaoge}{表格|)} + +\section{图片}\label{sec:figures} + +\pkgindex{graphicx} + +\LaTeX{} 本身不支持插图功能,需要由 \pkg{graphicx} 宏包辅助支持。 + +使用 \texttt{latex + dvipdfmx} 编译命令时,调用 \pkg{graphicx} 宏包时要指定 \texttt{dvipdfmx} 选项% +\footnote{早期常使用 \texttt{latex + dvips} 组合命令,后者将 \texttt{.dvi} 文件转为 \texttt{.ps} 文件(PostScript), +可进一步通过 \texttt{ps2pdf} 工具生成 PDF。\texttt{dvips} 和 \texttt{dvipdfmx} 在图形、颜色、超链接等功能的实现上有差别,而 \LaTeX{} 无法识别 +用户是用 \texttt{dvips} 还是 \texttt{dvipdfmx},所以要指定选项(缺省为 \texttt{dvips})。 +\ref{sec:hyperlinks} 节中的 \pkg{hyperref} 宏包同理。};而使用 \texttt{pdflatex} 或 \texttt{xelatex} 命令编译时不需要。 + +读者可能听说过“\LaTeX{} 只能插入 \texttt{.eps} 格式的图片,需要把 \texttt{.jpg} 转成 \texttt{.eps} 格式”的观点。 +\LaTeX{} 发展到今天,这个观点早已过时。事实上不同的编译命令支持的图片格式范围各异,见表 \ref{tbl:figure-format}。 +这个表格也能解答诸如“为什么 \texttt{.eps} 格式图片在 \texttt{pdflatex} 编译命令下出错”之类的问题。本表格也再一次说明,使用 +\texttt{xelatex} 命令是笔者最推荐的方式。 + +\begin{table}[htp] +\centering +\caption{各种编译方式支持的主流图片格式}\label{tbl:figure-format} +\begin{tabular}{*{3}{l}} + \hline + \textbf{格式} & \textbf{矢量图} & \textbf{位图} \\ + \hline + \texttt{latex + dvipdfmx} & \texttt{.eps} & n/a \\ + \quad $\llcorner$(调用 \pkg{bmpsize} 宏包 ) & \texttt{.eps .pdf} & \texttt{.jpg .png .bmp} \\[.3\baselineskip] + \texttt{pdflatex} & \texttt{.pdf} & \texttt{.jpg .png} \\ + \quad $\llcorner$(调用 \pkg{epstopdf} 宏包) & \texttt{.pdf .eps} & \texttt{.jpg .png} \\[.3\baselineskip] + \texttt{xelatex} & \texttt{.pdf .eps} & \texttt{.jpg .png .bmp} \\ + \hline +\end{tabular} +\begin{quote}\footnotesize +注:在较新的 \TeX{} 发行版中,\texttt{latex + dvipdfmx} 和 \texttt{pdf\-latex} 命令可不依赖宏包,支持原来需要宏包扩展的图片格式 +(但 \texttt{pdf\-latex} 命令仍不支持 \texttt{.bmp} 格式的位图)。 +\end{quote} +\end{table} + +\cmdindex[graphicx]{includegraphics} +在调用了 \pkg{graphicx} 宏包以后,就可以使用 \cmd{include\-graphics} 命令加载图片了: +\begin{command} +\cmd{includegraphics}\oarg{options}\marg{filename} +\end{command} + +\cmdindex[graphicx]{graphicspath} +其中 \Arg{filename} 为图片文件名,与 \cmd{include} 命令的用法类似,文件名可能需要用相对路径或绝对路径表示(见 \ref{sec:latex-multi-files} 节)。 +图片文件的扩展名一般可不写。另外一定要注意,\textbf{文件名里既不要有空格(类似 \cmd{include}),也不要有多余的英文点号},否则宏包在解析文件名的过程中会出错。 + +另外 \pkg{graphicx} 宏包还提供了 \cmd{graphics\-path} 命令,用于声明一个或多个图片文件存放的目录, +使用这些目录里的图片时可不用写路径: +\begin{verbatim} +% 假设主要的图片放在 figures 子目录下,标志放在 logo 子目录下 +\graphicspath{{figures/}{logo/}} +\end{verbatim} + +\cmd{includegraphics} 命令的可选参数 \Arg{options} 支持 \Arg{key}=\Arg{value} 形式赋值,常用的参数如下: +\begin{table}[htp] +\centering +\caption{\cmd{includegraphics} 命令的可选参数}\label{tbl:graphics-options} +\begin{tabular}{lp{18em}} + \hline + \textbf{参数} & \textbf{含义} \\ + \hline + \texttt{width=}\Arg{width} & 将图片缩放到宽度为 \Arg{width} \\ + \texttt{height=}\Arg{height} & 将图片缩放到高度为 \Arg{height} \\ + \texttt{scale=}\Arg{scale} & 将图片相对于原尺寸缩放 \Arg{scale} 倍 \\ + \texttt{angle=}\Arg{angle} & 令图片逆时针旋转 \Arg{angle} 度 \\ + \hline +\end{tabular} +\end{table} + +\section{盒子}\label{sec:box} + +盒子是 \LaTeX{} 排版的基础单元,虽然解释上去有些抽象:每一行是一个盒子, +里面的文字从左到右依次排列;每一页也是一个盒子,各行文字从上到下依次排布……颇有一些活字印刷术的味道。 + +不管如何,\LaTeX{} 提供了一些命令让我们生成一些有特定用途的盒子。 + +\subsection{水平盒子}\label{subsec:mbox} + +\cmdindex{mbox,makebox} +生成水平盒子的命令如下: +\begin{command} +\cmd{mbox}\marg*{\ldots} \\ +\cmd{makebox}\oarg{width}\oarg{align}\marg*{\ldots} +\end{command} + +\cmd{mbox} 生成一个基本的水平盒子,内容只有一行,不允许分段(除非嵌套其它盒子,比如后文的垂直盒子)。 +外表看上去,\cmd{mbox} 的内容与正常的文本无二,不过断行时文字不会从盒子里断开。 + +\cmd{makebox} 更进一步,可以加上可选参数用于控制盒子的宽度 \Arg{width},以及内容的对齐方式 \Arg{align}, +可选居中 \texttt{c}(默认值)、左对齐 \texttt{l}、右对齐 \texttt{r} 和分散对齐 \texttt{s}% +\footnote{分散对齐方式强行拉开单词的间距,往往会报 \texttt{Underfull} \cmd{hbox} 的消息。}。 +\begin{example} +|\mbox{Test some words.}|\\ +|\makebox[10em]{Test some words.}|\\ +|\makebox[10em][l]{Test some words.}|\\ +|\makebox[10em][r]{Test some words.}|\\ +|\makebox[10em][s]{Test some words.}| +\end{example} + +\subsection{带框的水平盒子}\label{subsec:fbox} + +\cmdindex{fbox,framebox} +\cmd{fbox} 和 \cmd{framebox} 让我们可以为水平盒子添加边框。使用的语法与 \cmd{mbox} 和 \cmd{makebox} 一模一样: +\begin{command} +\cmd{fbox}\marg*{\ldots} \\ +\cmd{framebox}\oarg{width}\oarg{align}\marg*{\ldots} +\end{command} +\begin{example} +\fbox{Test some words.}\\ +\framebox[10em][r]{Test some words.} +\end{example} + +\cmdindex{setlength} +\cmdindex{fboxrule,fboxsep} +可以通过 \cmd{setlength} 命令(见 \ref{subsec:lengths} 小节)调节边框的宽度 \cmd{fbox\-rule} 和内边距 \cmd{fbox\-sep}: +\begin{example} +\framebox[10em][r]{Test box}\\[1ex] +\setlength{\fboxrule}{1.6pt} +\setlength{\fboxsep}{1em} +\framebox[10em][r]{Test box} +\end{example} + +\subsection{垂直盒子}\label{subsec:parbox} + +\cmdindex{parbox} +\envindex{minipage} +如果需要排版一个文字可以换行的盒子,\LaTeX{} 提供了两种方式: +\begin{command} +\cmd{parbox}\oarg{align}\oarg{height}\oarg{inner-align}\marg{width}\marg*{\ldots} \\[0.5ex] +\cmd{begin}\marg*{minipage}\oarg{align}\oarg{height}\oarg{inner-align}\marg{width} \\ +\ldots \\ +\cmd{end}\marg*{minipage} +\end{command} + +其中 \Arg{align} 为盒子和周围文字的对齐情况(类似 \env{tabular} 环境); +\Arg{height} 和 \Arg{inner-align} 设置盒子的高度和内容的对齐方式,类似水平盒子 \cmd{makebox} 的设置, +不过 \Arg{inner-align} 接受的参数是顶部 \texttt{t}、底部 \texttt{b}、居中 \texttt{c} 和分散对齐 \texttt{s}。 + +\begin{example} +三字经:\parbox[t]{3em}% +{人之初 性本善 性相近 习相远} +\quad +千字文: +\begin{minipage}[b][8ex][t]{4em} +天地玄黄 宇宙洪荒 +\end{minipage} +\end{example} + +\cmdindex{footnote,footnotetext,footnotemark} +如果在 \env{minipage} 里使用 \cmd{footnote} 命令,生成的脚注会出现在盒子底部,编号是独立的,并且使用小写字母编号。 +这也是 \env{minipage} 环境之被称为“迷你页”(Mini-page)的原因。 +而在 \cmd{parbox} 里无法正常使用 \cmd{footnote} 命令,只能在盒子里使用 \cmd{foot\-note\-mark},在盒子外使用 \cmd{foot\-note\-text}。 +\begin{example} +\fbox{\begin{minipage}{15em}% + 这是一个垂直盒子的测试。 + \footnote{脚注来自 minipage。} +\end{minipage}} +\end{example} + +\subsection{标尺盒子}\label{subsec:rules} + +\cmdindex{rule} +\cmd{rule} 命令用来画一个实心的矩形盒子,也可适当调整以用来画线(标尺): +\begin{command} +\cmd{rule}\oarg{raise}\marg{width}\marg{height} +\end{command} +\begin{example} +Black \rule{12pt}{4pt} box. + +Upper \rule[4pt]{6pt}{8pt} and +lower \rule[-4pt]{6pt}{8pt} box. + +A \rule[-.4pt]{3em}{.4pt} line. +\end{example} + +\section{浮动体}\label{sec:float} + +内容丰富的文章或者书籍往往包含许多图片和表格等内容。这些内容的尺寸往往太大,导致分页困难。 +\LaTeX{} 为此引入了浮动体的机制,令大块的内容可以脱离上下文,放置在合适的位置。 + +\envindex{figure,table} +\LaTeX{} 预定义了两类浮动体环境 \env{figure} 和 \env{table}。习惯上 \env{figure} 里放图片,\env{table} 里放表格, +但并没有严格限制,可以在任何一个浮动体里放置文字、公式、表格、图片等等任意内容。 + +以 \env{table} 环境的用法举例,\env{figure} 同理: +\begin{command} +\cmd{begin}\marg*{table}\oarg{placement} \\ +\ldots \\ +\cmd{end}\marg*{table} +\end{command} + +\Arg{placement} 参数提供了一些符号用来表示浮动体允许排版的位置,如 \texttt{hbp} 允许浮动体排版在当前位置、底部或者单独成页。 +\env{table} 和 \env{figure} 浮动体的默认设置为 \texttt{tbp}。 +\begin{table}[htp] +\centering +\caption{浮动体的位置参数}\label{tbl:float-placement} +\begin{tabular}{*{2}{l}} + \hline + \textbf{参数} & \textbf{含义} \\ + \hline + \texttt{h} & 当前位置(代码所处的上下文) \\ + \texttt{t} & 顶部 \\ + \texttt{b} & 底部 \\ + \texttt{p} & 单独成页 \\ + \texttt{!} & 在决定位置时忽视限制 \\ + \hline +\end{tabular} +\begin{quote}\footnotesize +注 1:排版位置的选取与参数里符号的顺序无关,\LaTeX{} 总是以 \texttt{h-t-b-p} 的优先级顺序决定浮动体位置。 +也就是说 \texttt{[!htp]} 和 \texttt{[ph!t]} 没有区别。\par +注 2:限制包括浮动体个数(除单独成页外,默认每页不超过 3 个浮动体,其中顶部不超过 2 个,底部不超过 1 个) +以及浮动体空间占页面的百分比(默认顶部不超过 70\%,底部不超过 30\%)。 +\end{quote} +\end{table} + +\envindex{table*,figure*} +双栏排版环境下,\LaTeX{} 提供了 \env{table*} 和 \env{figure*} 环境用来排版跨栏的浮动体。 +它们的用法与 \env{table} 和 \env{figure} 一样,不同之处为双栏的 \Arg{placement} 参数只能用 \texttt{tp} 两个位置。 + +\cmdindex{clearpage} +浮动体的位置选取受到先后顺序的限制。如果某个浮动体由于参数限制、空间限制等原因在当前页无法放置,就要推迟到之后处理, +并使得之后的同类浮动体一并推迟。\cmd{clearpage} 命令会在另起一页之前,先将所有推迟处理的浮动体排版成页, +此时 \texttt{htbp} 等位置限制被完全忽略。 + +\pkgindex{float} + +\pkg{float} 宏包为浮动体提供了 \texttt{H} 位置参数,不与 \texttt{htbp} 及 \texttt{!} 混用。使用 \texttt{H} 位置参数时, +会取消浮动机制,将浮动体视为一般的盒子插入当前位置。这在一些特殊情况下很有用(如使用 \pkg{multicol} 宏包排版分栏内容的时候), +但尺寸过大的浮动体可能使得分页比较困难。 + +\subsection{浮动体的标题}\label{subsec:caption} + +\cmdindex{caption,label} +图表等浮动体提供了 \cmd{caption} 命令加标题,并且自动给浮动体编号: +\begin{command} +\cmd{caption}\marg*{\ldots} +\end{command} +\cmd{caption} 的用法非常类似于 \cmd{section} 等命令,可以用带星号的命令 \cmd{caption*} 生成不带编号的标题, +也可以使用带可选参数的形式 \cmd{caption}\oarg*{\ldots}\marg*{\ldots},使得在目录里使用短标题。 +\cmd{caption} 命令之后还可以紧跟 \cmd{label} 命令标记交叉引用。 + +\pkgindex{caption} +\cmd{caption} 生成的标题形如 ``Figure 1: \ldots''{}(\env{figure} 环境)或 ``Table 1: \ldots''{}(\env{table} 环境)。 +可通过修改 \cmd{figurename} 和 \cmd{tablename} 的内容来修改标题的前缀(详见第 \ref{sec:latex-settings} 节)。 +标题样式的定制功能由 \pkg{caption} 宏包提供,详见该宏包的帮助文档,在此不作赘述。 + +\cmdindex{listoftables,listoffigures} +\env{table} 和 \env{figure} 两种浮动体分别有各自的生成目录的命令: +\begin{command} +\cmd{listoftables} \\ +\cmd{listoffigures} +\end{command} + +它们类似 \cmd{tableofcontents} 生成单独的章节。 + +\subsection{并排和子图表}\label{subsec:subfig} + +我们时常有在一个浮动体里面放置多张图的用法。最简单的用法就是直接并排放置, +也可以通过分段或者换行命令 \crcmd{} 排版多行多列的图片。以下为示意代码,效果大致如图 \ref{fig:parallel-fig} 所示。 +\begin{verbatim} +\begin{figure}[htbp] + \centering + \includegraphics[width=...]{...} + \qquad + \includegraphics[width=...]{...} \\[..pt] + \includegraphics[width=...]{...} + \caption{...} +\end{figure} +\end{verbatim} + +\begin{figure}[htp] + \centering + \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 10ex\hfil}} + \qquad + \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} + \par\bigskip + \fcolorbox[gray]{0}{0.96}{\parbox{20em}{\vrule width 0pt height 12ex\hfil}} + \caption{并排放置图片的示意。}\label{fig:parallel-fig} +\end{figure} + +由于标题是横跨一行的,用 \cmd{caption} 命令为每个图片单独生成标题就需要借助前文提到的 \cmd{parbox} +或者 \env{minipage} 环境,将标题限制在盒子内。效果见图 \ref{fig:parallel-cap1} 和图 \ref{fig:parallel-cap2}。 +\begin{verbatim} +\begin{figure}[htbp] + \centering + \begin{minipage}{...} + \centering + \includegraphics[width=...]{...} + \caption{...} + \end{minipage} + \qquad + \begin{minipage}{...} + \centering + \includegraphics[width=...]{...} + \caption{...} + \end{minipage} +\end{figure} +\end{verbatim} + +\begin{figure}[htp] + \centering + \begin{minipage}{12em} + \centering + \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} + \caption{并排图1。}\label{fig:parallel-cap1} + \end{minipage} + \qquad + \begin{minipage}{12em} + \centering + \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} + \caption{并排图2。}\label{fig:parallel-cap2} + \end{minipage} +\end{figure} + +\pkgindex{subfig} +\cmdindex[subfig]{subfloat} +当我们需要更进一步,给每个图片定义小标题时,就要用到 \pkg{subfig} 宏包的功能了。 +这里仅举一例,效果见图 \ref{fig:subfig}。更详细的用法请参考 \pkg{subfig} 宏包的帮助文档。 +\begin{verbatim} +\begin{figure}[htbp] + \centering + \subfloat[...]{\label{sub-fig-1}% 为子图加交叉引用 + \begin{minipage}{...} + \centering + \includegraphics[width=...]{...} + \end{minipage} + } + \qquad + \subfloat[...]{% + \begin{minipage}{...} + \centering + \includegraphics[width=...]{...} + \end{minipage} + } + \caption{...} +\end{figure} +\end{verbatim} + +\begin{figure}[htp] + \centering + \subfloat[并排子图1]{% + \begin{minipage}{12em} + \centering + \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} + \end{minipage}} + \qquad + \subfloat[并排子图2]{% + \begin{minipage}{12em} + \centering + \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} + \end{minipage}} + \caption{使用 \pkg{subfig} 宏包的 \cmd{subfloat} 命令排版子图。}\label{fig:subfig} +\end{figure} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.04.math.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.04.math.tex new file mode 100644 index 00000000000..75212c440a5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.04.math.tex @@ -0,0 +1,901 @@ +\chapter{排版数学公式}\label{chap:math} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +准备好了!本章将见识到 \LaTeX{} 闻名的强项——排版数学公式。当然你得注意了,本章的内容只是一点皮毛, +虽然对大多数人来说已经够用了,但是如果不能解决你的问题的话也不要大惊小怪,求助于搜索引擎或者有经验的人不失为一个好办法。 +\end{intro} +\DeclareRobustCommand*\amscmd[1]{\textcolor{blue}{\cmd{#1}}} +\DeclareRobustCommand*\amsenv[1]{\textcolor{blue}{\env{#1}}} + +\section{\hologo{AmS} 宏集}\label{sec:ams-bundle} + +\pkgindex{amsmath,amsfonts,amssymb,amsthm} +在介绍数学公式排版之前,简单介绍一下 \hologo{AmS} 宏集。\hologo{AmS} 宏集合是美国数学学会(American Mathematical Society)提供的对 +\LaTeX{} 原生的数学公式排版的扩展,其核心是 \pkg{amsmath} 宏包,对多行公式的排版提供了有力的支持。 +此外,\pkg{amsfonts} 宏包以及基于它的 \pkg{amssymb} 宏包提供了丰富的数学符号;\pkg{amsthm} 宏包扩展了 \LaTeX{} 定理证明格式。 + +本章介绍的许多命令和环境依赖于 \pkg{amsmath} 宏包,这些命令和环境将以\textcolor{blue}{蓝色}示意。以下示例都假定了导言区中写有 +\begin{verbatim} +\usepackage{amsmath} +\end{verbatim} + +\section{公式排版基础}\label{sec:math-basics} + +\subsection{行内和行间公式}\label{subsec:math-inline-display} + +数学公式有两种排版方式:其一是与文字混排,称为\textbf{行内公式};其二是单独列为一行排版,称为\textbf{行间公式}。 + +\pinyinindex{hangneigongshi}{行内公式} +\index{^^d@\texttt\$ (\textit{数学模式})} +行内公式由一对 \texttt\$ 符号包裹: +\begin{example} +The Pythagorean theorem is +$a^2 + b^2 = c^2$. +\end{example} + +\envindex{equation} +\cmdindex{label,ref,nonumber} +\cmdindex[amsmath]{eqref,tag,notag} +单独成行的\textbf{行间公式}在 \LaTeX{} 里由 \env{equation} 环境包裹。 +\env{equation} 环境为公式自动生成一个编号,这个编号可以用 \cmd{label} 和 \cmd{ref} 生成交叉引用, +\pkg{amsmath} 的 \amscmd{eqref} 命令甚至为引用自动加上圆括号;还可以用 \amscmd{tag} 命令手动修改公式的编号, +或者用 \amscmd{notag} 命令取消为公式编号(与之基本等效的命令是 \cmd{nonumber})。 + +\begin{example} +The Pythagorean theorem is: +\begin{equation} +a^2 + b^2 = c^2 \label{pythagorean} +\end{equation} +Equation \eqref{pythagorean} is +called `Gougu theorem' in Chinese. +\end{example} + +\begin{example} +It's wrong to say +\begin{equation} +1 + 1 = 3 \tag{dumb} +\end{equation} +or +\begin{equation} +1 + 1 = 4 \notag +\end{equation} +\end{example} + +\cmdindex{[,]} +\envindex{displaymath} +\envindex[amsmath]{equation*} +如果需要直接使用不带编号的行间公式,则将公式用命令 \cmd{[} 和 \cmd{]} 包裹% +\footnote{\TeX{} 原生排版行间公式的方法是用一对 \texttt{\$\$} 符号包裹,不过无法通过指定 \texttt{fleqn} 选项控制左对齐, +与上下文之间的间距也不好调整,故不太推荐使用。}, +与之等效的是 \env{displaymath} 环境。有的人更喜欢 \amsenv{equation*} 环境,体现了带星号和不带星号的环境之间的区别。 + +\begin{example} +\begin{equation*} +a^2 + b^2 = c^2 +\end{equation*} +For short: +\[ a^2 + b^2 = c^2 \] +Or if you like the long one: +\begin{displaymath} +a^2 + b^2 = c^2 +\end{displaymath} +\end{example} + +我们通过一个例子展示行内公式和行间公式的对比。为了与文字相适应,行内公式在排版大的公式元素(分式、巨算符等)时显得很“局促”: + +\begin{example} +In text: +$\lim_{n \to \infty} +\sum_{k=1}^n \frac{1}{k^2} += \frac{\pi^2}{6}$. + +In display: +\[ +\lim_{n \to \infty} +\sum_{k=1}^n \frac{1}{k^2} += \frac{\pi^2}{6} +\] +\end{example} + +行间公式的对齐、编号位置等性质由文档类选项控制,文档类的 \texttt{fleqn} 选项令行间公式左对齐; +\texttt{leqno} 选项令编号放在公式左边。 + +\subsection{数学模式}\label{subsec:math-mode} + +\pinyinindex{shuxuemoshi}{数学模式} +\cmdindex[amsmath]{text} +当用户使用 \texttt\$ 开启行内公式输入,或是使用 \cmd{[} 命令、\env{equation} 环境时,\LaTeX{} 就进入了\textbf{数学模式}。 +数学模式相比于文本模式有以下特点: +\begin{enumerate} + \item 数学模式中输入的空格被忽略。数学符号的间距默认由符号的性质(关系符号、运算符等)决定。 + 需要人为引入间距时,使用 \cmd{quad} 和 \cmd{qquad} 等命令。详见 \ref{sec:math-space} 节。 + \item \textbf{不允许有空行(分段)}。行间公式中也无法用 \crcmd{} 命令手动换行。排版多行公式需要用到 + \ref{sec:multi-eqns} 节介绍的各种环境。 + \item 所有的字母被当作数学公式中的变量处理,字母间距与文本模式不一致,也无法生成单词之间的空格。 + 如果想在数学公式中输入正体的文本,简单情况下可用 \ref{subsec:math-alpha} 小节中提供的 \cmd{mathrm} 命令。 + 或者用 \pkg{amsmath} 提供的 \amscmd{text} 命令% + \footnote{\amscmd{text} 命令仅适合在公式中穿插少量文字。如果你的情况正好相反,需要在许多文字中穿插使用公式, + 则应该像正常的行内公式那样用,而不是滥用 \amscmd{text} 命令。}。 +\end{enumerate} +\begin{example} +$x^{2} \geq 0 \qquad +\text{for \textbf{all} } +x\in\mathbb{R}$ +\end{example} + +\section{数学符号}\label{sec:math-symbols} + +\def\msym#1{$\csname #1\endcsname$ (\cmd{#1})} + +\pkgindex{amssymb} +本节我们将接触到形形色色的数学符号,它们是 \LaTeX{} 卓越的数学公式排版能力的基础。\LaTeX{} 默认提供了常用的数学符号, +\pkg{amssymb} 宏包提供了一些次常用的符号。大多数常用的数学符号都能在本章末尾的 \ref{sec:math-tables} 节列出的各个表格里查到。 +更多符号可查阅参考文献\cite{symbols}。 + +\subsection{一般符号}\label{subsec:math-general} + +\pinyinindex{xilazimu}{希腊字母 (数学符号)} +\msymindex{infty} +希腊字母符号的名称就是其英文名称,如 \msym{alpha}、\msym{beta} 等等。 +大写的希腊字母为首字母大写的命令,如 \msym{Gamma}、\msym{Delta} 等等。 +无穷大符号为 \msym{infty}。更多符号命令可参考表 \ref{tbl:math-greek} 和 \ref{tbl:math-misc} 等。 + +\msymindex{dots,ldots,cdots} +省略号有 \msym{dots} 和 \msym{cdots} 两种形式。它们有各自合适的用途: +\begin{example} +$a_1, a_2, \dots, a_n$ \\ +$a_1 + a_2 + \cdots + a_n$ +\end{example} + +\cmd{ldots} 和 \cmd{dots} 是完全等效的,它们既能用在公式中,也用来在文本里作为省略号(详见 \ref{subsec:punct} 小节)。 +除此之外,在矩阵中可能会用到竖排的 \msym{vdots} 和斜排的 \msym{ddots}。 + +\subsection{指数、上下标和导数}\label{subsec:math-scripts} + +\index{^@\texttt\textasciicircum\ (\textit{数学上标})} +\index{_@\texttt\textunderscore\ (\textit{数学下标})} +在 \LaTeX{} 中用 \texttt\textasciicircum 和 \texttt\textunderscore 标明上下标。 +注意上下标的内容(子公式)一般需要\textbf{用花括号包裹},否则上下标只对后面的一个符号起作用。 +\begin{example} +$p^3_{ij} \qquad +m_\mathrm{Knuth}\qquad +\sum_{k=1}^3 k $\\[5pt] +$a^x+y \neq a^{x+y}\qquad +e^{x^2} \neq {e^x}^2$ +\end{example} + +\pinyinindex{daoshu}{导数符号\texttt' ($a'$)} +导数符号\texttt'(${}'$)是一类特殊的上标,可以适当连用表示多阶导数,也可以在其后连用上标: +\begin{example} +$f(x) = x^2 \quad f'(x) += 2x \quad f''^{2}(x) = 4$ +\end{example} + +\subsection{分式和根式}\label{subsec:frac-sqrt} + +\mathindex{frac} +\cmdindex[amsmath]{dfrac,tfrac} +分式使用 \cmd{frac}\marg*{分子}\marg*{分母} 来书写。分式的大小在行间公式中是正常大小,而在行内被极度压缩。 +\pkg{amsmath} 提供了方便的命令 \amscmd{dfrac} 和 \amscmd{tfrac},令用户能够在行内使用正常大小的分式,或是反过来。 +\begin{example} +In display style: +\[ +3/8 \qquad \frac{3}{8} +\qquad \tfrac{3}{8} +\] +In text style: +$1\frac{1}{2}$~hours \qquad +$1\dfrac{1}{2}$~hours +\end{example} + +\mathindex{sqrt} +一般的根式使用 \cmd{sqrt}\marg*{...};表示 $n$ 次方根时写成 \cmd{sqrt}\oarg*{\textit{n}}\marg*{...}。 +\begin{example} +$\sqrt{x} \Leftrightarrow x^{1/2} +\quad \sqrt[3]{2} +\quad \sqrt{x^{2} + \sqrt{y}}$ +\end{example} + +\cmdindex[amsmath]{binom} +特殊的分式形式,如二项式结构,由 \pkg{amsmath} 宏包的 \amscmd{binom} 命令生成: +\begin{example} +Pascal's rule is +\[ +\binom{n}{k} =\binom{n-1}{k} ++ \binom{n-1}{k-1} +\] +\end{example} + +\subsection{关系符}\label{subsec:math-rel} + +\msymindex{ne,ge,le,approx,equiv,propto,sim} +\LaTeX{} 常见的关系符号除了可以直接输入的 $=$,$>$,$<$,其它符号用命令输入,常用的有不等号 \msym{ne}、 +大于等于号 \msym{ge} 和小于等于号 \msym{le}% +\footnote{倾斜的关系符号 \msym{leqslant} 和 \msym{geqslant} 由 \pkg{amssymb} 提供,见表 \ref{tbl:ams-rel}。}、 +约等号 \msym{approx}、等价 \msym{equiv}、正比 \msym{propto}、相似 \msym{sim} 等等。 +更多符号命令可参考表 \ref{tbl:math-rel} 以及表 \ref{tbl:ams-rel}。 + +\mathindex{stackrel} +\LaTeX{} 还提供了自定义二元关系符的命令 \cmd{stackrel},用于将一个符号叠加在原有的二元关系符之上: +\begin{example} +\[ +f_n(x) \stackrel{*}{\approx} 1 +\] +\end{example} + +\subsection{算符}\label{subsec:math-op} + +\msymindex{times,div,cdot,pm,mp} +\LaTeX{} 中的算符大多数是二元算符,除了直接用键盘可以输入的 $+$、$-$、$*$、$/$,其它符号用命令输入, +常用的有乘号 \msym{times}、 除号 \msym{div}、点乘 \msym{cdot}、加减号 \msym{pm} / \msym{mp} 等等。 +更多符号命令可参考表 \ref{tbl:math-op} 以及表 \ref{tbl:ams-op}。 + +\msymindex{nabla,partial} +\msym{nabla} 和 \msym{partial} 也是常用的算符,虽然它们不属于二元算符。 + +\pinyinindex{shuxuehanshu}{数学函数} +\LaTeX{} 将数学函数的名称作为一个算符排版,字体为直立字体。其中有一部分符号在上下位置可以书写一些内容作为条件, +类似于后文所叙述的巨算符。 + +\begin{table}[htp] +\centering +\caption{\LaTeX{} 作为算符的函数名称一览}\label{tbl:math-functions} +\begin{tabular}{*{5}{p{5em}}} +\hline +\multicolumn{5}{c}{\textbf{不带上下限的算符}} \\ +\hline +\cmd{sin} & \cmd{arcsin} & \cmd{sinh} & \cmd{exp} & \cmd{dim} \\ +\cmd{cos} & \cmd{arccos} & \cmd{cosh} & \cmd{log} & \cmd{ker} \\ +\cmd{tan} & \cmd{arctan} & \cmd{tanh} & \cmd{lg} & \cmd{hom} \\ +\cmd{cot} & \cmd{arg} & \cmd{coth} & \cmd{ln} & \cmd{deg} \\ +\cmd{sec} & \cmd{csc} & \\ +\hline +\multicolumn{5}{c}{\textbf{带上下限的算符}} \\ +\hline +\cmd{lim} & \cmd{limsup} & \cmd{liminf} & \cmd{sup} & \cmd{inf} \\ +\cmd{min} & \cmd{max} & \cmd{det} & \cmd{Pr} & \cmd{gcd} \\ +\hline +\end{tabular} +\end{table} + +\begin{example} +\[ + \lim_{x \rightarrow 0} + \frac{\sin x}{x}=1 +\] +\end{example} + +\mathindex{bmod,pmod} +对于求模表达式,\LaTeX{} 提供了 \cmd{bmod} 和 \cmd{pmod} 命令,前者相当于一个二元运算符,后者作为同余表达式的后缀: +\begin{example} +$a\bmod b \\ + x\equiv a \pmod{b}$ +\end{example} + +\cmdindex[amsmath]{DeclareMathOperator} +如果表 \ref{tbl:math-functions} 中的算符不够用的话,\pkg{amsmath} 允许用户用 \amscmd{Declare\-Math\-Operator} +定义自己的算符,其中带星号的命令定义带上下限的算符: +\begin{verbatim} +\DeclareMathOperator{\argh}{argh} +\DeclareMathOperator*{\nut}{Nut} +\end{verbatim} + +\begin{example} +\[\argh 3 = \nut_{x=1} 4x\] +\end{example} + +\subsection{巨算符}\label{subsec:math-bigop} + +\msymindex{int,oint,sum,prod} +积分号 \msym{int}、求和号 \msym{sum} 等符号称为\textbf{巨算符}。巨算符在行内公式和行间公式的大小和形状有区别。 +\begin{example} +In text: +$\sum_{i=1}^n \quad +\int_0^{\frac{\pi}{2}} \quad +\oint_0^{\frac{\pi}{2}} \quad +\prod_\epsilon $ \\ +In display: +\[\sum_{i=1}^n \quad +\int_0^{\frac{\pi}{2}} \quad +\oint_0^{\frac{\pi}{2}} \quad +\prod_\epsilon \] +\end{example} + +\mathindex{limits,nolimits} +巨算符的上下标位置可由 \cmd{limits} 和 \cmd{nolimits} 调整,前者令巨算符类似 $\lim$ 或求和算符 $\sum$,上下标位于上下方; +后者令巨算符类似积分号,上下标位于右上方和右下方。 +\begin{example} +In text: +$\sum\limits_{i=1}^n \quad +\int\limits_0^{\frac{\pi}{2}} \quad +\prod\limits_\epsilon $ \\ +In display: +\[\sum\nolimits_{i=1}^n \quad +\int\limits_0^{\frac{\pi}{2}} \quad +\prod\nolimits_\epsilon \] +\end{example} + +\cmdindex[amsmath]{substack} +\envindex[amsmath]{subarray} +\pkg{amsmath} 宏包还提供了 \amscmd{substack},能够在下限位置书写多行表达式;\amsenv{subarray} +环境更进一步,令多行表达式可选择居中 (c) 或左对齐 (l): +\begin{example} +\[ +\sum_{\substack{0\le i\le n \\ + j\in \mathbb{R}}} +P(i,j) = Q(n) +\] +\[ +\sum_{\begin{subarray}{l} + 0\le i\le n \\ + j\in \mathbb{R} +\end{subarray}} +P(i,j) = Q(n) +\] +\end{example} + +\subsection{数学重音和上下括号}\label{subsec:math-accents} + +\maccindex{dot,ddot,vec,hat} +数学符号可以像文字一样加重音,比如求导符号 $\dot{r}$ (\cmd{dot}\marg*{r})、 $\ddot{r}$ (\cmd{ddot}\marg*{r})、 +表示向量的箭头 $\vec{r}$ (\cmd{vec}\marg*{r}) 、表示单位向量的符号 $\hat{\mathbf{e}}$ (\cmd{hat}\marg*{\cmd{mathbf}\marg*{e}}) 等, +详见表 \ref{tbl:math-accents}。使用时要注意重音符号的作用区域,一般应当对某个符号而不是“符号加下标”使用重音: +\begin{example} +$\bar{x_0} \quad \bar{x}_0$\\[5pt] +$\vec{x_0} \quad \vec{x}_0$\\[5pt] +$\hat{\mathbf{e}_x} \quad + \hat{\mathbf{e}}_x$ +\end{example} + +\waccindex{overline,underline} +\waccindex{widehat,overrightarrow} +\LaTeX{} 也能为多个字符加重音,包括直接画线的 \cmd{overline} 和 \cmd{underline} 命令(可叠加使用)、宽重音符号 \cmd{widehat}、 +表示向量的箭头 \cmd{overrightarrow} 等。后两者详见表 \ref{tbl:math-accents} 和 \ref{tbl:math-arrow-accents} 等。 +\begin{example} +$0.\overline{3} = +\underline{\underline{1/3}}$ \\[5pt] +$\hat{XY} \qquad \widehat{XY}$\\[5pt] +$\vec{AB} \qquad +\overrightarrow{AB}$ +\end{example} + +\waccindex{overbrace,underbrace} +\cmd{overbrace} 和 \cmd{underbrace} 命令用来生成上/下括号,各自可带一个上/下标公式。 +\begin{example} +$\underbrace{\overbrace{(a+b+c)}^6 +\cdot \overbrace{(d+e+f)}^7} +_\text{meaning of life} = 42$ +\end{example} + +\subsection{箭头}\label{subsec:math-arrows} + +\msymindex{to,rightarrow,leftarrow,uparrow,downarrow} +常用的箭头包括 \cmd{rightarrow} ($\rightarrow$,或 \cmd{to})、\cmd{leftarrow}($\leftarrow$,或 \cmd{gets})等。 +更多箭头详见表 \ref{tbl:math-arrows}。 + +\cmdindex[amsmath]{xleftarrow,xrightarrow} +\pkg{amsmath} 的 \amscmd{xleft\-arrow} 和 \amscmd{xright\-arrow} 命令提供了长度可以伸展的箭头,并且可以为箭头增加上下标: +\begin{example} +\[ a\xleftarrow{x+y+z} b \] +\[ c\xrightarrow[x 0. +\end{array} \right. \] +\end{example} + +\envindex[amsmath]{cases} +不过上述例子可以用 \pkg{amsmath} 提供的 \amsenv{cases} 环境更轻松地完成: +\begin{example} +\[ |x| = +\begin{cases} +-x & \text{if } x < 0,\\ +0 & \text{if } x = 0,\\ +x & \text{if } x > 0. +\end{cases} \] +\end{example} + +\envindex[amsmath]{matrix,pmatrix,bmatrix,Bmatrix,vmatrix,Vmatrix} +我们当然也可以用 \env{array} 环境排版各种矩阵。\pkg{amsmath} 宏包还直接提供了多种排版矩阵的环境,包括不带定界符的 \amsenv{matrix}, +以及带各种定界符的矩阵 \amsenv{pmatrix}($\bigl($)、\amsenv{bmatrix}($\bigl[$)、\amsenv{Bmatrix}($\bigl\{$)、 +\amsenv{vmatrix}($\bigl\vert$)、\amsenv{Vmatrix}($\bigl\Vert$)。使用这些环境时,无需给定列格式% +\footnote{事实上这些矩阵内部也是用 \env{array} 环境生成的,列格式默认为 \texttt{*\{\Arg{n}\}\{c\}},\Arg{n} 默认为 10; +\amsenv{cases} 内部是一个列格式为 \texttt{@\{\}l@\{\cmd{quad}\}l@\{\}} 的 \env{array} 环境。}: +\begin{example} +\[ +\begin{matrix} +1 & 2 \\ 3 & 4 +\end{matrix} \qquad +\begin{bmatrix} +x_{11} & x_{12} & \ldots & x_{1n}\\ +x_{21} & x_{22} & \ldots & x_{2n}\\ +\vdots & \vdots & \ddots & \vdots\\ +x_{n1} & x_{n2} & \ldots & x_{nn}\\ +\end{bmatrix} +\] +\end{example} + +在矩阵中的元素里排版分式时,一来要用到 \amscmd{dfrac} 等命令,二来行与行之间有可能紧贴着,这时要用到 +\ref{subsec:tabular-colht} 小节的方法来调节间距: +\begin{example} +\[ +\mathbf{H}= +\begin{bmatrix} +\dfrac{\partial^2 f}{\partial x^2} & +\dfrac{\partial^2 f} + {\partial x \partial y} \\[8pt] +\dfrac{\partial^2 f} + {\partial x \partial y} & +\dfrac{\partial^2 f}{\partial y^2} +\end{bmatrix} +\] +\end{example} + +\section{公式中的间距}\label{sec:math-space} + +\cmdindex{quad,qquad} +\index{,@\cmd{,}} % The only one which cannot use \cmdindex, oops.. +\mathindex{:,;,"!} +前文提到过,绝大部分时候,数学公式中各元素的间距是根据符号类型自动生成的,需要我们手动调整的情况极少。 +我们已经认识了两个生成间距的命令 \cmd{quad} 和 \cmd{qquad}。在公式中我们还可能用到的间距包括 \cmd{,}、\cmd{:}、\cmd{;} +以及负间距 \cmd{!},其中 \cmd{quad} 、 \cmd{qquad} 和 \cmd{,} 在文本和数学环境中可用,后三个命令只用于数学环境。 +文本中的 \cmd{\textvisiblespace} 也能使用在数学公式中。 + +\newdimen\testdimen \testdimen=\fontdimen6\textfont2 \divide\testdimen18\relax +\begin{center} +\begin{tabularx}{0.9\textwidth}{*{3}{>{\raggedright\arraybackslash}X}|*{3}{>{\raggedright\arraybackslash}X}} + \hline + 无额外间距 & & $a a$ & + \cmd{,} & \demowidth{3\testdimen} & $a\,a$ \\ + \cmd{quad} & \demowidth{18\testdimen} & $a\quad a$ & + \cmd{:} & \demowidth{4\testdimen} & $a\:a$ \\ + \cmd{qquad} & \demowidth{36\testdimen} & $a\qquad a$ & + \cmd{;} & \demowidth{5\testdimen} & $a\;a$ \\ + \cmd{\textvisiblespace} & \demowidth{\fontdimen2\textfont0} & $a\ a$ & + \cmd{!} & $-$\demowidth{3\testdimen} & $a\!a$ \\ + \hline +\end{tabularx} +\end{center} + +一个常见的用途是修正积分的被积函数$f(x)$和微元$\mathrm{d}x$之间的距离。注意微元里的$\mathrm{d}$用的是直立体: +\begin{example} +\[ +\int_a^b f(x)\mathrm{d}x +\qquad +\int_a^b f(x)\,\mathrm{d}x +\] +\end{example} + +另一个用途是生成多重积分号。如果我们直接连写两个 \cmd{int},之间的间距将会过宽,此时可以使用负间距 \cmd{!} 修正之。 +不过 \pkg{amsmath} 提供了更方便的多重积分号,如二重积分 \amscmd{iint}、三重积分 \amscmd{iiint} 等。 +\begin{example} +\newcommand\diff{\,\mathrm{d}} +\begin{gather*} +\int\int f(x)g(y) +\diff x \diff y \\ +\int\!\!\!\int +f(x)g(y) \diff x \diff y \\ +\iint f(x)g(y) \diff x \diff y \\ +\iint\quad \iiint\quad \idotsint +\end{gather*} +\end{example} + +\section{数学符号的字体控制}\label{sec:math-fonts} + +\subsection{数学字母字体}\label{subsec:math-alpha} + +\mathindex{mathrm,mathsf,mathtt,mathit,mathbf,mathcal,mathnormal} +\cmdindex[amssymb]{mathbb,mathfrak} +\cmdindex[mathrsfs]{mathscr} +\LaTeX{} 允许一部分数学符号切换字体,主要是拉丁字母、数字、大写希腊字母以及重音符号等。 +表 \ref{tbl:math-fonts} 给出了切换字体的命令。某一些命令需要字体宏包的支持。 +\begin{example} +$\mathcal{R} \quad \mathfrak{R} +\quad \mathbb{R}$ +\[\mathcal{L} += -\frac{1}{4}F_{\mu\nu}F^{\mu\nu}\] +$\mathfrak{su}(2)$ and +$\mathfrak{so}(3)$ Lie algebra +\end{example} + +\begin{table}[htp] +\centering +\caption{数学字母字体} \label{tbl:math-fonts} +\begin{tabular}{*{3}{l}} +\hline +\textbf{示例} & \textbf{命令} & \textbf{依赖的宏包}\\ +\hline +$\mathnormal{ABCDE abcde 1234}$ & \cmd{mathnormal}\marg*{\ldots}& \\ +$\mathrm{ABCDE abcde 1234}$ & \cmd{mathrm}\marg*{\ldots} & \\ +$\mathit{ABCDE abcde 1234}$ & \cmd{mathit}\marg*{\ldots} & \\ +$\mathbf{ABCDE abcde 1234}$ & \cmd{mathbf}\marg*{\ldots} & \\ +$\mathsf{ABCDE abcde 1234}$ & \cmd{mathsf}\marg*{\ldots} & \\ +$\mathtt{ABCDE abcde 1234}$ & \cmd{mathtt}\marg*{\ldots} & \\ +$\CMcal{ABCDE}$ & \cmd{mathcal}\marg*{\ldots} & 仅提供大写字母 \\ +\hline +$\EuScript{ABCDE}$ & \cmd{mathcal}\marg*{\ldots} & \pkg{eucal} 仅提供大写字母 \\ +$\mathscr{ABCDE}$ & \cmd{mathscr}\marg*{\ldots} & \pkg{mathrsfs} 仅提供大写字母\\ +$\mathfrak{ABCDE abcde 1234}$ & \cmd{mathfrak}\marg*{\ldots} & \pkg{amssymb} 或 \pkg{eufrak} \\ +$\mathbb{ABCDE}$ & \cmd{mathbb}\marg*{\ldots} & \pkg{amssymb} 仅提供大写字母 \\ +\hline +\end{tabular} +\end{table} + +\pkgindex{unicode-math} +如果需要为所有的数学符号切换字体,则需要直接调用数学字体宏包(见 \ref{subsec:font-pkgs} 小节)。在 \texttt{xelatex} 或者 \texttt{lualatex} 编译命令下,还可以使用基于 \pkg{fontspec} 宏包的 \pkg{unicode-math} 宏包配置 Unicode 数学字体,详见 \ref{subsec:unicode-math} 小节。 + +\subsection{数学符号的尺寸}\label{subsec:math-styles} + +\mathindex{displaystyle,textstyle,scriptstyle,scriptscriptstyle} +数学符号按照符号排版的位置规定尺寸,从大到小包括行间公式尺寸、行内公式尺寸、上下标尺寸、次级上下标尺寸。 +除了字号有别之外,行间和行内公式尺寸下的巨算符也使用不一样的大小。\LaTeX{} 为每个数学尺寸指定了一个切换的命令,见 \ref{tbl:math-size}。 +\begin{table}[htp] +\centering +\caption{数学符号尺寸}\label{tbl:math-size} +\begin{tabular}{lll} + \hline + \textbf{命令} & \textbf{尺寸} & \textbf{示例} \\ + \hline +\cmd{displaystyle} & 行间公式尺寸 & $\displaystyle\sum a $\\ +\cmd{textstyle} & 行内公式尺寸 & $\textstyle\sum a $ \\ +\cmd{scriptstyle} & 上下标尺寸 & $\scriptstyle a$ \\ +\cmd{scriptscriptstyle} & 次级上下标尺寸 & $\scriptscriptstyle a$\\ + \hline +\end{tabular} +\end{table} + +我们通过以下示例对比行间公式和行内公式的区别。在分式中,分子分母默认为行内公式尺寸,示例中将分母切换到行间公式尺寸: +\begin{example} +\[ +r = \frac + {\sum_{i=1}^n (x_i- x)(y_i- y)} + {\displaystyle \left[ + \sum_{i=1}^n (x_i-x)^2 + \sum_{i=1}^n (y_i-y)^2 + \right]^{1/2} } +\] +\end{example} + +\subsection{加粗的数学符号}\label{subsec:math-bold} + +在 \LaTeX{} 中为符号切换数学字体并不十分自由,只能通过 \cmd{mathbf} 等有限的命令切换字体。比如想得到粗斜体的符号,就没有现成的命令% +\footnote{国内使用粗斜体符号表示矢量,见 GB 3102.11--93。};再比如 \cmd{mathbf} 只能改变拉丁字母和大写希腊字母,小写希腊字母就没有用。 + +\cmdindex{boldmath} +\LaTeX{} 提供了一个命令 \cmd{boldmath} 令用户可以将整套数学字体切换为粗体版本(前提是数学字体宏包本身支持粗体符号)。但这个命令\textbf{只能在公式外使用}: +\begin{example} +$\mu, M \qquad +\mathbf{\mu}, \mathbf{M}$ +\qquad {\boldmath$\mu, M$} +\end{example} + +\cmdindex[amsmath]{boldsymbol} +\pkg{amsmath} 提供了一个 \amscmd{boldsymbol} 命令(由调用的 \pkg{amsbsy} 宏包提供),用于打破 \cmd{boldmath} 的限制, +在公式内部将一部分符号切换为粗体。 +\begin{example} +$\mu, M \qquad +\boldsymbol{\mu}, \boldsymbol{M}$ +\end{example} + +\pkgindex{bm} +\cmdindex[bm]{bm} +然而在许多数学字体宏包中,定界符、巨算符等一些符号本身没有粗体版本,\amscmd{boldsymbol} 也得不到粗体。 +\LaTeX{} 工具宏集之一的 \pkg{bm} 宏包可以用 \cmd{bm} 命令生成“伪粗体”,作为粗体符号的一个解决方案。这里不做过多介绍, +详情请参考 \pkg{bm} 宏包的帮助文档。 + +\section{定理环境}\label{sec:theorems} + +\subsection{\LaTeX{} 原始的定理环境}\label{subsec:latex-theorems} + +\cmdindex{newtheorem} +使用 \LaTeX{} 排版数学和其他科技文档时,会接触到大量的定理、证明等内容。 +\LaTeX{} 提供了一个基本的命令 \cmd{newtheorem} 提供定理环境的定义: +\begin{command} +\cmd{newtheorem}\marg{theorem environment}\marg{title}\oarg{section-level} \\ +\cmd{newtheorem}\marg{theorem environment}\oarg{counter}\marg{title} +\end{command} + +\Arg{theorem environment} 为定理环境的名称。原始的\LaTeX{} 里\textbf{没有现成的定理环境}, +不加定义而直接使用很可能会出错。\Arg{title} 是定理环境的标题(“定理”,“公理”等)。 + +定理的序号由两个可选参数之一决定,它们\textbf{不能同时使用}: +\begin{itemize} + \item \Arg{section level} 为章节级别,如 \texttt{chapter}、\texttt{section} 等,定理序号成为章节的下一级序号; + \item \Arg{counter} 为用 \cmd{newcounter} 自定义的计数器名称(详见 \ref{sec:counters} 节),定理序号由这个计数器管理。 +\end{itemize} +如果两个可选参数都不用的话,则使用默认的与定理环境同名的计数器。 + +在以下示例代码中,我们定义了一个 \env{mythm} 环境,其序号设为 \texttt{section} 的下一级序号。 +注意 \env{mythm} 环境的可选参数以及 \cmd{label} 的用法: +\begin{example} +\newtheorem{mythm}{My Theorem}[section] +\begin{mythm}\label{thm:light} +The light speed in vacuum +is $299,792,458\,\mathrm{m/s}$. +\end{mythm} +\begin{mythm}[Energy-momentum relation] +The relationship of energy, +momentum and mass is +\[E^2 = m_0^2 c^4 + p^2 c^2\] +where $c$ is the light speed +described in theorem \ref{thm:light}. +\end{mythm} +\end{example} + +\subsection{\pkg{amsthm} 宏包}\label{subsec:amsthm} + +\LaTeX{} 默认的定理环境格式为粗体标签、斜体正文、定理名用小括号包裹。如果需要修改格式, +则要依赖其它的宏包,如 \pkg{amsthm}、\pkg{ntheorem} 等等。本小节简单介绍一下 \pkg{amsthm} 的用法。 + +\pkgindex{amsthm} +\cmdindex[amsthm]{theoremstyle} +\pkg{amsthm} 提供了 \cmd{theo\-rem\-style} 命令支持定理格式的切换, +在用 \cmd{new\-theo\-rem} 命令定义定理环境之前使用。 +\pkg{amsthm} 预定义了三种格式用于 \cmd{theo\-rem\-style}:\texttt{plain} 和 \LaTeX{} 原始的格式一致; +\texttt{defi\-ni\-tion} 使用粗体标签、正体内容;\texttt{remark} 使用斜体标签、正体内容。 + +另外 \pkg{amsthm} 还支持用带星号的 \cmd{new\-theo\-rem*} 定义不带序号的定理环境: +\begin{verbatim} +\theoremstyle{definition} \newtheorem{law}{Law} +\theoremstyle{plain} \newtheorem{jury}[law]{Jury} +\theoremstyle{remark} \newtheorem*{mar}{Margaret} +\end{verbatim} +\theoremstyle{definition} \newtheorem{law}{Law} +\theoremstyle{plain} \newtheorem{jury}[law]{Jury} +\theoremstyle{remark} \newtheorem*{mar}{Margaret} + +以上例子定义的 \env{jury} 环境与 \env{law} 环境共用编号,\env{mar} 环境不编号: +\begin{example} +\begin{law}\label{law:box} +Don't hide in the witness box. +\end{law} +\begin{jury}[The Twelve] +It could be you! So beware and +see law~\ref{law:box}.\end{jury} +\begin{jury} +You will disregard the last +statement.\end{jury} +\begin{mar}No, No, No\end{mar} +\begin{mar}Denis!\end{mar} +\end{example} + +\pkg{amsthm} 还支持使用 \cmd{new\-theorem\-style} 命令自定义定理格式, +更为方便使用的是 \pkg{ntheorem} 宏包。感兴趣的读者可参阅它们的帮助文档。 + +\subsection{证明环境和证毕符号}\label{subsec:proof} + +\envindex[amsthm]{proof} +\pkg{amsthm} 还提供了一个 \env{proof} 环境用于排版定理的证明过程。\env{proof} 环境末尾 +自动加上一个 \qedsymbol{} 证毕符号: +\begin{example} +\begin{proof} +For simplicity, we use +\[ +E=mc^2 +\] +That's it. +\end{proof} +\end{example} + +\cmdindex[amsthm]{qedhere} +如果行末是一个不带编号的公式,\qedsymbol{} 符号会另起一行, +这时可使用 \cmd{qedhere} 命令将 \qedsymbol{} 符号放在公式末尾: +\begin{example} +\begin{proof} +For simplicity, we use +\[ +E=mc^2 \qedhere +\] +\end{proof} +\end{example} + +\cmd{qedhere} 对于 \amsenv{align*} 等环境也有效: +\begin{example} +\begin{proof} +Assuming $\gamma += 1/\sqrt{1-v^2/c^2}$, then +\begin{align*} +E &= \gamma m_0 c^2 \\ +p &= \gamma m_0v \qedhere +\end{align*} +\end{proof} +\end{example} + +在使用带编号的公式时,建议最好\textbf{不要在公式末尾使用} \cmd{qedhere} 命令。 +对带编号的公式使用 \cmd{qedhere} 命令会使 \qedsymbol{} 符号放在一个难看的位置,紧贴着公式: +\begin{example} +\begin{proof} +For simplicity, we use +\begin{equation} +E=mc^2.\qedhere +\end{equation} +\end{proof} +\end{example} + +在 \amsenv{align} 等环境中使用 \cmd{qedhere} 命令会使 \qedsymbol{} 盖掉公式的编号;使用 \env{equation} 嵌套 +\amsenv{aligned} 等环境时,\cmd{qedhere} 命令会将 \qedsymbol{} 直接放在公式后。这些位置都不太正常。 + +证毕符号 \qedsymbol{} 本身被定义在命令 \cmd{qedsymbol} 中,如果有使用实心符号作为证毕符号的需求,需要自行用 \cmd{re\-new\-comm\-and} +命令修改(用法见 \ref{subsec:newcmd} 小节)\footnote{注意,这个改法\textbf{只对 \pkg{amsthm} 宏包适用}。 +其它宏包如 \pkg{ntheorem} 等须参考帮助文档里提供的修改方法。}。 +我们可以利用在 \ref{subsec:rules} 小节介绍的标尺盒子来生成一个适当大小的“实心矩形”: +\begin{example} +\renewcommand{\qedsymbol}% + {\rule{1ex}{1.5ex}} +\begin{proof} +For simplicity, we use +\[ +E=mc^2 \qedhere +\] +\end{proof} +\end{example} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.05.style.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.05.style.tex new file mode 100644 index 00000000000..460dd7c81ce --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.05.style.tex @@ -0,0 +1,776 @@ +\chapter{排版样式设定}\label{chap:styles} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +至此你已经基本学会排版内容丰富的文档,标题、目录、章节、公式、列表、图片、表格等等应有尽有。但是你可能已经有点不甘心了, +因为似乎你排版出来的文档是千篇一律的模样——\LaTeX{} 默认的字体、单调的页眉页脚、不太令你满意的页边距,等等。 +本章的内容将带你一览如何修改 \LaTeX{} 的排版样式。 +\end{intro} + +\section{字体和字号}\label{sec:font} + +\LaTeX{} 根据文档的逻辑结构(章节、脚注等)来选择默认的字体样式以及字号。 +需要更改字体样式或字号的话,可以使用表 \ref{tbl:fonts} 和表 \ref{tbl:sizes} 中列出的命令。 +\begin{example} +{\small The small and +\textbf{bold} Romans ruled} +{\Large all of great big +{\itshape Italy}.} +\end{example} + +\LaTeXe{} 相比于较早的 \LaTeX{} 版本(2.09版或更早)在字体样式和字号的设定上有很大改进,令字体的各种属性相互独立(“正交”), +用户可以改变字体的大小,而仍然保留字体原有的粗体或者斜体的特性。 + +\subsection{字体样式}\label{subsec:fontshape} + +\pinyinindex{ziti}{字体} +\pinyinindex{fenzu}{分组} +\LaTeX{} 提供了两组修改字体的命令,见表 \ref{tbl:fonts}。其中诸如 \cmd{bfseries} 形式的命令将会影响之后所有的字符, +如果想要让它在局部生效,需要用花括号\textbf{分组},也就是写成 \marg*{\cmd{bfseries}\ \Arg{some text}} 这样的形式; +对应的 \cmd{textbf} 形式带一个参数,只改变参数内部的字体,更为常用。 + +在公式中,直接使用 \cmd{textbf} 等命令不会起效,甚至报错。\LaTeX{} 提供了修改数学字母样式的命令,如 \cmd{mathbf} 等,详见 \ref{subsec:math-alpha} 小节。 + +\begin{table}[htp] +\caption{字体命令} \label{tbl:fonts} +\centering +\begin{tabular}{*{4}{l}} +\hline +\cmd{rmfamily}\cmdindex{rmfamily} & \cmd{textrm}\cmdindex{textrm}\marg*{\ldots} & \textrm{roman} & 衬线字体(罗马体)\\ +\cmd{sffamily}\cmdindex{sffamily} & \cmd{textsf}\cmdindex{textsf}\marg*{\ldots} & \textsf{sans serif} & 无衬线字体 \\ +\cmd{ttfamily}\cmdindex{ttfamily} & \cmd{texttt}\cmdindex{texttt}\marg*{\ldots} & \texttt{typewriter} & 等宽字体 \\[\medskipamount] +\cmd{mdseries}\cmdindex{mdseries} & \cmd{textmd}\cmdindex{textmd}\marg*{\ldots} & \textrm{medium} & 正常粗细(中等) \\ +\cmd{bfseries}\cmdindex{bfseries} & \cmd{textbf}\cmdindex{textbf}\marg*{\ldots} & \textbf{bold face} & 粗体 \\[\medskipamount] +\cmd{upshape}\cmdindex{upshape} & \cmd{textup}\cmdindex{textup}\marg*{\ldots} & \textup{upright} & 直立体 \\ +\cmd{itshape}\cmdindex{itshape} & \cmd{textit}\cmdindex{textit}\marg*{\ldots} & \textit{italic} & 意大利斜体 \\ +\cmd{slshape}\cmdindex{slshape} & \cmd{textsl}\cmdindex{textsl}\marg*{\ldots} & \textsl{slanted} & 倾斜体 \\ +\cmd{scshape}\cmdindex{scshape} & \cmd{textsc}\cmdindex{textsc}\marg*{\ldots} & \textsc{Small Caps} & 小型大写字母 \\[\medskipamount] +\cmd{em}\cmdindex{em} & \cmd{emph}\cmdindex{emph}\marg*{\ldots} & \emph{emphasized} & 强调,默认斜体 \\ +\cmd{normalfont}\cmdindex{normalfont} & \cmd{textnormal}\cmdindex{textnormal}\marg*{\ldots} & \textnormal{normal font} & 默认字体 \\ +\hline +\end{tabular} +\end{table} + +\subsection{字号}\label{subsec:fontsize} + +\pinyinindex{zihao}{字号} +字号命令实际大小依赖于所使用的文档类及其选项。表 \ref{tbl:ptsizes} 列出了这些命令在标准文档类中的绝对大小,单位为 pt。 + +\begin{table}[htp] +\centering +\caption{字号} \label{tbl:sizes} +\begin{tabular}{ll} +\hline +\cmd{tiny}\cmdindex{tiny} & \tiny tiny font \\ +\cmd{scriptsize}\cmdindex{scriptsize} & \scriptsize very small font\\ +\cmd{footnotesize}\cmdindex{footnotesize} & \footnotesize quite small font \\ +\cmd{small}\cmdindex{small} & \small small font \\ +\cmd{normalsize}\cmdindex{normalsize} & \normalsize normal font \\ +\cmd{large}\cmdindex{large} & \large large font \\ +\hline +\end{tabular}% +\qquad\begin{tabular}{ll@{}} +\hline +\cmd{Large}\cmdindex{Large} & \Large larger font \\[5pt] +\cmd{LARGE}\cmdindex{LARGE} & \LARGE very large font \\[5pt] +\cmd{huge}\cmdindex{huge} & \huge huge \\[5pt] +\cmd{Huge}\cmdindex{Huge} & \Huge largest \\ +\hline +\end{tabular} +\end{table} + +\begin{table}[htp] +\centering +\caption{标准文档类中的字号大小}\label{tbl:ptsizes} +\begin{tabular}{*{4}{l}} +\hline +\textbf{字号} & \textbf{10pt 选项(默认)} & \textbf{11pt 选项} & \textbf{12pt 选项} \\ +\hline +\cmd{tiny}\cmdindex{tiny} & 5pt & 6pt & 6pt\\ +\cmd{scriptsize}\cmdindex{scriptsize} & 7pt & 8pt & 8pt\\ +\cmd{footnotesize}\cmdindex{footnotesize} & 8pt & 9pt & 10pt \\ +\cmd{small}\cmdindex{small} & 9pt & 10pt & 10.95pt \\ +\cmd{normalsize}\cmdindex{normalsize} & 10pt & 10.95pt & 12pt \\ +\cmd{large}\cmdindex{large} & 12pt & 12pt & 14.4pt \\ +\cmd{Large}\cmdindex{Large} & 14.4pt & 14.4pt & 17.28pt \\ +\cmd{LARGE}\cmdindex{LARGE} & 17.28pt & 17.28pt & 20.74pt\\ +\cmd{huge}\cmdindex{huge} & 20.74pt & 20.74pt & 24.88pt\\ +\cmd{Huge}\cmdindex{Huge} & 24.88pt & 24.88pt & 24.88pt\\ +\hline +\end{tabular} +\end{table} + +使用字号命令的时候,通常也需要用花括号进行分组,如同 \cmd{rmfamily} 那样。 +\begin{example} +He likes {\LARGE large and +{\small small} letters}. +\end{example} + +\cmdindex{fontsize} +\LaTeX{} 还提供了一个基础的命令 \cmd{fontsize} 用于设定任意大小的字号: +\begin{command} +\cmd{fontsize}\marg{size}\marg{base line-skip} +\end{command} + +\cmdindex{selectfont} +\cmd{fontsize} 用到两个参数,\Arg{size} 为字号,\Arg{base line-skip} 为基础行距。 +表 \ref{tbl:ptsizes} 中的命令也都各自设定了与字号对应的基础行距,大小为字号的 1.2 倍。 +如果不是在导言区,\cmd{fontsize} 的设定需要 \cmd{selectfont} 命令才能立即生效, +而表 \ref{tbl:sizes} 的字号设定都是立即生效的。 + +\subsection{选用字体宏包}\label{subsec:font-pkgs} + +至此已经介绍了如何改变字体样式如粗体、斜体等等,以及如何改变字号, +但你依然用着 \LaTeX{} 默认的那套、由高德纳设计制作的 Computer Modern 字体。 +有的人可能很喜欢 Times / Palatino,或者更好看的字体。这些字体样式的自由设置在 \LaTeX{} 里还不太容易。 + +幸好大部分时候,许多字体宏包为我们完成了整套配置,我们可以在调用宏包之后,照常使用 \cmd{bfseries} 或 \cmd{ttfamily} 等我们熟悉的命令。 +表 \ref{tbl:font-pkgs} 列出了较为常用的字体宏包,其中相当多的宏包还配置了数学字体,或者文本、数学字体兼而有之。 +更多的的字体配置参考 \cite{survey,fontcatalogue}。 + +\subsection{字体编码}\label{subsec:font-encs} + +字体编码对于 \LaTeX{} 用户来讲是一个比较晦涩的概念。它规定了一个字体里包含的符号,并将若干符号用 \LaTeX{} 命令定义。 +注意字体编码与我们在 \ref{subsec:ascii} 等小节叙述的 ASCII 编码等并非一一对应。 + +常见的正文字体编码有 \texttt{OT1} 和 \texttt{T1} 等。\LaTeX{} 默认使用兼容 \hologo{plainTeX} 的 \texttt{OT1} 编码,使用起来有诸多限制: +高德纳在设计 Computer Modern 字体时认为一些符号,如大于号、小于号等,原则上都应该在公式里出现,所以在正文字体里这些符号所在的位置被其它符号所占据 +(\texttt{OT1} 字体编码、\cmd{rmfamily} 和 \cmd{sffamly} 字体族下, \texttt< 和 \texttt> 排版\ !` 和\ ?` 两个倒立的标点符号, +正常的大于号和小于号可用命令 \cmd{textgreater} 和 \cmd{textless} 输入;\cmd{ttfamily} 字体族下是正常的大于号和小于号)。 +扩展的 \texttt{T1} 字体编码则更加靠近 ASCII 文本编码,不会出现上述的大于号、小于号的问题。 + +\pkgindex{fontenc} +切换字体编码要用到 \pkg{fontenc} 宏包: +\begin{command} +\cmd{usepackage}\oarg*{T1}\marg*{fontenc} +\end{command} + +\pkg{fontenc} 宏包是用来配合传统的 \LaTeX{} 字体的,如表 \ref{tbl:font-pkgs} 中的一些传统字体宏包。如果使用 \texttt{xelatex} 编译方式, +并使用 \pkg{fontspec} 宏包调用 \texttt{ttf} 或 \texttt{otf} 格式字体,就不要再使用 \pkg{fontenc} 宏包。 +使用表 \ref{tbl:font-pkgs} 中的字体宏包之前最好查看一下宏包的帮助文档,了解使用方法和注意事项。 + +\begin{table}[!p] +\centering\small +\caption{常见的 \LaTeX{} 字体宏包}\label{tbl:font-pkgs} +\begin{tabular}{lp{30em}} + \hline + \multicolumn{2}{c}{\textbf{文本 / 数学字体搭配的宏包}} \\ + \hline + \pkg{lmodern} & Latin Modern 字体,对 Computer Modern 字体的扩展 \\ + \pkg{cmbright} & 仿 Computer Modern 风格的无衬线字体 \\ + \pkg{euler} & Euler 风格数学字体,也出自于高德纳之手 \\ + \pkg{ccfonts} & Concrete 风格字体 \\ + \pkg{txfonts} & Times 风格的字体宏包 \\ + \pkg{pxfonts} & Palatino 风格的字体宏包 \\ + \pkg{stix} & Times 风格的字体宏包 \\ + \pkg{newtxtext},\pkg{newtxmath} & \pkg{txfonts} 的改进版本,分别设置文本和数学字体 \\ + \pkg{newpxtext},\pkg{newpxmath} & \pkg{pxfonts} 的改进版本,分别设置文本和数学字体 \\ + \pkg{mathptmx} & \pkg{psnfss} 字体宏集之一,Times 风格,较为陈旧,不推荐使用 \\ + \pkg{mathpazo} & \pkg{psnfss} 字体宏集之一,Palatino 风格,较为陈旧,不推荐使用 \\ + \pkg{fourier} & fourier 风格数学字体,配合 Utopia 正文字体 \\ + \pkg{fouriernc} & fourier 风格数学字体,配合 New Century Schoolbook 正文字体 \\ + \pkg{arev} & Arev 无衬线字体宏包,Vera Sans 风格 \\ + \pkg{mathdesign} & 配合 Charter / Garamond / Utopia 正文字体的数学字体宏包 \\ + \hline + \multicolumn{2}{c}{\textbf{文本字体宏包}} \\ + \multicolumn{2}{l}{\footnotesize 以下字体包括传统的 \LaTeX{} 字体格式以及 TrueType / OpenType 格式。} \\ + \hline + \pkg{cm-unicode} & Computer Modern 风格的 Unicode 字体,支持多种西方语言 \\ + \pkg{dejavu} & DejaVu 开源字体 \\ + \pkg{droid} & Droid 开源字体 \\ + \pkg{inconsolata} & Inconsolata 开源等宽字体 \\ + \pkg{libertine} & Linux Libertine / Linux Biolium 开源字体 \\ + \pkg{roboto} & Roboto 开源无衬线字体 \\ + \pkg{sourcesanspro} & Source Sans Pro 开源无衬线字体 \\ + \pkg{sourcecodepro} & Source Code Pro 开源等宽字体 \\ + \hline + \multicolumn{2}{c}{\textbf{符号宏包}} \\ + \hline + \pkg{mathabx} & 数学符号宏包之一 \\ + \pkg{MnSymbol} & 数学符号宏包之一,配合 Minion Pro 文本字体 \\ + \pkg{fdsymbol} & 数学符号宏包之一 \\ + \pkg{pifont} & Zapf Dingbats 符号宏包 \\ + \hline +\end{tabular} +\end{table} + +\subsection{使用 \pkg{fontspec} 宏包更改字体}\label{subsec:fontspec} + +\index{xelatex@\texttt{xelatex} 命令} +\index{lualatex@\texttt{lualatex} 命令} +\texttt{xelatex} 和 \texttt{lualatex} 编译命令能够支持直接调用系统和 \TeX{} 发行版中的 \texttt{.ttf} 或 \texttt{.otf} 格式字体% +\footnote{Linux 下的 \hologo{TeXLive} 为了令 \hologo{XeTeX} 使用 OpenType 字体,需要额外的配置。详见附录 \ref{app:install}。}。 +相比于前文介绍的字体宏包,我们有了更多自由修改字体的余地。 + +\pkgindex{fontspec} +\cmdindex[fontspec]{setmainfont,setsansfont,setmonofont} +\texttt{xelatex} 和 \texttt{lualatex} 命令下支持用户调用字体的宏包是 \pkg{fontspec}。 +宏包提供了几个设置全局字体的命令,设置 \cmd{rmfamily} 等对应命令的默认字体% +\footnote{旧版本 \pkg{fontspec} 的命令把必选参数 \Arg{font name} 放在可选参数 \Arg{font features} 的后面。新版本目前兼容旧版本的用法,但推荐使用新版本的用法。}: +\begin{command} +\cmd{setmainfont}\marg{font name}\oarg{font features} \\ +\cmd{setsansfont}\marg{font name}\oarg{font features} \\ +\cmd{setmonofont}\marg{font name}\oarg{font features} +\end{command} +其中 \Arg{font name} 使用字体的文件名(带扩展名)或者字体的英文名称。\Arg{font features} 用来手动配置对应的粗体或斜体 +,比如为 Windows 下的无衬线字体 Arial 配置粗体和斜体(通常情况下自动检测并设置对应的粗体和斜体,无需手动指定): +\begin{verbatim} +\setsansfont[BoldFont={Arial Bold}, ItalicFont={Arial Italic}]{Arial} +\end{verbatim} +\Arg{font features} 还能配置字体本身的各种特性,这里不再赘述,感兴趣的读者请参考 \pkg{fontspec} 宏包的帮助文档。 + +需要注意的是:\pkg{fontspec} 宏包会覆盖数学字体设置。需要调用表 \ref{tbl:font-pkgs} 中列出的一些数学字体宏包时, +应当在调用 \pkg{fontspec} 宏包时指定 \texttt{no-math} 选项。\pkg{fontspec} 宏包可能被其它宏包或文档类(如 \pkg{ctex} 文档类)自动调用时, +则在文档开头的 \cmd{document\-class} 命令里指定 \texttt{no-math} 选项。 + +\subsection{在 \pkg{ctex} 宏包或文档类中更改中文字体}\label{subsec:CJKfont} + +\pkgindex{xeCJK,ctex} +\cmdindex[xeCJK,ctex]{setCJKmainfont,setCJKsansfont,setCJKmonofont} +前文已经介绍过的 \pkg{ctex} 宏包或文档类提供了和 \pkg{fontspec} 宏包非常类似的语法设置中文字体% +\footnote{使用 \texttt{xelatex} 编译时,这几个命令实际上由 \pkg{xeCJK} 宏包提供; +使用 \texttt{lualatex} 编译时,则是由 \pkg{ctex} 宏包或文档类对 \pkg{luatexja} 宏包提供的类似命令进行额外封装。}: +\begin{command} +\cmd{setCJKmainfont}\marg{font name}\oarg{font features} \\ +\cmd{setCJKsansfont}\marg{font name}\oarg{font features} \\ +\cmd{setCJKmonofont}\marg{font name}\oarg{font features} +\end{command} + +由于中文字体少有对应的粗体或斜体,\Arg{font features} 里多用其他字体来配置, +比如在 Windows 中设定基本字体为宋体,并设定对应的 \texttt{BoldFont} 为黑体, \texttt{ItalicFont} 为楷体: +\begin{verbatim} +\setCJKmainfont{SimSun}[BoldFont=SimHei, ItalicFont=KaiTi] +\end{verbatim} + +\subsection{使用 \pkg{unicode-math} 宏包配置 Unicode 数学字体}\label{subsec:unicode-math} + +\pkgindex{unicode-math} +\cmdindex[unicode-math]{setmathfont} +Unicode 数学字体是一类 OpenType 字体,包含了 Unicode 字符集中的数学符号部分,字体中也设定了数学公式排版所需的一些参数。在 \texttt{xelatex} 或者 \texttt{lualatex} 编译命令下,借助 \pkg{unicode-math} 宏包可以调用 Unicode 数学字体配置数学公式的字体风格。 + +在导言区使用 \cmd{usepackage}\marg*{unicode-math} 后,使用 \cmd{setmathfont} 命令即可: +\begin{command} +\cmd{setmathfont}\marg{font name}\oarg{font features} +\end{command} + +绝大多数时候,只需要给定字体名称 \Arg{font name} 即可。由于篇幅所限,在此不介绍可选参数 \Arg{font feature} 涉及的配置,有兴趣的读者请参考宏包的帮助文档。 + +Unicode 数学字体相比于正文字体的选择余地不多。表 \ref{tbl:uni-math-fonts} 给出了较为常用的 Unicode 数学字体。 + +\begin{table}[htp] +\centering\small +\caption{常用 Unicode 数学字体。} +\label{tbl:uni-math-fonts} +\begin{tabular}{llp{20em}} +\hline +\textbf{数学字体名称} & \textbf{配套正文字体名称} & \textbf{备注}\\ +\hline +\multicolumn{3}{c}{开源字体,发布于 CTAN} \\ +\hline +\texttt{Latin Modern Math} & \texttt{Latin Modern} & 基于 Computer Modern 风格 \\ +\texttt{STIX Math} & \texttt{STIX} & Times 风格 \\ +\texttt{XITS Math} & \texttt{XITS} & 基于 STIX,Times 风格,有粗体 XITS Math Bold 可用 \\ +\texttt{TeX Gyre Pagella Math} & \texttt{TeX Gyre Pagella} & Palatino 风格 \\ +\texttt{TeX Gyre Termes Math} & \texttt{TeX Gyre Termes} & Times 风格 \\ +\texttt{Libertinus Math} & \texttt{Libertinus} & Linux Libertine 风格 \\ +\texttt{Fira Math} & \texttt{Fira Sans} & 无衬线数学字体 \\ +\hline +\multicolumn{3}{c}{商业字体} \\ +\hline +\texttt{Cambria Math} & \texttt{Cambria} & 较新版本的微软 Office 预装数学字体 \\ +\texttt{Lucida Bright Math OT} & \texttt{Lucida Bright OT} & 须购买商业授权 \\ +\texttt{Minion Math} & \texttt{Minion Pro} & 须购买商业授权 \\ +\hline +\end{tabular} +\end{table} + +\section{文字装饰和强调}\label{sec:emphasize} + +强调文字的方法,或者是添加下划线等装饰物,或者是改变文字的字体。 + +\cmdindex{underline} +\LaTeX{} 定义了 \cmd{underline} 命令用来为文字添加下划线: +\begin{example} +An \underline{underlined} text. +\end{example} + +\pkgindex{ulem} +\cmdindex[ulem]{uline} +\cmd{underline} 命令生成下划线的样式不够灵活,不同的单词可能生成高低各异的下划线,并且无法换行。 +\pkg{ulem} 宏包提供了更灵活的解决方案,它提供的 \cmd{uline} 命令能够轻松生成自动换行的下划线: +\begin{example} +An example of \uline{some +long and underlined words.} +\end{example} + +\cmdindex{emph} +前一节介绍了 \cmd{emph} 命令,它将文字变为斜体以示强调,而如果在已强调的文字中嵌套使用 \cmd{emph} 命令, +命令内则使用直立体文字: +\begin{example} +Some \emph{emphasized words, +including \emph{double-emphasized} +words}, are shown here. +\end{example} + +\section{段落格式和间距}\label{sec:par-lengths} + +\subsection{长度和长度变量}\label{subsec:lengths} + +在前面的一些章节,我们已经见到一些长度和长度变量的用法。本节首先统一介绍长度和长度变量。 + +长度的数值 \Arg{length} 由数字和单位组成。常用的单位见表 \ref{tbl:length-unit}。 + +\def\unitindex#1{\index{#1@\texttt{#1} (\textit{长度单位})}} + +\begin{table}[htp] +\centering +\caption{\TeX{} / \LaTeX{} 中的长度单位}\label{tbl:length-unit} +\begin{tabular}{ll} + \hline + \texttt{pt}\unitindex{pt} & 点阵宽度,1/72.27\texttt{in} \\ + \texttt{bp}\unitindex{bp} & 点阵宽度,1/72\texttt{in} \\ + \texttt{in}\unitindex{in} & 英寸 \\ + \texttt{cm}\unitindex{cm} & 厘米 \\ + \texttt{mm}\unitindex{mm} & 毫米 \\ + \hline + \texttt{em}\unitindex{em} & 当前字号下大写字母 M 的宽度,常用于水平距离的设定 \\ + \texttt{ex}\unitindex{ex} & 当前字号下小写字母 x 的高度,常用于垂直距离的设定 \\ + \hline +\end{tabular} +\end{table} + +在一些情况下还会用到可伸缩的“弹性长度”,如 \texttt{12pt plus 2pt minus 3pt} +表示基础长度为 \texttt{12pt},可以伸展到 \texttt{14pt},也可以收缩到 \texttt{9pt}。 +也可只定义 \texttt{plus} 或者 \texttt{minus} 的部分,如 \texttt{0pt plus 5pt}。 + +长度的数值还可以用长度变量本身或其倍数来表达,如 \texttt{2.5}\cmd{parindent} 等。 + +\cmdindex{newlength,setlength,addtolength} +\LaTeX{} 预定义了大量的长度变量用于控制版面格式。如页面宽度和高度、首行缩进、段落间距等。 +如果需要自定义长度变量,需使用如下命令: +\begin{command} +\cmd{newlength}\marg*{\cmd{\Arg{length command}}} +\end{command} + +长度变量可以用 \cmd{setlength} 赋值,或用 \cmd{addtolength} 增加长度: +\begin{command} +\cmd{setlength}\marg*{\cmd{\Arg{length command}}}\marg{length} \\ +\cmd{addtolength}\marg*{\cmd{\Arg{length command}}}\marg{length} +\end{command} + +\subsection{行距}\label{subsec:linespread} + +\pinyinindex{hangju}{行距} +\cmdindex{linespread} +前文中我们提到过 \cmd{fontsize} 命令可以为字号设定对应的行距,但我们很少那么用。 +更常用的办法是在导言区使用 \cmd{linespread} 命令。 +\begin{command} +\cmd{linespread}\marg{factor} +\end{command} + +其中 \Arg{factor} 作用于基础行距而不是字号。缺省的基础行距是 1.2 倍字号大小(参考 \cmd{font\-size} 命令), +因此使用 \cmd{line\-spread}\marg*{1.5} 意味着最终行距为 1.8 倍的字号大小。 + +\cmdindex{selectfont} +如果不是在导言区全局修改,而想要局部地改变某个段落的行距,需要用 \cmd{select\-font} 命令使 \cmd{line\-spread} 命令的改动立即生效: +\begin{example} +{\linespread{2.0}\selectfont +The baseline skip is set to be +twice the normal baseline skip. +Pay attention to the \verb|\par| +command at the end. \par} + +In comparison, after the +curly brace has been closed, +everything is back to normal. +\end{example} + +\cmdindex{par} +字号的改变是即时生效的,而行距的改变直到文字\textbf{分段}时才生效。 +如果需要改变某一部分文字的行距,那么不能简单地将文字包含在花括号内。注意下面两个例子中 \cmd{par} 命令的位置,包括上一个例子的写法 +(\cmd{par} 相当于分段,见 \ref{subsec:spaces} 小节): +\begin{example} +{\Large Don't read this! + It is not true. + You can believe me!\par} +\end{example} + +\begin{example} +{\Large This is not true either. +But remember I am a liar.}\par +\end{example} + +\subsection{段落格式}\label{subsec:par-shape} + +以下长度分别为段落的左缩进、右缩进和首行缩进: +\begin{command} +\cmd{setlength}\marg*{\cmd{leftskip}}\marg{length} \\ +\cmd{setlength}\marg*{\cmd{rightskip}}\marg{length} \\ +\cmd{setlength}\marg*{\cmd{parindent}}\marg{length} +\end{command} + +它们和设置行距的命令一样,在分段时生效。 + +\cmdindex{indent,noindent} +控制段落缩进的命令为: + +\begin{command} +\cmd{indent} \\ +\cmd{noindent} +\end{command} + +\LaTeX{} 默认在段落开始时缩进,长度为用上述命令设置的 \cmd{parindent}。如果需要在某一段不缩进,可在段落开头使用 +\cmd{noindent} 命令。相反地,\cmd{indent} 命令强制开启一段首行缩进的段落。在段落开头使用多个 \cmd{indent} 命令可以累加缩进量。 + +\pkgindex{indentfirst} +\LaTeX{} 还默认\textbf{在 \cmd{chapter}、\cmd{section} 等章节标题命令之后的第一段不缩进}% +\footnote{\pkg{ctex} 宏包和文档类默认按照中文习惯保持标题后第一段的首行缩进。}。 +如果不习惯这种设定,可以调用 \pkg{indent\-first} 宏包,令第一段的首行缩进照常。 + +\cmdindex{parskip} +段落间的垂直间距为 \cmd{parskip},如设置段落间距在 \texttt{0.8ex} 到 \texttt{1.5ex} 变动: +\begin{verbatim} +\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} +\end{verbatim} + +\subsection{水平间距}\label{subsec:hspace} + +\cmdindex{hspace} +\LaTeX{} 默认为将单词之间的“空格”转化为水平间距。如果需要在文中手动插入额外的水平间距,可使用 \cmd{hspace} 命令: +\begin{example} +This\hspace{1.5cm}is a space +of 1.5 cm. +\end{example} + +\cmdindex{hspace*} +\cmd{hspace} 命令生成的水平间距如果位于一行的开头或末尾,则有可能因为断行而被舍弃。可使用 \cmd{hspace*} 命令代替 \cmd{hspace} 命令 +得到不会因断行而消失的水平间距。 + +\cmdindex{stretch,fill} +命令 \cmd{stretch}\marg{n} 生成一个特殊弹性长度,参数 \Arg{n} 为权重。它的基础长度为 0pt,但可以无限延伸,直到占满可用的空间。 +如果同一行内出现多个 \cmd{stretch}\marg{n},这一行的所有可用空间将按每个 \cmd{stretch} 命令给定的权重 \Arg{n} 进行分配。 + +命令 \cmd{fill} 相当于 \cmd{stretch}\marg*{1}% +\footnote{注意不要用 \texttt{1.5}\cmd{fill} 这样的用法,它生成的长度只有基础长度 0pt 而没有延伸部分。}。 + +\begin{example} +x\hspace{\stretch{1}} +x\hspace{\stretch{3}} +x\hspace{\fill}x +\end{example} + +\cmdindex{quad,qquad} +在正文中用 \cmd{hspace} 命令生成水平间距时,往往使用 \texttt{em} 作为单位,生成的间距随字号大小而变。 +我们在数学公式中见过 \cmd{quad} 和 \cmd{qquad} 命令,它们也可以用于文本中,分别相当于 \cmd{hspace}\marg*{1em} 和 \cmd{hspace}\marg*{2em}: + +\begin{example} +{\Large big\hspace{1em}y}\\ +{\Large big\quad y}\\ +nor\hspace{2em}mal\\ +nor\qquad mal\\ +{\tiny tin\hspace{1em}y}\\ +{\tiny tin\quad y} +\end{example} + +\subsection{垂直间距}\label{subsec:vspace} + +在页面中,段落、章节标题、行间公式、列表、浮动体等元素之间的间距是 \LaTeX{} 预设的。比如 \cmd{parskip},默认设置为 \texttt{0pt plus 1pt}。 + +\cmdindex{vspace,vspace*} +如果我们想要人为地增加段落之间的垂直间距,可以在两个段落之间的位置使用 \cmd{vspace} 命令: +\begin{example} +A paragraph. + +\vspace{2ex} +Another paragraph. +\end{example} + +\cmd{vspace} 命令生成的垂直间距在一页的顶端或底端可能被“吞掉”,类似 \cmd{hspace} 在一行的开头和末尾那样。 +对应地,\cmd{vspace*} 命令产生不会因断页而消失的垂直间距。\cmd{vspace} 也可用 \cmd{stretch} 设置无限延伸的垂直长度。 + +\index{\@\crcmd{} (\textit{换行})} +在段落内的两行之间增加垂直间距,一般通过给断行命令 \crcmd{} 加可选参数,如 \crcmd\texttt{[6pt]} 或 \crcmd\texttt{*[6pt]}。 +\cmd{vspace} 也可以在段落内使用,区别在于 \cmd{vspace} 只引入垂直间距而不断行: +\begin{example} +Use command \verb|\vspace{12pt}| +to add \vspace{12pt} some spaces +between lines in a paragraph. + +Or you can use \verb|\\[12pt]| +to \\[12pt] add vertical space, +but it also breaks the line. +\end{example} + +\cmdindex{bigskip,medskip,smallskip} +另外 \LaTeX{} 还提供了\cmd{bigskip}, \cmd{medskip}, \cmd{smallskip} 来增加预定义长度的垂直间距。 +\begin{example} +\parbox[t]{3em}{TeX\par TeX} +\parbox[t]{3em}{TeX\par\smallskip TeX} +\parbox[t]{3em}{TeX\par\medskip TeX} +\parbox[t]{3em}{TeX\par\bigskip TeX} +\end{example} + +\section{页面和分栏}\label{sec:page-columns} + +我们不妨回顾一下第一章介绍的文档类属性。\LaTeX{} 允许用户通过为文档类指定选项来控制纸张的大小(见 \ref{subsec:classes} 小节), +包括 \texttt{a4paper}、\texttt{letterpaper}等等,并配合字号设置了适合的页边距。 + +\cmdindex{textheight,textwidth} +控制页边距的参数由图 \ref{fig:layouts} 里给出的各种长度变量控制。 +可以用 \cmd{setlength} 命令修改这些长度变量,以达到调节页面尺寸和边距的作用; +反之也可以利用这些长度变量来决定排版内容的尺寸,如在 \env{tabularx} 环境或 \cmd{include\-graphics} 命令的参数里, +设置图片或表格的宽度为 0.8\cmd{textwidth}。 + +\begin{figure}[!p] +\centering +\layoutpicture* +\caption{本文档的页面参数示意图(奇数页;由 \pkg{layout} 宏包生成)。} \label{fig:layouts} +\end{figure} + +页边距等比较直观的参数则必须间接设置。我们根据图 \ref{fig:layouts} 将各个方向的页边距计算公式给出(以奇数页为例): +\begin{align*} +\text{\Arg{left-margin}} &= \text{\ttfamily 1in} + + \text{\cmd{hoffset}} + + \text{\cmd{oddsidemargin}} \\ +\text{\Arg{right-margin}} &= \text{\cmd{paperwidth}} + - \text{\Arg{left-margin}} + - \text{\cmd{textwidth}} \\ +\text{\Arg{top-margin}} &= \text{\ttfamily 1in} + + \text{\cmd{voffset}} + + \text{\cmd{topmargin}} + + \text{\cmd{headheight}} + + \text{\cmd{headsep}} \\ +\text{\Arg{bottom-margin}} &= \text{\cmd{paperheight}} + - \text{\Arg{top-margin}} + - \text{\cmd{textheight}} +\end{align*} +如果需要设置合适的 \Arg{left-margin} 和 \Arg{right-margin},就要通过上述方程组把 \cmd{odd\-sidemargin} 和 \cmd{text\-width} 等参数解出来! + +幸好 \pkg{geometry} 宏包提供了设置页边距等参数的简便方法,能够帮我们完成背后繁杂的计算。 + +\subsection{利用 \pkg{geometry} 宏包设置页面参数}\label{subsec:geometry} + +\pkgindex{geometry} +\pinyinindex{xuanxiang}{选项(宏包/文档类)} +\pkg{geometry} 宏包的调用方式类似于 \pkg{graphicx},在 \texttt{latex} + \texttt{dvipdfmx} 命令下需要指定选项 \texttt{dvipdfm} +(注意这里不是 \texttt{dvipdfmx});\texttt{pdflatex} 和 \texttt{xelatex} 编译命令下不需要。 + +\cmdindex[geometry]{geometry} +你既可以调用 \pkg{geometry} 宏包然后用其提供的 \cmd{geometry} 命令设置页面参数: +\begin{command} +\cmd{usepackage}\marg*{geometry} \\ +\cmd{geometry}\marg{geometry-settings} +\end{command} + +也可以将参数指定为宏包的选项: +\begin{command} +\cmd{usepackage}\oarg{geometry-settings}\marg*{geometry} +\end{command} + +其中 \Arg{geometry-settings} 多以 \Arg{key}=\Arg{value} 的形式组织。 + +比如,符合 Microsoft Word 习惯的页面设定是 A4 纸张,上下边距 1 英寸,左右边距 1.25 英寸,于是我们可以通过如下两种等效的方式之一设定页边距: +\begin{verbatim} +\usepackage[left=1.25in,right=1.25in,% + top=1in,bottom=1in]{geometry} +% or like this: +\usepackage[hmargin=1.25in,vmargin=1in]{geometry} +\end{verbatim} + +又比如,需要设定周围的边距一致为1.25英寸,可以用更简单的语法: +\begin{verbatim} +\usepackage[margin=1.25in]{geometry} +\end{verbatim} + +对于书籍等双面文档,习惯上奇数页右边、偶数页左边留出较多的页边距,而书脊一侧的奇数页左边、偶数页右边页边距较少。我们可以这样设定: +\begin{verbatim} +\usepackage[inner=1in,outer=1.25in]{geometry} +\end{verbatim} + +\pkg{geometry} 宏包本身也能够修改纸张大小、页眉页脚高度、边注宽度等等参数。更详细的用法不再赘述, +感兴趣的用户可查阅 \pkg{geometry} 宏包的帮助文档。 + +\subsection{页面内容的垂直对齐}\label{subsec:raggedbottom} + +\LaTeX{} 默认将页面内容在垂直方向分散对齐。对于有大量图表的文档,许多时候想要做到排版匀称的页面很困难, +垂直分散对齐会造成某些页面的垂直间距过宽,还可能报大量的 \texttt{Underfull} \cmd{vbox} 消息。 +\LaTeX{} 还提供了另一种策略:将页面内容向顶部对齐,给底部留出高度不一的空白。 + +\cmdindex{raggedbottom, flushbottom} +以下命令分别令页面在垂直方向向顶部对齐 / 分散对齐: +\begin{command} +\cmd{raggedbottom} \\ +\cmd{flushbottom} +\end{command} + +\subsection{分栏}\label{subsec:columns} + +\cmdindex{onecolumn,twocolumn} +\LaTeX{} 支持简单的单栏或双栏排版。标准文档类的全局选项 \texttt{onecolumn}、\texttt{twocolumn} +可控制全文分单栏或双栏排版。\LaTeX{} 也提供了切换单/双栏排版的命令: +\begin{command} +\cmd{onecolumn} \\ +\cmd{twocolumn}\oarg{one-column top material} +\end{command} + +\cmd{twocolumn} 支持带一个可选参数,用于排版双栏之上的一部分单栏内容。 + +\cmdindex{newpage,clearpage} +切换单/双栏排版时总是会另起一页(\cmd{clearpage})。 +在双栏模式下使用 \cmd{newpage} 会换栏而不是换页;\cmd{clearpage} 则能够换页。 + +\cmdindex{columnwidth,columnsep,columnseprule} +双栏排版时每一栏的宽度为 \cmd{columnwidth},它由 \cmd{textwidth} 减去 \cmd{columnsep} 的差除以 2 得到。 +两栏之间还有一道竖线,宽度为 \cmd{columnseprule},默认为零,也就是看不到竖线。 + +\pkgindex{multicol} +\envindex[multicol]{multicols} +一个比较好用的分栏解决方案是 \pkg{multicol},它提供了简单的 \env{multicols} 环境 +(注意不要写成 \env{multicol} 环境)自动产生分栏,如以下环境将内容分为 3 栏: +\begin{verbatim} +\begin{multicols}{3} +... +\end{multicols} +\end{verbatim} + +\pinyinindex{fudongti}{浮动体} +\envindex{table,figure} +\pkgindex{float} +\pkg{multicol} 宏包能够在一页之中切换单栏/多栏,也能处理跨页的分栏,且各栏的高度分布平衡。但代价是% +\textbf{在 \env{multicols} 环境中无法正常使用 \env{table} 和 \env{figure} 等浮动体环境},它会直接让浮动体丢失。 +\env{multicols} 环境中只能用跨栏的 \env{table*} 和 \env{figure*} 环境,或者用 \pkg{float} 宏包提供的 \texttt{H} 参数固定浮动体的位置。 + +\section{页眉页脚}\label{sec:pagestyle} + +\subsection{基本的页眉页脚样式}\label{subsec:basic-pagesyle} + +\cmdindex{pagestyle,thispagestyle} +\pinyinindex{yemei}{页眉} +\pinyinindex{yejiao}{页脚} +\LaTeX{} 中提供了命令 \cmd{pagestyle} 来修改页眉页脚的样式: +\begin{command} +\cmd{pagestyle}\marg{page-style} +\end{command} + +命令 \cmd{thispagestyle} 只影响当页的页眉页脚样式: +\begin{command} +\cmd{thispagestyle}\marg{page-style} +\end{command} + +\Arg{page-style} 参数为样式的名称,在 \LaTeX{} 里预定义了四类样式,见表 \ref{tbl:pagestyle}。 + +\begin{table}[htp] +\centering +\caption{\LaTeX{} 预定义的页眉页脚样式}\label{tbl:pagestyle} +\begin{tabular}{lp{30em}} + \hline + \texttt{empty} & 页眉页脚为空 \\ + \texttt{plain} & 页眉为空,页脚为页码。(\cls{article} 和 \cls{report} 文档类默认;\cls{book} 文档类的每章第一页也为 plain 格式) \\ + \hline + \texttt{headings} & 页眉为章节标题和页码,页脚为空。(\cls{book} 文档类默认) \\ + \texttt{myheadings} & 页眉为页码及 \cmd{markboth} 和 \cmd{markright} 命令手动指定的内容,页脚为空。\\ + \hline +\end{tabular} +\end{table} + +\clsindex{article,report,book} +其中 \texttt{headings} 的情况较为复杂: +\begin{description} + \item[\cls{article} 文档类,\texttt{twoside} 选项] 偶数页为页码和节标题,奇数页为小节标题和页码; + \item[\cls{article} 文档类,\texttt{oneside} 选项] 页眉为节标题和页码; + \item[\cls{book/report} 文档类,\texttt{twoside} 选项] 偶数页为页码和章标题,奇数页为节标题和页码; + \item[\cls{book/report} 文档类,\texttt{oneside} 选项] 页眉为章标题和页码。 +\end{description} + +\cmdindex{pagenumbering} +\cmd{pagenumbering} 命令令我们能够改变页眉页脚中的页码样式: +\begin{command} +\cmd{pagenumbering}\marg{style} +\end{command} + +\cmdindex{frontmatter,mainmatter} +\Arg{style} 为页码样式,默认为 \texttt{arabic}(阿拉伯数字),还可修改为 \texttt{roman}(小写罗马数字)、 +\texttt{Roman}(大写罗马数字)等。注意使用 \cmd{pagenumbering} 命令后会将页码重置为 1。\cls{book} 文档类的 \cmd{front\-matter} 和 \cmd{main\-matter} 内部就使用了 \cmd{page\-numbering} 命令切换页码样式。 +对页码格式的详细说明见 \ref{sec:counters} 节。 + +\subsection{手动更改页眉页脚的内容}\label{subsec:marks} + +\cmdindex{markright,markboth} +对于 headings 或者 myheadings 样式,\LaTeX{} 允许用户使用命令手动修改页眉上面的内容, +特别是因为使用了 \cmd{chapter*} 等命令而无法自动生成页眉页脚的情况: +\begin{command} +\cmd{markright}\marg{right-mark}\\ +\cmd{markboth}\marg{left-mark}\marg{right-mark} +\end{command} + +在双面排版、\texttt{headings / myheadings} 页眉页脚样式下,\Arg{left-mark} 和 \Arg{right-mark} 的内容分别预期出现在左页(偶数页)和右页(奇数页)。 +事实上 \cmd{chapter} 和 \cmd{section} 等章节命令内部也使用 \cmd{mark\-both} 或者 \cmd{mark\-right} 生成页眉。 + +\LaTeX{} 默认将页眉的内容都转为大写字母。如果需要保持字母的大小写,可以尝试以下代码 +(\cmd{\renewcommand} 命令的用法详见 \ref{subsec:newcmd} 节)% +\footnote{但是这不能改变页眉的斜体样式(\cmd{slshape}),斜体是定义在 \texttt{headings} 样式里的。 +如果不喜欢斜体,可在 \cmd{mark\-both} 等命令的参数里先使用 \cmd{normal\-font},再使用想要的字体样式命令, +或直接尝试使用 \pkg{fancyhdr} 宏包。}: +\begin{verbatim} +\renewcommand\chaptermark[1]{% + \markboth{Chapter \thechapter\quad #1}{}} +\renewcommand\sectionmark[1]{% + \markright{\thesection\quad #1}} +\end{verbatim} + +其中 \cmd{thechapter}、\cmd{thesection} 等命令为章节计数器的数值(详见 \ref{sec:counters} 节)。以上代码适用于 \cls{report/book} 文档类。 +对于 \cls{article} 文档类,与两个页眉相关的命令分别为 \cmd{sec\-tion\-mark} 和 \cmd{sub\-sec\-tion\-mark}。 + +\subsection{\pkg{fancyhdr} 宏包}\label{subsec:fancyhdr} + +\pkgindex{fancyhdr} +\pkg{fancyhdr} 宏包改善了页眉页脚样式的定义方式,允许我们将内容自由安置在页眉和页脚的左、中、右三个位置,还为页眉和页脚各加了一条横线。 + +\cmdindex[fancyhdr]{fancyhead,fancyfoot,fancyhf} +\pkg{fancyhdr} 自定义了样式名称 \texttt{fancy}。使用 \pkg{fancyhdr} 宏包定义页眉页脚之前,通常先用 \cmd{page\-style}\marg*{fancy} 调用这个样式。 +在 \pkg{fancyhdr} 中定义页眉页脚的命令为: +\begin{command} +\cmd{fancyhf}\oarg{position}\marg*{\ldots}\\ +\cmd{fancyhead}\oarg{position}\marg*{\ldots}\\ +\cmd{fancyfoot}\oarg{position}\marg*{\ldots} +\end{command} +其中 \Arg{position} 为 L(左)/C(中)/R(右) 以及与 O(奇数页)/E(偶数页)字母的组合。\cmd{fancyhf} 用于同时定义页眉和页脚, +习惯上使用 \cmd{fancyhf}\marg*{} 来清空页眉页脚的设置。 + +源代码 \ref{code:fancyhdr} 给出了 \pkg{fancyhdr} 基础用法的一个示例,效果为将章节标题放在和 headings 一致的位置,但使用加粗格式; +页码都放在页脚正中;修改横线宽度,“去掉”页脚的横线。 + +\begin{sourcecode}[htp] + \begin{Verbatim} + % 在导言区使用此代码 + \usepackage{fancyhdr} + \pagestyle{fancy} + \renewcommand{\chaptermark}[1]{\markboth{#1}{}} + \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} + \fancyhf{} + \fancyfoot[C]{\bfseries\thepage} + \fancyhead[LO]{\bfseries\rightmark} + \fancyhead[RE]{\bfseries\leftmark} + \renewcommand{\headrulewidth}{0.4pt} % 注意不用 \setlength + \renewcommand{\footrulewidth}{0pt} + \end{Verbatim} + \caption{\pkg{fancyhdr} 宏包的使用方法示例。}\label{code:fancyhdr} +\end{sourcecode} + +\cmdindex[fancyhdr]{fancypagestyle} +\pkg{fancyhdr} 还支持用 \cmd{fancy\-page\-style} 为自定义的页眉页脚样式命名,或者重新定义已有的样式如 \texttt{plain} 等: +\begin{verbatim} +% 自定义 myfancy 样式 +\fancypagestyle{myfancy}{% + \fancyhf{} + \fancyhead{...} + \fancyfoot{...} +} +% 使用样式 +\pagestyle{myfancy} +\end{verbatim} + +更多用法请参考 \pkg{fancyhdr} 宏包的帮助文档。 + + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.06.spec.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.06.spec.tex new file mode 100644 index 00000000000..4db62146067 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.06.spec.tex @@ -0,0 +1,680 @@ +\chapter{特色工具和功能}\label{chap:spec} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +本章介绍一些特色的 \LaTeX{} 辅助功能。前两个功能 \hologo{BibTeX} 和 makeindex 依靠一些辅助程序自动生成参考文献、索引等; +之后的使用颜色、超链接等则令我们生成美观易用的电子文档。 +\end{intro} + +\section{参考文献和 \hologo{BibTeX} 工具}\label{sec:bib} + +\subsection{基本的参考文献和引用}\label{subsec:bib-basics} + +\pinyinindex{cankaowenxian}{参考文献} +\LaTeX{} 提供的参考文献和引用方式比较原始,需要用户自行书写参考文献列表(包括格式), +因此较难直接使用。相关的命令我们只作最简单的介绍。 + +\cmdindex{cite} +\LaTeX{} 提供了最基本的 \cmd{cite} 命令用于在正文中引用参考文献: +\begin{command} +\cmd{cite}\marg{citation} +\end{command} + +\Arg{citation} 为引用的参考文献的标签,类似 \cmd{ref} 里的参数;\cmd{cite} 带一个可选参数,为引用的编号后加上额外的内容, +如 \cmd{cite}\oarg*{page 22}\marg*{Paper2013} 可能得到形如 [13, page 22] 这样的引用。 + +\envindex{thebibliography} +\cmdindex{bibitem} +参考文献由 \env{thebibliography} 环境包裹。每条参考文献由 \cmd{bibitem} 开头,其后是参考文献本身的内容: +\begin{command} +\cmd{begin}\marg*{thebibliography}\marg{widest label} \\ +\quad \cmd{bibitem}\oarg{item number}\marg{citation} ...\\ +\cmd{end}\marg*{thebibliography} +\end{command} +其中 \Arg{citation} 是 \cmd{cite} 使用的文献标签, +\Arg{item number} 自定义参考文献的序号,如果省略,则按自然排序给定序号。 +\Arg{widest label} 用以限制参考文献序号的宽度,如 99 意味着不超过两位数字。通常设定为与参考文献的数目一致。 + +\env{thebibliography} 环境自动生成不带编号的一节(\cls{article} 文档类)或一章(\cls{report} / \cls{book} 文档类)。 +在 \cls{article} 文档类的节标题默认为 ``Reference''{},而在 \cls{report / book} 文档类 +的章标题默认为 ``Bibliography''{}。用户可通过 \ref{sec:latex-settings} 节给出的方法定制参考文献的标题。 + +以下为一个使用 \env{the\-biblio\-graphy} 排版参考文献的例子: +\begin{verbatim} +\documentclass{article} +\begin{document} +\section{Introduction} +Partl~\cite{germenTeX} has proposed that \ldots + +\begin{thebibliography}{99} +\bibitem{germenTeX} H.~Partl: \emph{German \TeX}, + TUGboat Volume~9, Issue~1 (1988) +\end{thebibliography} +\end{document} +\end{verbatim} + +\subsection{\hologo{BibTeX} 数据库}\label{subsec:bibtex-data} + +\index{bibtexdb@\protect\hologo{BibTeX} 数据库} +\hologo{BibTeX} 是最为流行的参考文献数据组织格式之一。它的出现让我们摆脱手写参考文献条目的麻烦。我们还可以通过参考文献样式的支持, +让同一份 \hologo{BibTeX} 数据库生成不同样式的参考文献列表。 + +\hologo{BibTeX} 数据库以 \texttt{.bib} 作为扩展名,其内容是若干个文献条目,每个条目的格式为: +\begin{command} +\texttt @\Arg{type}\texttt\{\Arg{citation}, \\ +\qquad\Arg{key1} = \marg{value1}, \\ +\qquad\Arg{key2} = \marg{value2}, \\ +\qquad\ldots\\ +\texttt\} +\end{command} + +其中 \Arg{type} 为文献的类别,如 \texttt{article} 为学术论文,\texttt{book} 为书籍,\texttt{in\-collection} 为论文集中的某一篇,等等。 +\Arg{citation} 为 \cmd{cite} 命令使用的文献标签。在 \Arg{citation} 之后为条目里的各个字段,以 \Arg{key} = \marg{value} 的形式组织。 + +我们在此简单列举学术论文里使用较多的 \hologo{BibTeX} 文献条目类别: +\begin{description} + \item[\texttt{article}] 学术论文,必需字段有 author, title, journal, year; 可选字段包括 volume, number, pages, doi 等; + \item[\texttt{book}] 书籍,必需字段有 author/editor, title, publisher, year; 可选字段包括 volume/number, series, address 等; + \item[\texttt{incollection}] 论文集中的一篇,必需字段有 author, title, booktitle, publisher, year; 可选字段包括 editor, volume/number, chapter, pages, address 等; + \item[\texttt{inbook}] 书中的一章,必需字段有 author/editor, title, chapter/pages, publisher, year; 可选字段包括 volume/number, series, address 等。 +\end{description} + +例如 \texttt{article} 类别的参考文献数据条目写法如下: +\begin{verbatim} +@article{Alice13, + title = {Demostration of bibliography items}, + author = {Alice Axford and Bob Birkin and Charlie Copper and Danny Dannford}, + year = {2013}, + month = {Mar}, + journal = {Journal of \TeX perts}, + volume = {36}, + number = {7}, + pages = {114-120}} +\end{verbatim} +所有类别的文献条目格式请参考 \CTAN|biblio/bibtex/base/btxdoc.pdf|。 + +多数时候,我们无需自己手写 \hologo{BibTeX} 文献条目。从 Google Scholar 或者期刊/数据库的网站上都能够导出 \hologo{BibTeX} 文献条目, +老牌的文献管理软件 EndNote 也支持生成 \hologo{BibTeX} 格式的数据库。开源软件 JabRef 甚至支持 \hologo{BibTeX} 文献条目的导入、导出和管理。 + +\subsection{\hologo{BibTeX} 样式}\label{subsec:bibtex-style} + +参考文献的写法在不同文献里千差万别,包括作者、标题、年份等各项的顺序和字体样式、文献在列表中的排序规则等。 +\hologo{BibTeX} 用样式(style)来管理参考文献的写法。\hologo{BibTeX} 提供了几个预定义的样式, +如 \texttt{plain}, \texttt{unsrt}, \texttt{alpha} 等。 +如果使用期刊模板的话,可能会提供自用的样式。样式文件以 \texttt{.bst} 为扩展名。 + +\cmdindex{bibliographystyle} +使用样式文件的方法是在源代码内(一般在导言区)使用 \cmd{biblio\-graphy\-style} 命令: +\begin{command} +\cmd{bibliographystyle}\marg{bst-name} +\end{command} +这里 \Arg{bst-name} 为 \texttt{.bst} 样式文件的名称,\textbf{不要带 \texttt{.bst} 扩展名}。 + +我们以 \ref{subsec:bibtex-data} 小节给出的数据条目为例,使用 \cmd{biblio\-graphy\-style} 命令选择不同的参考文献样式, +效果大致如表 \ref{tbl:bibtex-style} 所示。 + +\begin{table}[htp] +\caption{\hologo{BibTeX} 样式的排版效果}\label{tbl:bibtex-style} +\hrule +\begin{trivlist}\item\relax +\textbf{plain}\\{} +[1] Alice Axford, Bob Birkin, Charlie Copper, and Danny Dannford. +\newblock Demostration of bibliography items. +\newblock {\em Journal of \TeX perts}, 36(7):114--120, Mar 2013. + +\medskip +\textbf{alpha}\\{} +[ABCD13] Alice Axford, Bob Birkin, Charlie Copper, and Danny Dannford. +\newblock Demostration of bibliography items. +\newblock {\em Journal of \TeX perts}, 36(7):114--120, Mar 2013. + +\medskip +\textbf{abbrv}\\{} +[1] A.~Axford, B.~Birkin, C.~Copper, and D.~Dannford. +\newblock Demostration of bibliography items. +\newblock {\em Journal of \TeX perts}, 36(7):114--120, Mar 2013. + +\medskip +\textbf{amsplain}(\AmS{} 文档类 \textsf{amsart} 等配套的样式)\\{} +[1] Alice Axford, Bob Birkin, Charlie Copper, and Danny Dannford, \emph{Demostration of bibliography + items}, Journal of \TeX perts \textbf{36} (2013), no.~7, 114--120. + +\medskip +\textbf{elsarticle-num}(Elsevier 提供的 \textsf{elsarticle} 文档类配套的样式)\\{} +[1] A.~Axford, B.~Birkin, C.~Copper, D.~Dannford, Demostration of bibliography items, + Journal of \TeX perts 36~(7) (2013) 114--120. + +\medskip +\textbf{IEEEtran}(\textsf{IEEEtran} 模板文档类配套的样式)\\{} +[1] A.~Axford, B.~Birkin, C.~Copper, and D.~Dannford, ``Demostration of + bibliography items,'' \emph{Journal of \TeX perts}, vol.~36, no.~7, pp. + 114--120, Mar 2013. +\end{trivlist} +\hrule +\end{table} + +\subsection{使用 \hologo{BibTeX} 排版参考文献}\label{subsec:bibtex-use} + +\index{bibtex@\protect\hologo{BibTeX} 工具} +现在我们来看如何利用 \hologo{BibTeX} 数据库生成参考文献和引用。 + +第一步:准备一份 \hologo{BibTeX} 数据库,假设数据库文件名为 \texttt{books.bib}, +和 \LaTeX{} 源代码\textbf{一般位于同一个目录下}。 + +第二步:在源代码中添加必要的命令。假设源代码名为 \texttt{demo.tex}(见源代码 \ref{code:bibtex-demo})。 +\begin{enumerate} +\item \cmdindex{bibliographystyle} +首先需要使用命令 \cmd{bibliographystyle} 设定参考文献的格式。 + +\item \cmdindex{cite,nocite} +其次,在正文中引用参考文献。\hologo{BibTeX} 程序在生成参考文献列表的时候,通常只列出用了 \cmd{cite} 命令引用的那些。 +如果需要列出未被引用的文献,则需要 \cmd{nocite}\marg{citation} 命令;而 \cmd{nocite}\marg*{*} 则让所有未被引用的文献都列出。 + +\item \cmdindex{bibliography} +再次,在需要列出参考文献的位置,使用 \cmd{biblio\-graphy} 命令代替 \env{the\-biblio\-graphy} 环境: +\begin{command} +\cmd{bibliography}\marg{bib-name} +\end{command} + +其中 \Arg{bib-name} 是 \hologo{BibTeX} 数据库的文件名,\textbf{不要带 \texttt{.bib} 扩展名}。 +\end{enumerate} + +\begin{sourcecode}[htp] +\begin{Verbatim} +\documentclass{article} +\bibliographystyle{plain} +\begin{document} +\section{Some words} +Some excellent books, for example, \cite{citation1} +and \cite{citation2} \ldots + +\bibliography{books} +\end{document} +\end{Verbatim} +\caption{利用 \texttt{books.bib} 生成参考文献的源代码 \texttt{demo.tex}。}\label{code:bibtex-demo} +\end{sourcecode} + +注意:\cmd{bibliographystyle} 和 \cmd{bibliography} 命令缺一不可,没有这两个命令,使用 \hologo{BibTeX} 生成参考文献列表的时候会报错。 + +第三步:写好了以上两个文件之后,我们就可以开始编译了。 +\begin{enumerate} + \item 首先使用 \texttt{pdflatex} 或 \texttt{xelatex} 等命令编译 \LaTeX{} 源代码 \texttt{demo.tex}; + \item 接下来用 \texttt{bibtex} 命令处理 \texttt{demo.aux} 辅助文件记录的参考文献格式、引用条目等信息。 + \texttt{bibtex} 命令处理完毕后会生成 \texttt{demo.bbl} 文件,内容就是一个 \env{thebibliography} 环境; + \item 再使用 \texttt{pdflatex} 或 \texttt{xelatex} 等命令把源代码 \texttt{demo.tex} 编译\textbf{两遍},读入参考文献并正确生成引用。 +\end{enumerate} + +整个过程使用的命令如下(可以略去扩展名): +\begin{verbatim} +xelatex demo +bibtex demo +xelatex demo +xelatex demo +\end{verbatim} + +使用 \texttt{latex + dvipdfmx} 命令编译时,则 \texttt{dvipdfmx} 命令放在最后,相当于先后使用 +\texttt{latex}, \texttt{bibtex}, \texttt{latex}, \texttt{latex}, \texttt{dvipdfmx}。 + +\subsection{\pkg{natbib} 宏包}\label{subsec:natbib} + +\pkgindex{natbib} +时下许多学术期刊比较喜欢使用人名——年份的引用方式,形如(\emph{Axford et~al.}, 2013)。 +\pkg{natbib} 宏包提供了对这种“自然”引用方式的处理。 + +\cmdindex[natbib]{citep,citet} +除了 \cmd{cite} 之外,\pkg{natbib} 宏包在正文中支持两种引用方式: +\begin{command} +\cmd{citep}\marg{citation} \\ +\cmd{citet}\marg{citation} +\end{command} + +它们分别生成形如(\emph{Axford et~al.}, 2013) 和 \emph{Axford et~al.} (2013) 的人名——年份引用。 +正确排版人名——年份引用还依赖于特定的 \hologo{BibTeX} 样式。\pkg{natbib} 提供了与 \LaTeX{} 预定义样式相对应的几个样式, +包括 \texttt{plainnat}、\texttt{abbrvnat} 和 \texttt{unsrtnat}。学术论文模板是否支持 \pkg{natbib},需要参考其帮助文档。 + +\pkg{natbib} 宏包同样也支持数字引用,并且支持将引用的序号压缩,例如: +\begin{verbatim} +\usepackage[numbers,sort&compress]{natbib} +\end{verbatim} +调用 \pkg{natbib} 宏包时指定以上选项后,连续引用多篇文献时,会生成形如 (3--7) 的引用而不是 (3, 4, 5, 6, 7)。 + +\pkg{natbib} 宏包还有更多选项和用法,比如默认的引用是用小括号包裹的,可指定 \texttt{square} 选项改为中括号; +再比如 \cmd{citep} 命令也支持可选参数,为引用前后都添加额外内容。这里不再赘述,请参考 \pkg{natbib} 宏包的帮助文档。 + + +\subsection{\pkg{biblatex} 宏包}\label{subsec:biblatex} + +\pkgindex{biblatex} +本节的末尾简单介绍一下基于 \pkg{biblatex} 宏包排版参考文献的方式。 +\pkg{biblatex} 宏包是一套基于 \LaTeX{} 宏命令的参考文献解决方案,提供了便捷的格式控制和强大的排序、分类、筛选、多文献表等功能。 +\pkg{biblatex} 宏包也因其对 UTF-8 和中文参考文献的良好支持,被国内较多 \LaTeX{} 模板采用。 + +基于 \pkg{biblatex} 宏包的方式与基于 \hologo{BibTeX} 的传统方式有一定区别,下面从文档结构和命令、编译方式、样式选择等方面逐一介绍: + +\subsubsection{文档结构和 \pkg{biblatex} 相关命令} + +\cmdindex[biblatex]{addbibresource,printbibliography} +\begin{enumerate} + \item 首先是在导言区调用 \pkg{biblatex} 宏包。宏包支持以 \Arg{key}=\Arg{value} 形式指定选项,包括参考文献样式 style、参考文献著录排序的规则 sorting 等。 + \item 接着在导言区使用 \cmd{addbibresource} 命令为 \pkg{biblatex} 引入参考文献数据库。与基于 \hologo{BibTeX} 的传统方式不同的是,这里需要写完整的文件名。 + \item 在正文中使用 \cmd{cite} 命令引用参考文献。除此之外还可以使用丰富的命令达到不同的引用效果,如 \cmd{citeauthor} 和 \cmd{citeyear} 分别单独引用作者和年份,\cmd{textcite} 和 \cmd{parencite} 分别类似 \pkg{natbib} 宏包提供的 \cmd{citet} 和 \cmd{citep} 命令,以及脚注式引用 \cmd{footcite} 等。 + \item 最后在需要排版参考文献的位置使用命令 \cmd{printbibliography}。 +\end{enumerate} + +\begin{sourcecode}[htp] +\begin{Verbatim} +% File: egbibdata.bib +@book{caimin2006, + title = {UML基础和Rose建模教程}, + address = {北京}, + author = {蔡敏 and 徐慧慧 and 黄柄强}, + publisher = {人民邮电出版社}, + year = {2006}, + month = {1} +} + +% File: demo.tex +\documentclass{ctexart} +% 使用符合 GB/T 7714-2015 规范的参考文献样式 +\usepackage[style=gb7714-2015]{biblatex} +% 注意加 .bib 扩展名 +\addbibresource{egbibdata.bib} + +\begin{document} + +见文献\cite{caimin2006}。 + +\printbibliography +\end{document} +\end{Verbatim} +\caption{应用 \pkg{biblatex} 的示例 egbibdata.bib 和 demo.tex。} +\end{sourcecode} + +\subsubsection{编译方式} + +\index{biber} +与基于 \hologo{BibTeX} 的传统方式不同的是,\pkg{biblatex} 宏包使用 \texttt{biber} 程序处理参考文献。因此上述文档的编译步骤为: + +\begin{verbatim} +xelatex demo +biber demo +xelatex demo +xelatex demo +\end{verbatim} + +\subsubsection{\pkg{biblatex} 样式和其它选项} + +\pkg{biblatex} 使用的参考文献样式分为著录样式(bibliography style)和引用样式(citation style),分别以 \texttt{.bbx} 和 \texttt{.cbx} 为扩展名。参考文献的样式在调用宏包时使用 \texttt{style} 选项指定,或者使用 \texttt{bibstyle} 或 \texttt{citestyle} 分别指定: +\begin{verbatim} +% 同时调用 gb7714-2015.bbx 和 gb7714-2015.cbx +\usepackage[style=gb7714-2015]{biblatex} +% 著录样式调用 gb7714-2015.bbx,引用样式调用 biblatex 宏包自带的 authoryear +\usepackage[bibstyle=gb7714-2015,citestyle=authoryear]{biblatex} +\end{verbatim} + +以下总结一些常用的参考文献样式,除 \pkg{biblatex} 宏包自带的样式外,许多样式以单独的宏包在发行版内发布。 + +\begin{description} + \item[\texttt{authoryear}] + \pkg{biblatex} 自带样式,类似 \pkg{natbib} 默认的引用样式效果。 + \item[\texttt{authortitle}] + \pkg{biblatex} 自带样式,采用作者-题名(shorttitle 字段)的引用样式。 + \item[\texttt{verbose}] + \pkg{biblatex} 自带样式,引用样式中包含作者、题名、书名、页码等字段的信息。 + \item[\texttt{alphabetic}] + \pkg{biblatex} 自带样式,著录样式与 \hologo{BibTeX} 的 \texttt{alpha} 样式类似。 + \item[\texttt{trad-alpha}] + \pkg{biblatex-trad} 样式包,移植自 \hologo{BibTeX} 默认的 \texttt{alpha} 样式。另外还包括 \texttt{trad-abbrv}、\texttt{trad-plain} 和 \texttt{trad-unsrt}。 + \item[\texttt{gb7714-2015}] + 符合中文文献著录标准 GB/T 7714--2015 的样式,著录按顺序编码排版。另外还包括按作者-年份顺序排版著录的样式 \texttt{gb7714-2015ay}。 + \item[\texttt{caspervector}] + 以中文文献著录标准 GB/T 7714--2015 为基础的一个样式。 + \item[\texttt{ieee}] + 兼容 \pkg{IEEEtran} 风格的样式,著录按顺序编码排版。另外还包括按作者-年份顺序排版著录的样式 \texttt{ieee-alphabetic}。 +\end{description} + +\section{索引和 makeindex 工具}\label{sec:index} + +\pinyinindex{suoyin}{索引} +\index{makeindex@makeindex 工具} +书籍和大文档通常用索引来归纳关键词,方便用户查阅。\LaTeX{} 借助配套的 makeindex 程序完成对索引的排版。 + +\subsection{使用 makeindex 工具的方法}\label{subsec:makeidx} + +要使用索引,须经过这么几个步骤(仍设源代码名为 \texttt{demo.tex}): + +\pkgindex{makeidx} +\cmdindex[makeidx]{makeindex} +第一步,在 \LaTeX{} 源代码的导言区调用 \pkg{makeidx} 宏包,并使用 \cmd{makeindex} 命令开启索引的收集: +\begin{verbatim} +\usepackage{makeidx} +\makeindex +\end{verbatim} + +\cmdindex{index} +\cmdindex[makeidx]{printindex} +第二步,在正文中需要索引的地方使用 \cmd{index} 命令。\cmd{index} 命令的参数写法详见下一小节; +并在需要输出索引的地方(如所有章节之后)使用 \cmd{printindex} 命令。 + +第三步,编译过程: + +\begin{enumerate} + \item 首先用 \texttt{xelatex} 等命令编译源代码 \texttt{demo.tex}。编译过程中产生索引记录文件 \texttt{demo.idx}; + \item 用 makeindex 程序处理 \texttt{demo.idx},生成用于排版的索引列表文件 \texttt{demo.ind}; + \item 再次编译源代码 \texttt{demo.tex},正确生成索引列表。 +\end{enumerate} + +\subsection{索引项的写法}\label{subsec:index-entry} + +\cmdindex{index} +添加索引项的命令为: +\begin{command} +\cmd{index}\marg{index entry} +\end{command} + +其中 \Arg{index entry} 为索引项,写法由表 \ref{tbl:index-entry} 汇总。其中 \texttt!、\texttt @ 和 \texttt| +为特殊符号,如果要向索引项直接输出这些符号,需要加前缀 \texttt";而 \texttt" 需要输入两个引号 \texttt{""} 才能输出到索引项。 + +\begin{table}[htp] +\centering +\caption{索引项的写法列表}\label{tbl:index-entry} +\begin{tabular}{lll} + \hline + \textbf{举例} &\textbf{索引项} &\textbf{备注}\\ + \hline + \multicolumn{3}{l}{普通索引} \\[.8ex] + \verb+hello+ & hello, 1 & 普通索引 \\ + \hline + \multicolumn{3}{l}{分级索引,以 \texttt! 分隔,最多支持三级} \\[.8ex] + \verb+hello+ & hello, 1 & 一级索引 \\ + \verb+hello!Peter+ &\quad Peter, 3 & 二级索引 \\ + \verb+hello!Peter!Jack+ &\qquad Jack, 3 & 三级索引 \\ + \hline + \multicolumn{3}{l}{格式化索引,形式为 \Arg{alpha}\texttt @\Arg{format}} \\ + \multicolumn{3}{l}{\Arg{alpha}为纯字母,用来排序} \\ + \multicolumn{3}{l}{\Arg{format}为索引的格式,可以包括 \LaTeX 代码和简单的公式} \\[.8ex] + \verb+Mobius@M\""obius+ & M\"obius, 2 & 输出重音 \\ + \verb+alpha@$\alpha$+ & $\alpha$, 7 & 输出公式 \\ + \verb+bold@\textbf{bold}+ & \textbf{bold}, 12 & 输出粗体 \\ + \hline + \multicolumn{3}{l}{页码范围} \\[.8ex] + \verb+morning|(+ & morning, 6--7 & 范围索引的开头 \\ + \verb+morning|)+ & & 范围索引的结尾 \\ + \hline + \multicolumn{3}{l}{格式化索引页码} \\[.8ex] + \verb+Jenny|textbf+ & Jenny, \textbf{3} & 调用 \cmd{textbf} 加粗页码 \\ + \verb+Joe|see{Jenny}+ & Joe, \textit{see} Jenny & 调用 \cmd{see} 生成特殊形式 \\ + \verb+Joe|seealso{Jenny}+ & Joe, \textit{see also} Jenny & 调用 \cmd{seealso} 生成特殊形式 \\ + \hline +\end{tabular} +\end{table} + +读者可以钻研一下以下给出的一个较为复杂的,结合多级索引、索引格式、页码格式等的用法示例。但在自己使用时, +最好还是遵循“简单的就是最好的”原则,尽量使用表 \ref{tbl:index-entry} 中的写法。 +\begin{verbatim} +Test index. +\index{Test@\textsf{""Test}|(textbf} +\index{Test@\textsf{""Test}!sub@"|sub"||see{Test}} +\newpage +Test index. +\index{Test@\textsf{""Test}|)textbf} +\end{verbatim} + +\section{使用颜色}\label{sec:color} + +\pinyinindex{yanse}{颜色} +原始的 \LaTeX{} 不支持使用各种颜色。\pkg{color} 宏包或者 \pkg{xcolor} 宏包提供了对颜色的支持,给 PDF 输出生成颜色的特殊指令。 + +\subsection{颜色的表达方式}\label{subsec:color-code} + +\pkgindex{color} +\cmdindex[color/xcolor]{color} +调用 \pkg{color} 或 \pkg{xcolor} 宏包后,我们就可以用如下命令切换颜色: +\begin{command} +\cmd{color}\oarg{color-mode}\marg{code} \\ +\cmd{color}\marg{color-name} +\end{command} + +颜色的表达方式有两种,其一是使用色彩模型和色彩代码,代码用 $0\sim1$ 的数字代表成分的比例。 +\pkg{color} 宏包支持 \texttt{rgb}、\texttt{cmyk} 和 \texttt{gray} 模型,\pkg{xcolor} 支持更多的模型如 \texttt{hsb} 等。 +\begin{example} +\large\sffamily +{\color[gray]{0.6} + 60\% 灰色} \\ +{\color[rgb]{0,1,1} + 青色} +\end{example} + +其二是直接使用名称代表颜色,前提是已经定义了颜色名称(没定义的话会报错): +\begin{example} +\large\sffamily +{\color{red} 红色} \\ +{\color{blue} 蓝色} +\end{example} + +\pkgindex{xcolor} +\pkg{color} 宏包仅定义了 8 种颜色名称,\pkg{xcolor} 补充了一些,总共有 19 种,见表 \ref{tbl:colors}。 + +\def\showcolor#1{% + \texttt{#1}\index{yanse@颜色!#1@\texttt{#1}}% + \ \begingroup\fboxsep=0pt\fbox{{\color{#1}\vrule width 1.2em height 1.4ex}}\endgroup} +\def\showxcolor#1{% + \texttt{#1}\index{yanse@颜色!#1@\texttt{#1} (\pkg{xcolor})}% + \ \begingroup\fboxsep=0pt\fbox{{\color{#1}\vrule width 1.2em height 1.4ex}}\endgroup} + +\begin{table}[htp] +\centering +\caption{\pkg{color} 和 \pkg{xcolor} 宏包可用的颜色名称}\label{tbl:colors} +\renewcommand\arraystretch{1.1} +\begin{tabularx}{0.8\textwidth}{*{4}{>{\raggedleft\arraybackslash}X}} + \hline + \multicolumn{4}{c}{基本的 8 种颜色名称(后三种颜色为 CMYK 模型)} \\ + \showcolor{black} & \showcolor{red} & \showcolor{green} & \showcolor{blue} \\ + \showcolor{white} & \showcolor{cyan} & \showcolor{magenta} & \showcolor{yellow} \\ + \hline + \multicolumn{4}{c}{\pkg{xcolor} 额外可用的颜色名称:} \\ + \showxcolor{darkgray} & \showxcolor{gray} & \showxcolor{lightgray} & \\ + \showxcolor{brown} & \showxcolor{olive} & \showxcolor{orange} & \showxcolor{lime}\\ + \showxcolor{purple} & \showxcolor{teal} & \showxcolor{violet} & \showxcolor{pink} \\ + \hline +\end{tabularx} +\end{table} + +\pkg{xcolor} 还支持将颜色通过表达式混合或互补: +\begin{example} +\large\sffamily +{\color{red!40} 40\% 红色}\\ +{\color{blue}蓝色 +\color{blue!50!black}蓝黑 +\color{black}黑色}\\ +{\color{-red}红色的互补色} +\end{example} + +我们还可以通过命令自定义颜色名称,注意这里的 \Arg{color-mode} 是必选参数: +\begin{command} +\cmd{definecolor}\marg{color-name}\marg{color-mode}\marg{code} +\end{command} + +如果调用 \pkg{color} 或 \pkg{xcolor} 宏包时指定 \texttt{dvipsnames} 选项,就有额外的 68 种颜色名称可用% +\footnote{\pkg{color} 宏包实际要指定 \texttt{dvipsnames} 和 \texttt{usenames} 选项。}。 +\pkg{xcolor} 宏包还支持通过指定其它选项载入更多颜色名称。限于篇幅不展开介绍,详情请参考 \pkg{xcolor} 宏包的手册。 + +\subsection{带颜色的文本和盒子}\label{subsec:colorbox} + +原始的 \cmd{color} 命令类似于字体命令 \cmd{bfseries},它使之后排版的内容全部变成指定的颜色, +所以直接使用时通常要加花括号分组。\pkg{color} / \pkg{xcolor} 宏包都定义了一些方便用户使用的带颜色元素。 + +\cmdindex[color/xcolor]{textcolor} +输入带颜色的文本可以用类似 \cmd{textbf} 的命令: +\begin{command} +\cmd{textcolor}\oarg{color-mode}\marg{code}\marg{text} \\ +\cmd{textcolor}\marg{color-name}\marg{text} +\end{command} + +\cmdindex[color/xcolor]{colorbox} +以下命令构造一个带背景色的盒子,\Arg{material} 为盒子中的内容: +\begin{command} +\cmd{colorbox}\oarg{color-mode}\marg{code}\marg{material} \\ +\cmd{colorbox}\marg{color-name}\marg{material} +\end{command} + +\cmdindex[color/xcolor]{fcolorbox} +以下命令构造一个带背景色和有色边框的盒子,\Arg{fcode} 或 \Arg{fcolor-name} 用于设置边框颜色: +\begin{command} +\cmd{fcolorbox}\oarg{color-mode}\marg{fcode}\marg{code}\marg{material} \\ +\cmd{fcolorbox}\marg{fcolor-name}\marg{color-name}\marg{material} +\end{command} + +\begin{example} +\sffamily +文字用\textcolor{red}{红色}强调\\ +\colorbox[gray]{0.95}{浅灰色背景} \\ +\fcolorbox{blue}{yellow}{% + \textcolor{blue}{蓝色边框+文字,% + 黄色背景} +} +\end{example} + +\cmdindex{fboxrule,fboxsep} +\cmd{fcolorbox} 也可以像 \ref{subsec:fbox} 小节里的 \cmd{fbox} 那样调节 \cmd{fbox\-rule} 和 \cmd{fbox\-sep};对于 \cmd{color\-box}, +调整 \cmd{fbox\-sep} 是有效的。这里不再给出具体的示例。 + +\section{使用超链接}\label{sec:hyperlinks} + +\pinyinindex{chaolianjie}{超链接} +PDF 文档格式是现今最流行的电子文档格式,而电子文档最实用的需求之一就是超链接功能。 +\LaTeX{} 中实现这一功能的是 \pkg{hyperref} 宏包。 + +\subsection{\pkg{hyperref} 宏包}\label{subsec:hyperref} + +\pkgindex{hyperref} +\pkg{hyperref} 宏包涉及到的链接遍布 \LaTeX{} 的每一个角落——目录、引用、脚注、索引、参考文献等等都被封装成超链接。 +但这也使得它与其它宏包发生冲突的可能性大大增加,虽然宏包已经尽力解决各方面的兼容性,但仍不能面面俱到。 +为减少可能的冲突,习惯上将 \pkg{hyperref} 宏包\textbf{放在其它宏包之后调用}。 + +\pinyinindex{xuanxiang}{选项(宏包/文档类)} +与 \pkg{graphicx} 宏包类似,\texttt{latex} + \texttt{dvipdfmx} 命令下调用 \pkg{hyperref} 宏包时,需要指定选项 \texttt{dvipdfmx}; +而 \texttt{pdflatex} 或 \texttt{xelatex} 命令下不需要。 + +\cmdindex[hyperref]{hypersetup} +\pkg{hyperref} 宏包提供了命令 \cmd{hypersetup} 配置各种参数。参数也可以作为宏包选项,在调用宏包时指定: +\begin{command} +\cmd{hypersetup}\marg*{\Arg{option1},\Arg{option2}=\marg*{value},\ldots} \\ +\cmd{usepackage}\oarg*{\Arg{option1},\Arg{option2}=\marg*{value},\ldots}\marg*{hyperref} +\end{command} +可用的参数见表 \ref{tbl:hyperref-settings}。 + +\begin{table}[htp] +\centering +\caption{\pkg{hyperref} 宏包提供的参数设置}\label{tbl:hyperref-settings} +\begin{tabular}{llp{19.5em}} + \hline + \textbf{参数} & \textbf{默认值} & \textbf{含义} \\ + \hline + \texttt{colorlinks=}\Arg{true\textnormal|false} + & \textit{false} & 设置为 \textit{true} 为链接文字带颜色,反之加上带颜色的边框 \\ + \texttt{hidelinks} & & 取消链接的颜色和边框 \\ + \texttt{pdfborder=}\marg*{\Arg{n} \Arg{n} \Arg{n}} + & 0 0 1 & 超链接边框设置,设为 0 0 0 可取消边框 \\ + \hline + \texttt{bookmarks=}\Arg{true\textnormal|false}\textsuperscript{\dag} + & \textit{true} & 是否生成书签 \\ + \texttt{bookmarksopen=}\Arg{true\textnormal|false} + & \textit{false} & 是否展开书签 \\ + \texttt{bookmarksnumbered=}\Arg{true\textnormal|false} + & \textit{false} & 书签是否带章节编号 \\ + \hline + \texttt{pdftitle=}\Arg{string} + & 空 & 标题 \\ + \texttt{pdfauthor=}\Arg{string} + & 空 & 作者 \\ + \texttt{pdfsubject=}\Arg{string} + & 空 & 主题 \\ + \texttt{pdfkeywords=}\Arg{string} + & 空 & 关键词 \\ + \texttt{pdfstartview=}\Arg{Fit\textnormal|FitH\textnormal|FitV} + & \textit{Fit} & 设置 PDF 页面以适合页面/适合宽度/适合高度等方式显示,默认为适合页面 \\ + \hline +\end{tabular} +\begin{quotation} +\small +\textsuperscript{\dag} 该选项只能作为宏包选项,在调用宏包时指定。 +\end{quotation} +\end{table} + +\subsection{超链接}\label{subsec:url-href} + +\cmdindex[hyperref]{url,nolinkurl} +\pkg{hyperref} 宏包提供了直接书写超链接的命令,用于在 PDF 中生成 URL: +\begin{command} +\cmd{url}\marg{url} \\ +\cmd{nolinkurl}\marg{url} +\end{command} + +\cmd{url} 和 \cmd{nolinkurl} 都生成可以点击的 URL,区别是前者有彩色,后者没有。在 \cmd{url} 命令中作为参数的 URL 里, +\textbf{可直接输入如 \texttt\%、\texttt\& 这样的特殊符号}。 + +\cmdindex[hyperref]{href} +我们也可以像 HTML 中的超链接一样,把一段文字作为超链接: +\begin{command} +\cmd{href}\marg{url}\marg{text} +\end{command} + +\begin{example} +\url{http://wikipedia.org} \\ +\nolinkurl{http://wikipedia.org} \\ +\href{http://wikipedia.org}{Wiki} +\end{example} + +\cmdindex[hyperref]{hyperref} +使用 \pkg{hyperref} 宏包后,文档中所有的引用、参考文献、索引等等都转换为超链接。 +用户也可对某个 \cmd{label} 命令定义的标签 \Arg{label} 作超链接(注意这里的 \Arg{label} 虽然是可选参数的形式,但通常是\textbf{必填的}% +\footnote{不带可选参数的 \cmd{hyperref} 命令带四个必选参数,前三个组成特殊格式的超链接,最后一个同 \Arg{text}。}): +\begin{command} +\cmd{hyperref}\oarg{label}\marg{text} +\end{command} + +默认的超链接在文字外边加上一个带颜色的边框(在打印 PDF 时边框不会打印),可指定 \texttt{color\-links} 参数修改为将文字本身加上颜色, +或修改 \texttt{pdf\-border} 参数调整边框宽度以“去掉”边框;\texttt{hide\-links} 参数则令超链接既不变色也不加边框。 +\begin{verbatim} +\hypersetup{hidelinks} +% or: +\hypersetup{pdfborder={0 0 0}} +\end{verbatim} + +\subsection{PDF 书签}\label{subsec:pdf-bookmark} + +\pinyinindex{PDFshuqian}{PDF 书签} +\pkg{hyperref} 宏包另一个强大的功能是为 PDF 生成书签。对于章节命令 \cmd{chapter}、\cmd{section} 等, +默认情况下会为 PDF 自动生成书签。和交叉引用、索引等类似,生成书签也需要多次编译源代码,第一次编译将书签记录写入 \texttt{.out} 文件, +第二次编译才正确生成书签。 + +书签的一些属性见表 \ref{tbl:hyperref-settings}。使用 \pkg{CJK} 宏包时,为了防止中文书签出现乱码, +需要进行繁琐的设置;但在使用 \pkg{ctex} 宏包和文档类、且使用 \texttt{xelatex} 或 \texttt{lualatex} 编译的情况下, +无需用户额外干预,即可正确生成中文书签。 + +\cmdindex[hyperref]{pdfbookmark} +\pkg{hyperref} 还提供了手动生成书签的命令: +\begin{command} +\cmd{pdfbookmark}\oarg{level}\marg{bookmark}\marg{anchor} +\end{command} +\Arg{bookmark} 为书签名称,\Arg{anchor} 为书签项使用的锚点(类似交叉引用的标签)。可选参数 \Arg{level} 为书签的层级,默认为 0。 + +\cmdindex[hyperref]{texorpdfstring} +章节命令里往往有 \LaTeX{} 命令甚至数学公式,而 PDF 书签是纯文本,对命令和公式的处理很困难,有出错的风险。 +\pkg{hyperref} 宏包已经为我们处理了许多常见命令,如 \cmd{LaTeX} 和字体命令 \cmd{textbf} 等, +对于未被处理的命令或数学公式,就要在章节标题中使用如下命令,分别提供 \LaTeX{} 代码和 PDF 书签可用的纯文本: +\begin{command} +\cmd{texorpdfstring}\marg{\LaTeX{} code}\marg{PDF bookmark text} +\end{command} +比如在章节名称里使用公式 $E=mc^2$,而书签则使用纯文本形式的 \verb|E=mc^2|: +\begin{verbatim} +\section{质能公式 \texorpdfstring{$E=mc^2$}{E=mc\textasciicircum 2}} +\end{verbatim} + +\subsection{PDF 文档属性}\label{subsec:pdf-settings} + +\pkg{hyperref} 宏包还提供了一些参数用于改变 PDF 文档的属性,部分见表 \ref{tbl:hyperref-settings}。 + + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.07.graphic.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.07.graphic.tex new file mode 100644 index 00000000000..11abdec17d3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.07.graphic.tex @@ -0,0 +1,473 @@ +\chapter{绘图功能}\label{chap:graphics} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +除了排版文字,\LaTeX{} 也支持用代码表示图形。不同的扩展已经极大地丰富了 \LaTeX{} 的图形功能,\hologo{TikZ} 就是其中之一。 +本章将带你了解一些基本的绘图功能。 + +一些特殊的绘图,如交换图、树状图甚至分子式和电路图也能够通过代码绘制, +不过其复杂程度已经超出本手册范围,有兴趣的读者可以查阅一些帮助文档,或者在互联网寻求帮助。 +\end{intro} + +\section{绘图语言简介}\label{sec:pict-lang} + +\LaTeX{} 提供了原始的 \env{picture} 环境,能够绘制一些基本的图形如点、线、矩形、圆、B\'ezier 曲线等等, +不过受制于 \LaTeX{} 本身,它的绘图功能极为有限,效果也不够美观。 + +当前较为流行的、用于 \LaTeX{} 的绘图宏包 / 程序主要有: +\begin{itemize} + \item PSTricks \par + 以 PostSciprt 语法为基础的绘图宏包,具有优秀的绘图能力。它对老式的 \texttt{latex + dvips} 编译命令支持最好, + 而现在的几种编译命令下使用起来都不够方便。 + + \item \hologo{TikZ} \& \pkg{pgf} \par + 德国的 Till Tantau 教授在开发著名的 \LaTeX{} 幻灯片文档类 \cls{beamer} 时一并开发了绘图宏包 \pkg{pgf}, + 目的是令其能够在 \texttt{pdflatex} 或 \texttt{xelatex} 等不同的编译命令下都能使用。 + \hologo{TikZ} 是在 \pkg{pgf} 基础上封装的一个宏包,采用了类似 \hologo{METAPOST} 的语法,提供了方便的绘图命令,绘图能力不输 PSTricks。 + + \item \hologo{METAPOST} \& Asymptote \par + \hologo{METAPOST} 脱胎于高德纳为 \TeX{} 配套开发的字体生成程序 \hologo{METAFONT}, + 具有优秀的绘图能力,并能够调用 \TeX{} 引擎向图片中插入文字和公式。 + Asymptote 在 \hologo{METAPOST} 的基础上更进一步,具有一定的类似 C 语言的编程能力,支持三维图形的绘制。\par + 它们作为独立的程序,通常的用法是将代码写在单独的文件里,编译生成图片供 \LaTeX{} 引用,也可以借助特殊的宏包在 \LaTeX{} 代码里直接使用。 +\end{itemize} + +本手册将介绍 \hologo{TikZ} 绘图宏包里最基本的部分。\hologo{TikZ} 还支持各种自定义的扩展,基于 \hologo{TikZ} 的专门用途的绘图宏包也不胜枚举, +其复杂程度已远远超出入门手册的范围(\hologo{TikZ} 的帮助文档有上千页之厚)。 +对此感兴趣的读者需要自行查阅帮助文档,或者到互联网上参考现成的范例。 + +\section{\hologo{TikZ} 绘图语言}\label{sec:tikz} + +\index{TikZ@\protect\hologo{TikZ}} +\pkgindex{tikz} +\envindex[tikz]{tikzpicture} +\cmdindex[tikz]{tikz} +在导言区调用 \pkg{tikz} 宏包,就可以用以下命令和环境使用 \hologo{TikZ} 的绘图功能了% +\footnote{\texttt{latex + dvipdfmx} 编译方式要在 \pkg{tikz} 宏包之前调用 \pkg{graphicx} 宏包并指定 \texttt{dvipdfmx} 选项。}: +\begin{command} +\cmd{tikz}\oarg*{...} \Arg{tikz code}\texttt{;} \\[1ex] +\cmd{tikz}\oarg*{...} \marg*{\Arg{tikz code 1}\texttt{;} \Arg{tikz code 2}\texttt{;} ...} \\[1ex] +\cmd{begin}\marg*{tikzpicture}\oarg*{...} \\ +\Arg{tikz code 1}\texttt{;} \\ +\Arg{tikz code 2}\texttt{;} \\ +... \\ +\cmd{end}\marg*{tikzpicture} +\end{command} + +前一种用法为 \cmd{tikz} 带单条绘图命令,以分号结束,一般用于在文字之间插入简单的图形; +后两种用法较为常见,使用多条绘图命令,可以在 \env{figure} 等浮动体中使用。 + +\subsection{\hologo{TikZ} 坐标和路径}\label{subsec:tikz-path} + +\hologo{TikZ} 用直角坐标系或者极坐标系描述点的位置。 +\begin{itemize} + \item 直角坐标下,点的位置写作 \texttt{(\Arg{$x$},\Arg{$y$})},坐标 \Arg{$x$} 和 \Arg{$y$} 可以用 \LaTeX{} 支持的任意单位表示, + 缺省为 \texttt{cm}; + \item 极坐标下,点的位置写作 \texttt{(\Arg{$\theta$}:\Arg{r})}。$\theta$ 为极角,单位是度。 +\end{itemize} + +\cmdindex[tikz]{coordinate} +我们还可以为某个点命名:\cmd{coordinate} \texttt{(A) at (\Arg{coordinate})} +然后就可以使用 \texttt{(A)} 作为点的位置了。 + +\begin{example} +\begin{tikzpicture} +\draw (0,0) -- (30:1); +\draw (1,0) -- (2,1); +\coordinate (S) at (0,1); +\draw (S) -- (1,1); +\end{tikzpicture} +\end{example} + +坐标的表示形式还包括“垂足”形式: +\begin{example} +\begin{tikzpicture} +\coordinate (S) at (2,2); +\draw[gray] (-1,2) -- (S); +\draw[gray] (2,-1) -- (S); +\draw[red] (0,0) -- (0,0 -| S); +\draw[blue] (0,0) -- (0,0 |- S); +\end{tikzpicture} +\end{example} + + +\hologo{TikZ} 最基本的路径为两点之间连线,如 \texttt{(\Arg{$x_1$},\Arg{$y_1$}) -{}- (\Arg{$x_2$},\Arg{$y_2$})},可以连用表示多个连线(折线)。 +连续使用连线时,可以使用 \texttt{cycle} 令路径回到起点,生成闭合的路径。 +\begin{example} +\begin{tikzpicture} +\draw (0,0) -- (1,1) -- (2,0) -- cycle; +\end{tikzpicture} +\end{example} + +多条路径可用于同一条画图命令中,以空格分隔: +\begin{example} +\begin{tikzpicture} +\draw (0,0) -- (0,1) + (1,0) -- (1,1) -- (2,0) -- cycle; +\end{tikzpicture} +\end{example} + +其它常用的路径还包括: +\begin{itemize} + \item 矩形、圆和椭圆: +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw (0,0) rectangle (1.5,1); +\draw (2.5,0.5) circle [radius=0.5]; +\draw (4.5,0.5) ellipse + [x radius=1,y radius=0.5]; +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item 直角、圆弧、椭圆弧: +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw (0,0) |- (1,1); +\draw (1,0) -| (2,1); +\draw (4,0) arc (0:135:1); +\draw (6,0) arc (0:135:1 and 0.5); +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item 正弦、余弦曲线(1/4 周期): +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw (0,0) sin (1,1); +\draw (0,1) sin (1,0); +\draw (2,1) cos (3,0); +\draw (2,0) cos (3,1); +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item 抛物线,用 \texttt{bend} 控制顶点: +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw (0,0) parabola (1,2); +\draw (2,0) parabola + bend (2.25,-0.25) (3,2); +\draw (4,0) parabola + bend (4.75,2.25) (5,2); +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item 二次和三次 B\'ezier 曲线,分别使用一个和两个控制点: +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw (0,0) .. controls + (2,1) and (3,1) .. (3,0); +\draw (4,0) .. controls + (5,1) .. (5,0); +\draw[help lines] (0,0) + -- (2,1) -- (3,1) -- (3,0) + (4,0) -- (5,1) -- (5,0); +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item 网格、函数图像,网格可用 \texttt{step} 参数控制网格大小,函数图像用 \texttt{domain} 参数控制定义域: +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw[help lines,step=0.5] + (-1,-1) grid (1,1); +\draw[->] (-1.5,0) -- (1.5,0); +\draw[->] (0,-1.5) -- (0,1.5); +\draw[domain=-1:1] + plot(\x,{\x*\x*2 -1}); +\end{tikzpicture} +\end{example} + +\subsection{\hologo{TikZ} 绘图命令和参数}\label{subsec:tikz-draw} + +\cmdindex[tikz]{draw,fill,filldraw} +除了 \cmd{draw} 命令之外,\hologo{TikZ} 还提供了 \cmd{fill} 命令用来填充图形,\cmd{filldraw} 命令则同时填充和描边。 +除了矩形、圆等现成的闭合图形外,\cmd{fill} 和 \cmd{filldraw} 命令也能够填充人为构造的闭合路径。 +\begin{command} +\cmd{draw}\oarg*{...} \Arg{path}; \\ +\cmd{fill}\oarg*{...} \Arg{path}; \\ +\cmd{filldraw}\oarg*{...} \Arg{path}; +\end{command} + +绘图参数可作为可选参数用在 \env{tikzpiture} 环境或 \cmd{tikz} 命令时,参数会影响到所有具体的绘图命令; +用在单个绘图命令 \cmd{draw}、\cmd{filldraw} 等时,只对这个命令起效。 + +\hologo{TikZ} 有数不清的绘图参数,这些参数令 \hologo{TikZ} 能够绘制丰富多彩的图像,同时也令 \hologo{TikZ} 难以精通。 +以下示例常用的一些绘图参数。 + +\begin{itemize} + \item \texttt{color/draw/fill=\Arg{color}} 为 \cmd{draw} 或 \cmd{fill} 等命令指定颜色。 + \texttt{draw} 和 \texttt{fill} 分别指定填充和描边的颜色,而 \texttt{color} 同时指定, + 可以省略 \texttt{color=} 直接写颜色名称。 +\end{itemize} +\begin{example} +\begin{tikzpicture}[thick] +\draw[blue] (0,0) rectangle (1,1); +\filldraw[fill=yellow,draw=red] + (2,0.5) circle [radius=0.5]; +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item \texttt{thick=\Arg{length}/thin/semithick/...} 指定线条的粗细。 +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw[ultra thin] (0,0)--(0,2); +\draw[very thin] (0.5,0)--(0.5,2); +\draw[thin] (1,0)--(1,2); +\draw[semithick] (1.5,0)--(1.5,2); +\draw[thick] (2,0)--(2,2); +\draw[very thick] (2.5,0)--(2.5,2); +\draw[ultra thick] (3,0)--(3,2); +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item \texttt{solid/dashed/dotted/dash dot/dash dot dot} 指定线条类型(实线、虚线、点划线等)。 + 与 \texttt{dashed} 对应地有 \texttt{densely dashed} 和 \texttt{loosely dashed},后三种类型同理。 +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw[dashed] (0,0) -- (0,2); +\draw[dotted] (0.5,0) -- (0.5,2); +\draw[dash dot] (1,0) -- (1,2); +\draw[dash dot dot] (1.5,0) -- (1.5,2); +\draw[densely dotted] + (2,0) -- (3,2) -- (4,0) -- cycle; +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item \texttt{\Arg{arrow}-\Arg{arrow}} 指定线条首尾的箭头形式。 + 复杂的箭头形式需要在导言区使用 \cmd{use\-tikz\-library} \marg*{arrows.meta}。 +\end{itemize} +\begin{example} +\begin{tikzpicture}[thick] +\draw[->] (0,4) -- (3,4); +\draw[->>] (0,3.5) -- (3,3.5); +\draw[->|] (0,3) -- (3,3); +\draw[<-] (0,2.5) -- (3,2.5); +\draw[<->] (0,2) -- (3,2); +\draw[>->|] (0,1.5) -- (3,1.5); +\draw[-stealth] (0,1) -- (3,1); +\draw[-latex] (0,0.5) -- (3,0.5); +\draw[-to] (0,0) -- (3,0); +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item \texttt{rounded corners\oarg*{=\Arg{radius}}/sharp corners} 将路径转向处绘制成圆角/直角。可选参数 \Arg{radius} 控制圆角的半径。 + 可以对某一段路径直接使用。 +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw[rounded corners] + (0,0) rectangle (1,1); +\draw (2,0) -- (2,1) + [rounded corners=.3cm] + -- (3,1) -- (3.5,0) + [sharp corners] -- cycle; +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item \texttt{scale/xshift/yshift/xslant/yslant/rotate} 设定图形的缩放、位移和旋转。 +\end{itemize} +\begin{example} +\begin{tikzpicture} +\draw[help lines](0,0) rectangle (1,1); +\draw[scale=1.5] (0,0) rectangle (1,1); +\draw[rotate=30] (0,0) rectangle (1,1); +\draw[help lines](2,0) rectangle (3,1); +\draw[yshift=4pt](2,0) rectangle (3,1); +\draw[help lines](4,0) rectangle (5,1); +\draw[xslant=0.4](4,0) rectangle (5,1); +\end{tikzpicture} +\end{example} + +为了重复利用绘图参数,减少代码冗余,\hologo{TikZ} 引入了“样式”的概念,可以定义一个样式包含绘图参数, +然后将样式作为一个参数用于绘图: +\begin{example} +\begin{tikzpicture} + [myarrow/.style={blue,thick,->}] +\draw (0,0)--(0,1)--(2,1); +\draw[myarrow] (0,0)--(2,1); +\draw[myarrow,dotted] + (0,0)--(2,0)--(2,1); +\end{tikzpicture} +\end{example} + +\envindex[tikz]{scope} +\hologo{TikZ} 还提供了 \env{scope} 环境,令绘图参数或样式在局部生效: +\begin{example} +\begin{tikzpicture} +\draw (0,0) rectangle (2.5, 2.5); +\begin{scope}[thick,scale=0.5] +\draw (0,0) rectangle (2.5, 2.5); +\end{scope} +\end{tikzpicture} +\end{example} + +\subsection{\hologo{TikZ} 文字结点}\label{subsec:tikz-node} + +\cmdindex[tikz]{node} +\hologo{TikZ} 用 \cmd{node} 命令绘制文字结点: +\begin{command} +\cmd{node}\oarg{options} \texttt{(\Arg{name})} \texttt{at (\Arg{coordinate})} \marg{text}\texttt{;} +\end{command} +\texttt{(\Arg{name})} 为结点命名,类似 \cmd{coordinate};\texttt{at (\Arg{coordinate})} 指定结点的位置。 +这两者和前面的 \Arg{options} 都可以省略,只有 \Arg{text} 是必填的。 +\begin{example} +\begin{tikzpicture} +\node (A) at (0,0) {A}; +\node (B) at (1,0) {B}; +\node (C) at (60:1) {C}; +\draw (A) -- (B) -- (C) -- (A); +\end{tikzpicture} +\end{example} + +\ref{subsec:tikz-draw} 小节中的参数可用于 \cmd{node} 命令的配置。除此之外,\cmd{node} 还有一些特定的参数: +\begin{itemize} + \item \texttt{anchor=\Arg{position}} 令结点的某个角落 \Arg{position} 与 \Arg{coordinate} 对应。 + \item \texttt{centered / above / below / left / right / above left / ... \oarg*{=\Arg{length}}} \\ + 与 \texttt{anchor} 等效的选项。可选的 \Arg{length} 为节点相对于 \Arg{coordinate} 的距离。 +\end{itemize} +\begin{example} +\begin{tikzpicture} +\coordinate (A) at (1,1); +\fill (A) circle[radius=2pt]; +\node[draw,anchor=south] at (A) {a}; +\node[draw,below right=4pt] at (A) {b}; +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item \texttt{shape=\Arg{shape}} + 结点的形状,默认可用 \texttt{rectangle} 和 \texttt{circle},可省略 \texttt{shape=} 直接写。在导言区使用命令 + \cmd{use\-tikz\-library}\marg*{shapes.geometric} 可用更多的形状。 + \item \texttt{text=\Arg{color}} + 结点文字的颜色。 + \item \texttt{node font=\Arg{font command}} + 结点文字的字体,形如 \cmd{bfseries} 或 \cmd{itshape} 等。 +\end{itemize} +\begin{example} +\begin{tikzpicture} +\node[circle,fill=blue,text=white, + node font={\bfseries}] + (A) at (0,0) {A node}; +\node[rectangle,rounded corners, + draw=gray, + node font={\sffamily\slshape}] + (B) at (2,0) {B node}; +\end{tikzpicture} +\end{example} + +\begin{itemize} + \item \texttt{inner sep=\Arg{length} / outer sep=\Arg{length}} + 结点边界向外和向内的额外距离。 + \item \texttt{minimum size=\Arg{length} / minimum height=\Arg{length} / minimum width=\Arg{length}} \\ + 结点的最小大小或最小高度/宽度。 +\end{itemize} + +\cmd{node} 命令不仅为文字结点的位置命名,在 \cmd{draw} 等命令中还可以使用某个结点的相对位置, +以“东南西北”的方式命名: +\begin{example} +\begin{tikzpicture} +\draw (0,0) circle[radius=1]; +\fill (0,0) circle[radius=2pt]; +\node[draw] (P) at (15:2) {center}; +\draw[dotted] (0,0) -- (P.west); +\end{tikzpicture} +\end{example} + +\cmd{node} 命令的一种等效用法是在 \cmd{draw} 等命令的路径中使用 \texttt{node},不仅可以对某个位置标记节点,还能够对线标记: +\begin{example} +\begin{tikzpicture} +\draw (2,1.5) node[above] {$A$} + -- node[above left] {$c$} + (0,0) node[left] {$B$} + -- node[below] {$a$} + (2.5,0) node[right] {$C$} + -- node[above right] {$b$} + cycle; +\end{tikzpicture} +\end{example} + +在此举一个较为复杂的例子,综合前面介绍过的各种路径、形状、文字结点和参数设置,见源代码 \ref{code:tikz-example}。 + +\begin{sourcecode}[htp] +\begin{Verbatim} +\begin{tikzpicture} +\draw[-stealth,line width=0.2pt] (-0.5,0) -- (4.5,0); +\draw[-stealth,line width=0.2pt] (0,-0.5) -- (0,2.5); +\coordinate (a) at (0.5,1.9); +\coordinate (b) at (4,1.2); +\node[below] (a0) at (a |- 0,0) {$a$}; +\node[below] (b0) at (b |- 0,0) {$b$}; +\filldraw[fill=gray!20,draw,thick] + (a0) -- (a) .. controls (1,2.8) and (2.7,0.4) .. (b) -- (b0) -- cycle; +\node[above right,outer sep=0.2cm, rounded corners, + fill=green!20,draw=gray,text=blue!60!black,scale=0.6] + at (b) {$\displaystyle \int_a^b {f(x)\,\mathrm{d}x} = F(b) - F(a)$}; +\end{tikzpicture} +\end{Verbatim} +\begin{center} +\begin{tikzpicture} +\draw[-stealth,line width=0.2pt] (-0.5,0) -- (4.5,0); +\draw[-stealth,line width=0.2pt] (0,-0.5) -- (0,2.5); +\coordinate (a) at (0.5,1.9); +\coordinate (b) at (4,1.2); +\coordinate[label=below:$a$] (a0) at (a |- 0,0); +\coordinate[label=below:$b$] (b0) at (b |- 0,0); +\filldraw[fill=gray!20,draw,thick] + (a0) -- (a) .. controls (1,2.8) and (2.7,0.4) .. (b) -- (b0) -- cycle; +\node[above right,outer sep=0.2cm, rounded corners, + fill=green!20,draw=gray,text=blue!60!black,scale=0.6] + at (b) {$\displaystyle \int_a^b {f(x)\,\mathrm{d}x} = F(b) - F(a)$}; +\end{tikzpicture} +\end{center} +\caption{\hologo{TikZ} 绘图示例源代码和效果。}\label{code:tikz-example} +\end{sourcecode} + +\subsection{在 \hologo{TikZ} 中使用循环} + +\cmdindex[tikz]{foreach} +\hologo{TikZ} 通过 \pkg{pgffor} 功能宏包实现了简单的循环功能,语法为: +\begin{command} +\cmd{foreach} \cmd{a} \texttt{in} \marg{list} \marg{commands} +\end{command} +上述语法定义了 \cmd{a} 为变量,在 \marg{commands} 中使用 \cmd{a} 完成循环。 + +\Arg{list} 可以直接将所有值写出来,如 1,2,3,4;也可以写成省略形式,如 1,2,\ldots,10。 +\begin{example} +\begin{tikzpicture} +\draw (0,0)--(5,0); +\foreach \i in {0.0,0.1,...,5.0} + {\draw[very thin] + (\i,0)--(\i,0.15);} +\foreach \I in {0,1,2,3,4,5} + {\draw (\I,0)--(\I,0.25) + node[above] {\I};} +\end{tikzpicture} +\end{example} + +\cmd{foreach} 还可使用变量对参与循环: +\begin{example} +\begin{tikzpicture} +\foreach \n/\t in + {0/\alpha,1/\beta,2/\gamma} + {\node[circle,fill=lightgray,draw] + at (\n,0) {$\t$};} +\end{tikzpicture} +\end{example} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.08.custom.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.08.custom.tex new file mode 100644 index 00000000000..d31043c5722 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/chap.08.custom.tex @@ -0,0 +1,349 @@ +\chapter{自定义 \LaTeX{} 命令和功能}\label{chap:custom} +\addtocontents{los}{\protect\addvspace{10pt}} + +\begin{intro} +读到这一章之前,如果你确保掌握了前几章的知识并熟练运用,你已经能制作出内容和形式都相当丰富的文档了。 +但你可能还不会满足:我要如何制作一个简单但像样的毕业论文/书籍/简历模板,每次可以直接套用, +而不是再在导言区写一堆代码? + +本章的内容将有助于你实现这一个目标,让你能编写可重复利用的模块——宏包和文档类,并在其中自己定义命令和环境。 +不过作为入门手册,这些知识仍是不全面的。如果你不满足于此,需要参考更多资料,比如 \cite{companion,clsguide}。 +\end{intro} + +\section{自定义命令和环境}\label{sec:defs} + +你也许已经意识到了,在本手册中介绍的所有命令都被包含在一个带颜色的矩形背景框中。 +笔者并没有直接使用基础的 \LaTeX{} 命令来实现这个效果,而是创建了一个\textbf{宏包}, +并在其中定义了笔者所需要的命令和环境。现在我只需写成这样简单的形式: + +\begin{example} +\begin{command} +\cmd{dum} +\end{command} +\end{example} + +这个例子中使用了一个新的环境 \env{command}。这个环境负责给命令代码加上一个带颜色的矩形背景框。 +同时还使用了一个命令:\cmd{cmd}, 这个命令负责输出命令的名字,包括前面的反斜线。 + +一旦笔者想要修改命令代码的样式,比如更换颜色、加边框等等,可以通过改变 \env{command} 环境的定义来很容易地创建新的外观, +而不是挨个修改每个命令示例。 + +\subsection{定义新命令}\label{subsec:newcmd} + +\cmdindex{newcommand} +使用如下命令可以定义你自己的命令: +\begin{command} +\cmd{newcommand}\marg*{\cmd{\Arg{name}}}\oarg{num}\marg{definition} +\end{command} +\cmd{newcommand} 的基本用法需要两个必选参数,第一个参数 \Arg{name} 是要定义的命令名称(带反斜线), +第二个参数 \Arg{definition} 是命令的具体定义。方括号里的参数 \Arg{num} 是可选的, +用于指定新命令所需的参数数目(最多 9 个)。如果缺省可选参数,默认就是 0,也就是新定义的命令不带任何参数。 + +接下来的两个例子有助于理解。第一个例子定义了一个新的命令 \cmd{tnss}。 +这个命令是本手册英文名称 ``The Not So Short Introduction to \LaTeXe'' 的简写。 +如果需要在文档中多次使用本手册的名称,那么使用这个命令是一个非常方便的办法。 + +\begin{example} +\newcommand{\tnss}{The not + so Short Introduction to + \LaTeXe} +This is ``\tnss'' \ldots{} +``\tnss'' +\end{example} + +第二个例子演示了如何定义一个带参数的命令。在命令的定义中,标记 \verb|#1| +代表指定的参数。如果想使用多个参数,可以依次使用 \verb|#2|、……、\verb|#9| 等标记。 + +\begin{example} +\newcommand{\txsit}[1] + {This is the \emph{#1} Short + Introduction to \LaTeXe} +% in the document body: +\begin{itemize} +\item \txsit{not so} +\item \txsit{very} +\end{itemize} +\end{example} + +\cmdindex{renewcommand} +\LaTeX{} 不允许使用 \cmd{newcommand} 定义一个与现有命令重名的命令。如果需要修改命令定义的话,使用 \cmd{re\-new\-comm\-and} 命令。它使用与命令 \cmd{new\-comm\-and} +相同的语法。 + +\cmdindex{providecommand} +在某些情况之下,使用 \cmd{pro\-vide\-comm\-and} 命令是一种比较理想的方案。在命令未定义时,它相当于 \cmd{new\-comm\-and} +;在命令已定义时,沿用已有的定义。 + +\subsection{定义环境}\label{subsec:newenv} + +\cmdindex{newenvironment} +与 \cmd{new\-comm\-and} 命令类似,有一个命令用于定义新的环境。这个命令是 \cmd{new\-environ\-ment},它的语法如下所示: + +\begin{command} +\cmd{newenvironment}\marg{name}\oarg{num}\marg{before}\marg{after} +\end{command} + +同样地,\cmd{newenvironment} 命令有一个可选的参数。 +在 \Arg{before} 中的内容将在此环境包含的文本之前处理,而在 \Arg{after} 中的内容将在遇到 \cmd{end\marg{name}} 命令时处理。 + +下面的例子演示了 \cmd{newenvironment} 命令的用法: +\begin{example} +\newenvironment{king} +{\rule{1ex}{1ex}% + \hspace{\stretch{1}}} +{\hspace{\stretch{1}}% + \rule{1ex}{1ex}} + +\begin{king} +My humble subjects \ldots +\end{king} +\end{example} + +\cmdindex{renewenvironment} +参数 \Arg{num} 的使用方式与 \cmd{new\-comm\-and} 命令相同。\LaTeX{} 还同样保证你 +不会不小心新建重名的环境。如果你确实希望改变一个现有的环境,你可以使用命令 + \cmd{re\-new\-environ\-ment},它使用和命令 \cmd{new\-environ\-ment} 相同的语法。 + +\section{编写自己的宏包和文档类}\label{sec:packages} + +\subsection{编写简单的宏包}\label{subsec:provide-pkg} + +\cmdindex{usepackage} +如果你定义了很多新的环境和命令,你的文档的导言区将变得相当长,在这种情况下,好的方式是 +建立一个新的 \LaTeX{} 宏包来存放所有你自己定义的命令和环境, +然后在你的文档中使用 \cmd{use\-package} 命令来调用自定义的宏包。 + +\begin{sourcecode}[htp] +\begin{Verbatim} +% Demo Package by Tobias Oetiker +\ProvidesPackage{demopack} +\newcommand{\tnss}{The not so Short Introduction + to \LaTeXe} +\newcommand{\txsit}[1]{The \emph{#1} Short + Introduction to \LaTeXe} +\newenvironment{king}{\begin{quote}}{\end{quote}} +\end{Verbatim} +\caption{宏包的一个最简示例。}\label{code:package} +\end{sourcecode} + +\cmdindex{ProvidesPackage} +写一个宏包的基本工作就是将原本在你的文档导言区里很长的内容拷贝到另一个文件中去, + 这个文件需要以 \texttt{.sty} 作扩展名。你还需要加入一个宏包专用的命令: +\begin{command} +\cmd{ProvidesPackage}\marg{package name} +\end{command} +这个命令应该放在你的宏包的最前面,并且一定要注意:\textbf{\Arg{package name} 需要和宏包的文件名一致。} +\cmd{Provides\-Package} 让 \LaTeX{} 记录宏包的名称,从而在 \cmd{usepackage} 命令再次调用同一个宏包的时候忽略之% +\footnote{但如果你以\emph{不同的选项}多次引入宏包,则有可能会引起错误,见附录 \ref{sec:errors}。}。 +源代码 \ref{code:package} 给出了一个小的宏包示例,其中包含了我们之前定义的一些命令。 + +\subsection{在宏包中调用其它宏包}\label{subsec:require-pkg} + +\cmdindex{RequirePackage} +如果你想进一步把各种宏包的功能汇总到一个文件里,而不是在文档的导言区罗列一大堆宏包的话, +\LaTeX{} 允许你在自己编写的宏包中调用其它宏包,命令为 \cmd{RequirePackage},用法和 \cmd{usepackage} +一致: +\begin{command} +\cmd{RequirePackage}\oarg{options}\marg{package name} +\end{command} + +\subsection{编写自己的文档类}\label{subsec:provide-cls} + +\cmdindex{ProvidesClass} +当你更进一步,需要编写自己的文档类,如论文模板等,问题就稍稍麻烦了一些。首先,自己的文档类以 \texttt{.cls} 作扩展名,开头使用 +\cmd{ProvidesClass} 命令: +\begin{command} +\cmd{ProvidesClass}\marg{class name} +\end{command} +当然了,\marg{class name}也需要和文档类的文件名一致。 + +\cmdindex{LoadClass} +但是有了上述命令和和你之前学到的 \cmd{newcommand} 等,还并不能完成一个文档类的编写,因为诸如 \cmd{chapter}、 +\cmd{section} 等等许多常用的命令都是在文档类中定义的。事实上,许多时候我们只需要像调用宏包那样调用一个基本的文档类, +省去许多不必要的麻烦。在你的文档类中调用其它文档类的命令是 \cmd{LoadClass},用法和 \cmd{documentclass} 十分相像: +\begin{command} +\cmd{LoadClass}\oarg{options}\marg{package name} +\end{command} + +\section{计数器}\label{sec:counters} + +\pinyinindex{jishuqi}{计数器} +我们早就见识到了 \LaTeX{} 对文档元素自动计数的能力:章节符号、列表、图表……它们都是依靠 \LaTeX{} 提供的计数器功能完成的。 + +\subsection{定义和修改计数器}\label{subsec:count-defs} + +\cmdindex{newcounter} +定义一个计数器的方法为: +\begin{command} +\cmd{newcounter}\marg{counter name}\oarg{parent counter name} +\end{command} + +\Arg{counter name} 为计数器的名称。计数器可以有上下级的关系,可选参数 \Arg{parent counter name} 定义为 \Arg{counter name} 的上级计数器。 + +\cmdindex{setcounter,addtocounter,stepcounter} +以下命令修改计数器的数值,\cmd{set\-counter} 将数值设为 \Arg{number};\cmd{add\-to\-counter} 将数值加上 \Arg{number}; +\cmd{step\-counter} 将数值加一,并\textbf{将所有下级计数器归零}。 +\begin{command} +\cmd{setcounter}\marg{counter name}\marg{number} \\ +\cmd{addtocounter}\marg{counter name}\marg{number} \\ +\cmd{stepcounter}\marg{counter name} +\end{command} + +\subsection{计数器的输出格式}\label{subsec:count-value} + +计数器 \Arg{counter} 的输出格式由 \cmd{the\Arg{counter}} 表示,如我们在 \ref{sec:pagestyle} 一节见过的 \cmd{thechapter} 等。 +这个值默认以阿拉伯数字形式输出,如果想改成其它形式,需要重定义 \cmd{the\Arg{counter}},如将 equation 计数器的格式定义为大写字母: +\begin{verbatim} +\renewcommand\theequation{\Alph{equation}} +\end{verbatim} + +\cmdindex{arabic,alph,Alph,roman,Roman,fnsymbol} +命令 \cmd{Alph} 控制计数器 \Arg{counter} 的值以大写字母形式显示。下表列出所有可用于修改计数器格式的命令。 +注意:这些命令\textbf{只能用于计数器,不能直接用于数字},如 \cmd{roman}\marg*{1} 这样的命令会出错。 +\begin{table}[htp] +\centering +\caption{计数器输出格式相关命令}\label{tbl:counter-commands} +\begin{tabular}{lp{22em}l} + \hline + \textbf{命令} & \textbf{样式} & \textbf{范围} \\ + \hline + \cmd{arabic} & 阿拉伯数字(默认) & \\ + \cmd{alph} & 小写字母 & 限 0--26 \\ + \cmd{Alph} & 大写字母 & 限 0--26 \\ + \cmd{roman} & 小写罗马数字 & 限非负整数 \\ + \cmd{Roman} & 大写罗马数字 & 限非负整数 \\ + \cmd{fnsymbol} & 一系列符号,用于 \cmd{thanks} 命令生成的脚注 & 限 0--9 \\ + \hline +\end{tabular} +\begin{quotation} +\small +\makeatletter +注:\cmd{fnsymbol} 使用的符号顺次为: +\@fnsymbol{1} \@fnsymbol{2} \@fnsymbol{3} +\@fnsymbol{4} \@fnsymbol{5} \@fnsymbol{6} +\@fnsymbol{7} \@fnsymbol{8} \@fnsymbol{9} +\makeatother +\end{quotation} +\end{table} + +计数器的输出格式还可以利用其它字符,甚至其它计数器的输出格式与之组合。如标准文档类里对 \cmd{sub\-section} 相关的计数器的输出格式的定义相当于: +\begin{verbatim} +\renewcommand\thesubsection{\thesection.\arabic{subsection}} +\end{verbatim} + +\subsection{\LaTeX{} 中的计数器}\label{subsec:latex-counts} + +\begin{itemize} + \item 所有章节命令 \cmd{chapter}、\cmd{section} 等分别对应计数器 chapter、section 等等,而且有上下级的关系。 + 而计数器 part 是独立的。 + \item 有序列表 \env{enumerate} 的各级计数器为 enumi, enumii, enumiii, enumiv,也有上下级的关系。 + \item 图表浮动体的计数器就是 table 和 figure;公式的计数器为 equation。 + 这些计数器在 \cls{article} 文档类中是独立的,而在 \cls{book} 和 \cls{report} 中以 chapter 为上级计数器。 + \item 页码、脚注的计数器分别是 page 和 footnote。 +\end{itemize} + +我们可以利用前面介绍过的命令,修改计数器的样式以达到想要的效果,比如把页码修改成大写罗马字母,左右加横线,或是给脚注加上方括号: +\begin{verbatim} +\renewcommand\thepage{--~\Roman{page}~--} +\renewcommand\thefootnote{[\arabic{footnote}]} +\end{verbatim} + +\cmdindex{pagenumbering} +我们在 \ref{subsec:basic-pagesyle} 小节中见过命令 \cmd{pagenum\-bering}。 +它的内部机制是修改 page 计数器的格式 \cmd{thepage},并将计数器的值重置为 1。 + +最后介绍两个有用的计数器: + +\subsubsection{secnumdepth} + +\index{secnumdepth@secnumdepth (\textit{计数器})} +\LaTeX{} 标准文档类对章节划分了层级: +\begin{itemize} + \item 在 \cls{article} 文档类里 part 为 0,section 为 1,依此类推; + \item 在 \cls{report}/\cls{book} 文档类里 part 为 -1,chapter 为 0,section 为 1,等等。 +\end{itemize} + +secnumdepth 计数器控制章节编号的深度,如果章节的层级大于 secnumdepth,那么章节的标题、在目录和页眉页脚的标题都不编号 +(照常生成目录和页眉页脚),章节计数器也不计数。 + +可以用 \cmd{setcounter} 命令设置 secnumdepth 为较大的数使得层级比较深的章节也编号, +如设置为 4 令 \cmd{paragraph} 也编号;或者设置一个较小的数以取消编号,如设置为 -1 令 \cmd{chapter} 不编号。 +后者是生成不编号的章节的一个妙招,免去了手动使用 \cmd{add\-contents\-line} 和 \cmd{mark\-both} 的麻烦。 + +secnumdepth 计数器在 \cls{article} 文档类里默认为 3 (subsubsection 一级);在 \cls{report} 和 \cls{book} 文档类里默认为 2 (subsection 一级)。 + +\subsubsection{tocdepth} + +\index{tocdepth@tocdepth (\textit{计数器})} +tocdepth 计数器控制目录的深度,如果章节的层级大于 tocdepth,那么章节将不会自动写入目录项。默认值同 secnumdepth。 + +\section{\LaTeX{} 可定制的一些命令和参数}\label{sec:latex-settings} + +\LaTeX{} 事实上有相当一些可以定制的命令和参数,不过对于修改样式或者开发宏包来说,这些定制项还远远不够。 + +对于用户来讲,容易定制的是这一些项目: + +\begin{itemize} + \item 标题名称/前后缀等。表 \ref{tbl:latex-settings-names} 列出了标准文档类里可定制的项目, + 表中所有的 \LaTeX{} 命令都可以用 \cmd{re\-new\-comm\-and} 来修改。 + \item 长度。前文在叙述各种排版元素时已经涉及到一些,现归纳于表 \ref{tbl:latex-settings-lengths}。 + 表中所有的长度命令可用 \cmd{setlength} 来修改。 + 大多数控制页面尺寸的长度参数在图 \ref{fig:layouts} 给出,此处不再赘述。 +\end{itemize} + +\begin{table}[htp] +\centering +\caption{\LaTeX{} 可定制的标题名称/前后缀}\label{tbl:latex-settings-names} +\small +\begin{tabular}{llp{24em}} + \hline + \textbf{命令} & \textbf{默认值} & \textbf{含义} \\ + \hline + \cmd{partname} & Part & \cmd{part} 命令生成的标题前缀 \\ + \cmd{chaptername} & Chapter & \cmd{chapter} 命令生成的标题前缀 \\ + \cmd{appendixname} & Appendix & 使用 \cmd{appendix} 命令生成的附录部分的章标题前缀 \\ + \cmd{abstractname} & Abstract & 摘要环境 \env{abstract} 的标题名称 \\[1ex] + \cmd{contentsname} & Contents & \cmd{tableofcontents} 命令生成的目录标题 \\ + \cmd{listfigurename} & List of Figures & \cmd{listoffigures} 命令生成的插图目录标题 \\ + \cmd{listtablename} & List of Tables & \cmd{listoftables} 命令生成的表格目录标题 \\[1ex] + \cmd{tablename} & Table & \env{table} 浮动体中 \cmd{caption} 命令生成的标题前缀 \\ + \cmd{figurename} & Figure & \env{figure} 浮动体中 \cmd{caption} 命令生成的标题前缀 \\[1ex] + \cmd{refname} & References & \env{thebibliography} 环境或 \cmd{biblio\-graphy} + 命令生成的参考文献标题(\cls{article} 文档类) \\ + \cmd{bibname} & Bibliography & \env{thebibliography} 环境或 \cmd{biblio\-graphy} + 命令生成的参考文献标题(\cls{book / report} 文档类)\\ + \cmd{indexname} & Index & \cmd{printindex} 命令生成的索引标题 \\ + \hline +\end{tabular} +\begin{quotation}\footnotesize% +注:形如“第 X 章”和“第 X 部分”的中文章节标题不能直接由修改本表的命令得到,需要使用 \pkg{titlesec} 等宏包定制。 +如果使用 \pkg{ctex} 宏包或文档类,那么标题默认被修改成“第 X 章”和“第 X 部分”的形式,本表中的其它标题也修改为中文标题。详见 \pkg{ctex} 宏包的帮助文档。 +\end{quotation} +\end{table} + +\begin{table}[htp] +\centering +\caption{\LaTeX{} 可定制的长度参数}\label{tbl:latex-settings-lengths} +\small +\begin{tabular}{lll} + \hline + \textbf{命令} & \textbf{默认值} & \textbf{含义} \\ + \hline + \cmd{fboxrule} & 0.4pt & \cmd{fbox} 或 \cmd{framebox} 等带框盒子的线宽 \\ + \cmd{fboxsep} & 3pt & \cmd{fbox} 或 \cmd{framebox} 等带框盒子的内边距 \\[1ex] + \cmd{arraycolsep} & 5pt & \env{array} 环境的表格项前后的间距 \\ + \cmd{tabcolsep} & 6pt & \env{tabular} 环境的表格项前后的间距 \\ + \cmd{arrayrulewidth} & 0.4pt & 表格线宽 \\ + \cmd{doublerulesep} & 2pt & 连续两根表格线之间的间距 \\[1ex] + \cmd{abovecaptionskip} & 10pt & \cmd{caption} 命令位于图表下方时,与上方图表的间距 \\ + \cmd{belowcaptionskip} & 0pt & \cmd{caption} 命令位于图表上方时,与下方图表的间距 \\[1ex] + \cmd{columnsep} & 10pt & 双栏排版下两栏的间距 \\ + \cmd{columnseprule} & 0pt & 双栏排版下两栏之间竖线的宽度 \\ + \hline +\end{tabular} +\begin{quotation}\footnotesize% +注:\cmd{arraycolsep} 和 \cmd{tabcolsep} 是每个表格项本身前后的间距(表格线前后无间距;\texttt{@} 列格式会消除与前后表格项的间距)。 +两个表格项之间的间距相当于 2\cmd{arraycolsep} 或 2\cmd{tabcolsep}。 +\end{quotation} +\end{table} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/fdl.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/fdl.tex new file mode 100644 index 00000000000..820a486b1fb --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/fdl.tex @@ -0,0 +1,490 @@ +\chapter{GNU Free Documentation License} + +\begingroup \small + +\begin{center} +Version 1.3, 3 November 2008 +\end{center} +\bigskip + +Copyright \copyright\ 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. \texttt{} + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +\begin{flushleft} +{\large\bfseries\sffamily 0. Preamble\par} +\end{flushleft} + +The purpose of this License is to make a manual, textbook, or other +functional and useful document ``free'' in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of ``copyleft'', which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +\begin{flushleft} +{\large\bfseries\sffamily 1. APPLICABILITY AND DEFINITIONS\par} +\end{flushleft} + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``\textbf{Document}'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``\textbf{you}''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A ``\textbf{Modified Version}'' of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A ``\textbf{Secondary Section}'' is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (Thus, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The ``\textbf{Invariant Sections}'' are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The ``\textbf{Cover Texts}'' are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A ``\textbf{Transparent}'' copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``\textbf{Opaque}''. + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The ``\textbf{Title Page}'' means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, ``Title Page'' means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The ``\textbf{publisher}'' means any person or entity that distributes +copies of the Document to the public. + +A section ``\textbf{Entitled XYZ}'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``\textbf{Acknowledgements}'', +``\textbf{Dedications}'', ``\textbf{Endorsements}'', or ``\textbf{History}''.) +To ``\textbf{Preserve the Title}'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + + +\begin{flushleft} +{\large\bfseries\sffamily 2. VERBATIM COPYING\par} +\end{flushleft} + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section~3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +\begin{flushleft} +{\large\bfseries\sffamily 3. COPYING IN QUANTITY\par} +\end{flushleft} + + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +\begin{flushleft} +{\large\bfseries\sffamily 4. MODIFICATIONS\par} +\end{flushleft} + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +\begin{itemize} +\item[A.] + Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. + +\item[B.] + List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. + +\item[C.] + State on the Title page the name of the publisher of the + Modified Version, as the publisher. + +\item[D.] + Preserve all the copyright notices of the Document. + +\item[E.] + Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + +\item[F.] + Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. + +\item[G.] + Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. + +\item[H.] + Include an unaltered copy of this License. + +\item[I.] + Preserve the section Entitled ``History'', Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled ``History'' in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. + +\item[J.] + Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the ``History'' section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. + +\item[K.] + For any section Entitled ``Acknowledgements'' or ``Dedications'', + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. + +\item[L.] + Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. + +\item[M.] + Delete any section Entitled ``Endorsements''. Such a section + may not be included in the Modified Version. + +\item[N.] + Do not retitle any existing section to be Entitled ``Endorsements'' + or to conflict in title with any Invariant Section. + +\item[O.] + Preserve any Warranty Disclaimers. +\end{itemize} + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled ``Endorsements'', provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +\begin{flushleft} +{\large\bfseries\sffamily 5. COMBINING DOCUMENTS\par} +\end{flushleft} + + +You may combine the Document with other documents released under this +License, under the terms defined in section~4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all sections +Entitled ``Endorsements''. + +\begin{flushleft} +{\large\bfseries\sffamily 6. COLLECTIONS OF DOCUMENTS\par} +\end{flushleft} + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +\begin{flushleft} +{\large\bfseries\sffamily 7. AGGREGATION WITH INDEPENDENT WORKS\par} +\end{flushleft} + + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section~3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + + +\begin{flushleft} +{\large\bfseries\sffamily 8. TRANSLATION\par} +\end{flushleft} + + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section~4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section~4) to Preserve +its Title (section~1) will typically require changing the actual +title. + + +\begin{flushleft} +{\large\bfseries\sffamily 9. TERMINATION\par} +\end{flushleft} + + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + + +\begin{flushleft} +{\large\bfseries\sffamily 10. FUTURE REVISIONS OF THIS LICENSE\par} +\end{flushleft} + + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +\texttt{http://www.gnu.org/copyleft/}. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + + +\begin{flushleft} +{\large\bfseries\sffamily 11. RELICENSING\par} +\end{flushleft} + + +``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the +site means any set of copyrightable works thus published on the MMC +site. + +``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +``Incorporate'' means to publish or republish a Document, in whole or +in part, as part of another Document. + +An MMC is ``eligible for relicensing'' if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole +or in part into the MMC, (1) had no cover texts or invariant sections, +and (2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + +\endgroup + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.contrib.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.contrib.tex new file mode 100644 index 00000000000..87d7156b436 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.contrib.tex @@ -0,0 +1,238 @@ +\chapter{中文版致谢} + +\section*{5.05 中文版致谢} + +对 lshort-zh-cn 的新一轮修订在 China\TeX{} 交流 QQ 群 (91940767) 的网友支持下完成。 +参与此次修订的朋友包括: + +\begin{center} +\begin{tabular}{lll} + \toprule + 网友 ID & E-mail \\ + \midrule + hello & 312439151@qq.com \\ + $\varepsilon$ & 554502177@qq.com \\ + \bottomrule +\end{tabular} +\end{center} + +\noindent\dotfill + +\section*{4.20 中文版致谢} + +中文 \TeX{} 学会启动的 lshort-zh-cn 修正计划! +本项计划历时八个月,参加的朋友有: + +\begin{center} +\begin{tabular}{ll} +\toprule +\textbf{\hologo{CTeX} 论坛 ID} & \textbf{翻译章节} \\ +\midrule +zpxing & 前言、第二章、第五章 1--2.4 {\&} 3、第六章 \\ +Frogge & 第一章 \\ +liwenjun & 第三章 \\ +lijian605 & 第四章 \\ +gprsnl & 第五章 2.5--2.11 \\ +\bottomrule +\end{tabular} +\end{center} + +haginile 和 Frogge 通读了全篇,并给出了详细的勘误表。 +blackold 对于第二章亦有所贡献。最后由 zpxing 统筹全书。 + +\noindent\dotfill + +\section*{3.20 中文版致谢} + +本文档的翻译工作由 \hologo{CTeX} 版主“经典问题”倡议,历经近十个月才得以完成。 +期间参与翻译工作的朋友有: + +\begin{center} +\begin{tabular}{lll} +\toprule +\textbf{\hologo{CTeX} 论坛 ID} & \textbf{翻译章节} & \textbf{源文件名} \\ +\midrule +经典问题 & 前言 & overview.tex \\ +高原之狼 & 第一章 & things.tex \\ +controlong & 第二章 & typeset.tex \\ +cxterm & 第三章 & math.tex, lssym.tex \\ +aloft & 第四章 & spec.tex \\ +ganzhi & 第五章 & custom.tex \\ +\bottomrule +\end{tabular} +\end{center} + +\vspace{20pt} + +\begin{flushright} +\large\textbf{在此特向这些奉献者表示感谢!} +\end{flushright} + +\chapter{英文版致谢} + +\noindent Much of the material used in this introduction comes from an +Austrian introduction to \LaTeX{} 2.09 written in German by: +\begin{verse} +\contrib{Hubert Partl}{partl@mail.boku.ac.at}% +{Zentraler Informatikdienst der Universit\"at f\"ur Bodenkultur Wien} +\contrib{Irene Hyna}{Irene.Hyna@bmwf.ac.at}% + {Bundesministerium f\"ur Wissenschaft und Forschung Wien} +\contrib{Elisabeth Schlegl}{no email}% + {in Graz} +\end{verse} + +If you are interested in the German document, you can find a version +updated for \LaTeXe{} by J\"org Knappen at +\CTAN|info/lshort/german| + +\newpage \noindent +The following individuals helped with corrections, suggestions and +material to improve this paper. They put in a big effort to help me +get this document into its present shape. I would like to +sincerely thank all of them. Naturally, all the mistakes you'll find +in this book are mine. If you ever find a word that is spelled +correctly, it must have been one of the people below dropping me a +line. + +\begin{flushleft}\small +Eric~Abrahamsen, % +Lenimar~Nunes~de~Andrade, % 12 Nov 1999 +Eilinger~August, % +Rosemary~Bailey, % 0.2 +Barbara~Beeton, % +Marc~Bevand, % +Connor~Blakey, % it's Ligatures! +Salvatore~Bonaccorso, % +Pietro~Braione, % +Friedemann~Brauer, % 3.4 +Markus~Br\"uhwiler, % +Jan~Busa, % +David~Carlisle, % GONE 1.0 +Neil~Carter, % +Carl~Cerecke, % +Mike~Chapman, % 3.16 +Pierre~Chardaire, % +Xingyou~Chen, % 5.04 +Christopher~Chin, % 3.1 +Diego~Clavadetscher, % +Wim~van~Dam, % GONE 2.2 +Benjamin~Deschwanden % +Jan~Dittberner, % 3.15 +Michael~John~Downes, % 14 Oct 1999 +Matthias~Dreier, % +David~Dureisseix, % 1.1 +Hans~Ehrbar, % +Elliot, % GONE 1.1 +Rockrush~Engch, % +William~Faulk, % +Robin~Fairbairns, % 0.2 1.0 +Johan~Falk, % 5.0.1 +J\"org~Fischer, % 3.16 +Frank~Fischli, % +Daniel~Flipo, % +Frank, % 11 Feb 2000 +Mic~Milic~Frederickx, % +David~Frey, % 2.2 +Erik~Frisk, % 3.4 +Hans~Fugal, % +Robert~Funnell, % 5.1 +Greg~Gamble, % 2.2 +Andy~Goth, % +Cyril~Goutte, % 2.1 2.2 +Kasper~B.~Graversen, % +Arlo~Griffiths, % +Alexandre~Guimond, % 0.9 +Neil~Hammond, % 0.3 +Christoph~Hamburger, % +Rasmus~Borup~Hansen, % GONE 0.2 0.9 0.91 0.92 1.9.9 +Joseph~Hilferty, % +Daniel~Hirsbrunner, % +Martien~Hulsen, % 1.0 1.1 +Bj\"orn Hvittfeldt, % 3.13 +Morten~H\o gholm, % +Werner~Icking, % 3.1 +Eric~Jacoboni, % GONE 0.1 0.9 +Jakob, % +Alan~Jeffrey, % 0.2 +Martin~Jenkins, % xqp.ltd@gmail.com 5.04 +Byron~Jones, % 1.1 +David~Jones, % GONE 1.1 +Johannes-Maria~Kaltenbach, % 3.01 +Nils~Kanning, % +Andrzej~Kawalec, % GONE 1.9.9 +Christian~Kern, % 2.1 +Alain~Kessi, % 2.2 +Axel~Kielhorn, % +Sander~de~Kievit, % +Kjetil~Kjernsmo, % 3.2 +Tobias~Klauser, % 4.17 +J\"org~Knappen, % 0.1 +Michael~Koundouros, % +Matt~Kraai, % +Tobias~Krewer, % +Flori~Lambrechts, % +Mike~Lee, % +Maik~Lehradt, % 0.1 +R\'emi~Letot, % +Axel~Liljencrantz, % +Jasper~Loy, % +Johan~Lundberg, % +Martin~Maechler, % 2.2 +Alexander~Mai, % 3.8 +Claus~Malten, % GONE 1.1 +Kevin~Van~Maren, % 24 Nov 1999 +Pablo~Markin, +I.~J.~Vera~Mar\'un, % +Hendrik~Maryns, % +Chris~McCormack, % GONE 0.1 +Aleksandar~S.~Milosevic, % +Henrik~Mitsch, % +Stefan~M.~Moser, % +Philipp~Nagele, % +Richard~Nagy, % +Manuel~Oetiker, % +Urs~Oswald, % +Hubert~Partl, % 0.2 1.1 +Marcelo~Pasin, % +Martin~Pfister, % +Lan~Thuy~Pham, % +Breno~Pietracci, % +Demerson~Andre~Polli, % +Maksym~Polyakov, % +Nikos~Pothitos, % +John~Refling, % 0.1 0.9 +Mike~Ressler, % 0.1 0.2 0.9 1.0 1.9.9 +Brian~Ripley, % 2.1 +Kurt~Rosenfeld, % +Bernd~Rosenlecher, % <9rosenle@informatik.uni-hamburg.de> 10 Feb 2000 +Chris~Rowley, % 0.91 +Young~U.~Ryu, % 2.1 +Risto~Saarelma, % +Andr{\'a}s~Salamon, % +Jos\'e~Carlos~Santos, % +Christopher~Sawtell, % 1 Sep 1999 +Gilles~Schintgen, % +Craig~Schlenter, % 0.1 0.2 0.9 +Hanspeter~Schmid, % +Baron~Schwartz, % +Jordi~Serra~i~Solanich, % +Miles~Spielberg, % +Susan~Stewart, +Matthieu~Stigler, +Geoffrey~Swindale, % +Laszlo~Szathmary, % +Boris~Tobotras, % +Josef~Tkadlec, % 2.0 2.2 +Scott~Veirs, % +Didier~Verna, % 2.2 +Carl-Gustav~Werner, % 11 Oct 1999, 3.16 +Fabian~Wernli, % 3.2 +Matthew~Widmann, % +David~Woodhouse, % 3.16 +Chris~York, % 21 Nov 1999 +Rick~Zaccone, % 2.2 +Fritz~Zaucker, % 3.0 +and Mikhail~Zotov. % 3.1 +\end{flushleft} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.overview.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.overview.tex new file mode 100644 index 00000000000..f93bf7d8de0 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/preface.overview.tex @@ -0,0 +1,58 @@ +\chapter{前言} + +\LaTeX{} \cite{manual} 是一个文档准备系统 (Document Preparing System),它非常适用于生成高印刷质量 +的科技类和数学类文档。它也能够生成所有其他种类的文档,小到简单的信件,大到完整的书籍。 +\LaTeX{} 使用 \TeX{} \cite{texbook} 作为它的排版引擎。 + +这份短小的手册描述了 \LaTeXe{} 的使用,对 \LaTeX{} 的大多数应用来说应该是足够了。 +参考文献 \cite{manual,companion} 对 \LaTeX{} 系统提供了完整的描述。 + +\bigskip +本手册在英文版 lshort 的基础上进行了适当的重新编排,共有八章和两篇附录: +\begin{description} + \item[第一章] 讲述 \LaTeX{} 的来源,源代码的基本结构,以及如何编译源代码生成文档。 + \item[第二章] 讲述在 \LaTeX{} 中如何书写文字,包括中文。 + \item[第三章] 讲述文档排版的基本元素——标题、目录、列表、图片、表格等等。结合前一章的内容,你应当能够制作内容较为丰富的文档了。 + \item[第四章] \LaTeX{} 排版公式的能力是众人皆知的。本章的内容涉及了一些排版公式经常用到的命令、环境和符号。 + 章节末尾列出了 \LaTeX{} 常见的数学符号。 + \item[第五章] 介绍了如何修改文档的一些基本样式,包括字体、段落、页面尺寸、页眉页脚等。 + \item[第六章] 介绍了 \LaTeX{} 的一些扩展功能:排版参考文献、排版索引、排版带有颜色和超链接的电子文档。 + \item[第七章] 介绍了如何在 \LaTeX{} 里使用 \hologo{TikZ} 绘图。作为入门手册,这一部分点到为止。 + \item[第八章] 当你相当熟悉前面几章的内容,需要自己编写命令和宏包扩展 \LaTeX{} 的功能时,本章介绍了一些基本的命令满足你的需求。 +\end{description} +\begin{description} + \item[附录A] 介绍了如何安装 \TeX{} 发行版和更新宏包。 + \item[附录B] 当新手遇到错误和需要寻求更多帮助时,本章提供了一些基本的参考。 +\end{description} + +\bigskip +这些章节是循序渐进的,建议刚刚熟悉 \LaTeX{} 的读者按顺序阅读。一定要认真阅读例子的源代码,它们贯穿全篇手册,包含了很多的信息。 + +\bigskip +如果你已经对 \LaTeX{} 较为熟练,本手册的资源已不足够解决你的问题时,请访问``Comprehensive +\TeX{} Archive Network'' (\texttt{CTAN}) 站点,主页是 \url{www.ctan.org}。 +所有的宏包也可以从 \url{mirrors.ctan.org} 和遍布全球的各个镜像站点中获得。 + +在本书中你会找到其他引用 \texttt{CTAN} 的地方,形式为 \texttt{CTAN://} 和之后的树状结构。 +引用本身是一个超链接,点击后将打开内容在 \texttt{CTAN} 上相应位置的页面。 + +要在自己的电脑上安装 \TeX{} 发行版,请参考附录 \ref{app:install} 中的内容。 +各个操作系统下的 \TeX{} 发行版位于 \CTAN|systems|。 + +\bigskip +如果你有意在这份文档中增加、删除或者改变一些内容,请通知作者。作者对 \LaTeX{} +初学者的反馈特别感兴趣,尤其是关于这份介绍哪些内容很容易理解,哪些内容可能需要更好地解释, +而哪些内容由于太过难以理解、非常不常用而不适宜放在本手册。 + +\bigskip +\begin{flushright} +\hologo{CTeX} 开发小组\par +\url{https://github.com/CTeX-org} +\end{flushright} + +\vfill + +\noindent\begingroup\small lshort 的的最新中文版本位于 \CTAN|info/lshort/chinese|。 +如果用户对其他语言的版本感兴趣,请浏览 \CTAN|info/lshort|。\endgroup + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/sec.symbol.table.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/sec.symbol.table.tex new file mode 100644 index 00000000000..33ce2cd11d8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/sec.symbol.table.tex @@ -0,0 +1,393 @@ +% Definitions +\def\lsym{$\mathsurround=0pt {}^\ell$} +\def\LSYM #1{$#1$ & \texttt{\string#1}\lsym} + +\def\SYM #1{$#1$ & \texttt{\string#1}} +\def\BIGSYM #1{$#1$ & $\displaystyle #1$ & \texttt{\string#1}} +\def\ACC #1#2{$#1{#2}$ & \texttt{\string#1}\marg*{#2}} +\def\DEL #1{$\big#1 \bigg#1$ & \texttt{\string#1}} + +\def\AMSSYM #1{$#1$ & \texttt{\string#1}} +% These symbols rely on `amsmath' package +\def\AMSM #1{$#1$ & \textcolor{blue}{\texttt{\string#1}}} +\def\AMSACC#1#2{$#1{#2}$ & \textcolor{blue}{\texttt{\string#1}}\marg*{#2}} +\def\AMSBIG #1{$#1$ & $\displaystyle #1$ & \textcolor{blue}{\texttt{\string#1}}} + +\def\SC #1{#1 & \texttt{\string#1}} + +\newenvironment{symbols}[1]% + {\small\def\arraystretch{1.1} + \begin{tabular}{@{}#1@{}}}% + {\end{tabular}} + +\clearpage +\section{符号表}\label{sec:math-tables} + +\pkgindex{latexsym} +有几个注意事项: +\begin{enumerate} + \item \textcolor{blue}{蓝色}的命令依赖 \pkg{amsmath} 宏包(非 \pkg{amssymb} 宏包); + \item 带有角标\lsym 的符号命令依赖 \pkg{latexsym} 宏包。 +\end{enumerate} + +\subsection{\LaTeX{} 普通符号} +\symindex{dag,ddag,P,S,copyright,pounds} + +\begin{table}[htp] +\centering +\caption{文本/数学模式通用符号}\label{tbl:general-syms} +\begin{quote}\footnotesize% +这些符号可用于文本和数学模式。 +\end{quote} +\begin{symbols}{*4{cl}} +\hline + \SC{\{} & \SC{\}} & \SC{\$} & \SC{\%} \\ + \SC{\dag} & \SC{\S} & \SC{\copyright} & \SC{\dots} \\ + \SC{\ddag} & \SC{\P} & \SC{\pounds} & \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{希腊字母} \label{tbl:math-greek} +\begin{quote}\footnotesize% +\cmd{Alpha},\cmd{Beta} 等希腊字母符号不存在,因为它们和拉丁字母 A,B 等一模一样; +小写字母里也不存在 \cmd{omicron},直接用拉丁字母 $o$ 代替。 +\end{quote} +\begin{symbols}{*4{cl}} +\hline + \SYM{\alpha} & \SYM{\theta} & \SYM{o} & \SYM{\upsilon} \\ + \SYM{\beta} & \SYM{\vartheta} & \SYM{\pi} & \SYM{\phi} \\ + \SYM{\gamma} & \SYM{\iota} & \SYM{\varpi} & \SYM{\varphi} \\ + \SYM{\delta} & \SYM{\kappa} & \SYM{\rho} & \SYM{\chi} \\ + \SYM{\epsilon} & \SYM{\lambda} & \SYM{\varrho} & \SYM{\psi} \\ + \SYM{\varepsilon}& \SYM{\mu} & \SYM{\sigma} & \SYM{\omega} \\ + \SYM{\zeta} & \SYM{\nu} & \SYM{\varsigma} & \\ + \SYM{\eta} & \SYM{\xi} & \SYM{\tau} & \\[1ex] + \SYM{\Gamma} & \SYM{\Lambda} & \SYM{\Sigma} & \SYM{\Psi} \\ + \SYM{\Delta} & \SYM{\Xi} & \SYM{\Upsilon} & \SYM{\Omega} \\ + \SYM{\Theta} & \SYM{\Pi} & \SYM{\Phi} & \\[1ex] + \AMSM{\varGamma} & \AMSM{\varLambda}& \AMSM{\varSigma} & \AMSM{\varPsi} \\ + \AMSM{\varDelta} & \AMSM{\varXi} & \AMSM{\varUpsilon}& \AMSM{\varOmega} \\ + \AMSM{\varTheta} & \AMSM{\varPi} & \AMSM{\varPhi} & \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{二元关系符} \label{tbl:math-rel} +\begin{quote}\footnotesize% +所有的二元关系符都可以加 \cmd{not} 前缀得到相反意义的关系符,例如 \cmd{not}\texttt{=} 就得到不等号(同 \cmd{ne})。 +\end{quote} +\begin{symbols}{*3{cl}} +\hline + \SYM{<} & \SYM{>} & \SYM{=} \\ + \SYM{\leq} or \cmd{le} & \SYM{\geq} or \cmd{ge} & \SYM{\equiv} \\ + \SYM{\ll} & \SYM{\gg} & \SYM{\doteq} \\ + \SYM{\prec} & \SYM{\succ} & \SYM{\sim} \\ + \SYM{\preceq} & \SYM{\succeq} & \SYM{\simeq} \\ + \SYM{\subset} & \SYM{\supset} & \SYM{\approx} \\ + \SYM{\subseteq} & \SYM{\supseteq} & \SYM{\cong} \\ + \LSYM{\sqsubset} & \LSYM{\sqsupset} & \LSYM{\Join} \\ + \SYM{\sqsubseteq} & \SYM{\sqsupseteq} & \SYM{\bowtie} \\ + \SYM{\in} & \SYM{\ni}, \cmd{owns} & \SYM{\propto} \\ + \SYM{\vdash} & \SYM{\dashv} & \SYM{\models} \\ + \SYM{\mid} & \SYM{\parallel} & \SYM{\perp} \\ + \SYM{\smile} & \SYM{\frown} & \SYM{\asymp} \\ + \SYM{:} & \SYM{\notin} & \SYM{\neq} or \cmd{ne} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{二元运算符}\label{tbl:math-op} +\begin{symbols}{*3{cl}} +\hline + \SYM{+} & \SYM{-} & \\ + \SYM{\pm} & \SYM{\mp} & \SYM{\triangleleft} \\ + \SYM{\cdot} & \SYM{\div} & \SYM{\triangleright}\\ + \SYM{\times} & \SYM{\setminus} & \SYM{\star} \\ + \SYM{\cup} & \SYM{\cap} & \SYM{\ast} \\ + \SYM{\sqcup} & \SYM{\sqcap} & \SYM{\circ} \\ + \SYM{\vee}, \cmd{lor}& \SYM{\wedge},\cmd{land} & \SYM{\bullet} \\ + \SYM{\oplus} & \SYM{\ominus} & \SYM{\diamond} \\ + \SYM{\odot} & \SYM{\oslash} & \SYM{\uplus} \\ + \SYM{\otimes} & \SYM{\bigcirc} & \SYM{\amalg} \\ + \SYM{\bigtriangleup} &\SYM{\bigtriangledown}& \SYM{\dagger} \\ + \LSYM{\lhd} & \LSYM{\rhd} & \SYM{\ddagger} \\ + \LSYM{\unlhd} & \LSYM{\unrhd} & \SYM{\wr} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{巨算符}\label{tbl:math-bigop} +\def\arraystretch{2.2} +\begin{symbols}{*3{ccl}} +\hline + \BIGSYM{\sum} & \BIGSYM{\bigcup} & \BIGSYM{\bigvee} \\ + \BIGSYM{\prod} & \BIGSYM{\bigcap} & \BIGSYM{\bigwedge} \\ + \BIGSYM{\coprod} & \BIGSYM{\bigsqcup} & \BIGSYM{\biguplus} \\ + \BIGSYM{\int} & \BIGSYM{\oint} & \BIGSYM{\bigodot} \\ + \BIGSYM{\bigoplus} & \BIGSYM{\bigotimes} & \\ + \AMSBIG{\iint} & \AMSBIG{\iiint} & \AMSBIG{\iiiint} \\ + \AMSBIG{\idotsint} & & \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{数学重音符号}\label{tbl:math-accents} +\begin{quote}\footnotesize% +最后一个 \cmd{wideparen} 依赖 \pkg{yhmath} 宏包。 +\end{quote} +\begin{symbols}{*3{cl}} +\hline +\ACC{\hat}{a} & \ACC{\check}{a} & \ACC{\tilde}{a} \\ +\ACC{\acute}{a} & \ACC{\grave}{a} & \ACC{\breve}{a} \\ +\ACC{\bar}{a} & \ACC{\vec}{a} & \ACC{\mathring}{a} \\ +\ACC{\dot}{a} & \ACC{\ddot}{a} & \AMSACC{\dddot}{a} \\ +\AMSACC{\ddddot}{a} \\[1ex] +\ACC{\widehat}{AAA} & \ACC{\widetilde}{AAA} & \ACC{\wideparen}{AAA} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{箭头} \label{tbl:math-arrows} +\begin{symbols}{*2{cl}} +\hline + \SYM{\leftarrow} or \cmd{gets} & \SYM{\longleftarrow} \\ + \SYM{\rightarrow} or \cmd{to} & \SYM{\longrightarrow} \\ + \SYM{\leftrightarrow} & \SYM{\longleftrightarrow} \\ + \SYM{\Leftarrow} & \SYM{\Longleftarrow} \\ + \SYM{\Rightarrow} & \SYM{\Longrightarrow} \\ + \SYM{\Leftrightarrow} & \SYM{\Longleftrightarrow}\\ + \SYM{\mapsto} & \SYM{\longmapsto} \\ + \SYM{\hookleftarrow} & \SYM{\hookrightarrow} \\ + \SYM{\leftharpoonup} & \SYM{\rightharpoonup} \\ + \SYM{\leftharpoondown} & \SYM{\rightharpoondown} \\ + \SYM{\rightleftharpoons} & \SYM{\iff} \\ + \SYM{\uparrow} & \SYM{\downarrow} \\ + \SYM{\updownarrow} & \SYM{\Uparrow} \\ + \SYM{\Downarrow} & \SYM{\Updownarrow} \\ + \SYM{\nearrow} & \SYM{\searrow} \\ + \SYM{\swarrow} & \SYM{\nwarrow} \\ + \LSYM{\leadsto} & \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{作为重音的箭头符号} \label{tbl:math-arrow-accents} +\begin{symbols}{*2{cl}} +\hline +\ACC{\overrightarrow}{AB} & \AMSACC{\underrightarrow}{AB} \\ +\ACC{\overleftarrow}{AB} & \AMSACC{\underleftarrow}{AB} \\ +\AMSACC{\overleftrightarrow}{AB} & \AMSACC{\underleftrightarrow}{AB} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{定界符}\label{tbl:math-delims} +\begin{quote}\footnotesize% +\pkg{amsmath} 还定义了 \amscmd{lvert}、\amscmd{rvert} 和 \amscmd{lVert}、\amscmd{rVert}, +分别作为 \cmd{vert} 和 \cmd{Vert} 对应的开符号(左侧)和闭符号(右侧)的命令。 +\end{quote} +\begin{symbols}{*4{cl}} +\hline + \SYM{(} & \SYM{)} & \SYM{\uparrow} & \SYM{\downarrow} \\ + \SYM{[} or \cmd{lbrack} & \SYM{]} or \cmd{rbrack} & \SYM{\Uparrow} & \SYM{\Downarrow} \\ + \SYM{\{} or \cmd{lbrace} & \SYM{\}} or \cmd{rbrace} & \SYM{\updownarrow} & \SYM{\Updownarrow} \\ + \SYM{|} or \cmd{vert} & \SYM{\|} or \cmd{Vert} & \SYM{\lceil} & \SYM{\rceil} \\ + \SYM{\langle} & \SYM{\rangle} & \SYM{\lfloor} & \SYM{\rfloor} \\ + \SYM{/} & \SYM{\backslash} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{用于行间公式的大定界符}\label{tbl:math-large-delims} +\def\arraystretch{1.8} +\begin{symbols}{*3{cl}} +\hline + \DEL{\lgroup} & \DEL{\rgroup} & \DEL{\lmoustache} \\ + \DEL{\arrowvert} & \DEL{\Arrowvert} & \DEL{\bracevert} \\ + \DEL{\rmoustache} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{其他符号}\label{tbl:math-misc} +\begin{symbols}{*4{cl}} +\hline + \SYM{\dots} & \SYM{\cdots} & \SYM{\vdots} & \SYM{\ddots} \\ + \SYM{\hbar} & \SYM{\imath} & \SYM{\jmath} & \SYM{\ell} \\ + \SYM{\Re} & \SYM{\Im} & \SYM{\aleph} & \SYM{\wp} \\ + \SYM{\forall} & \SYM{\exists} & \LSYM{\mho} & \SYM{\partial} \\ + \SYM{'} & \SYM{\prime} & \SYM{\emptyset} & \SYM{\infty} \\ + \SYM{\nabla} & \SYM{\triangle} & \LSYM{\Box} & \LSYM{\Diamond} \\ + \SYM{\bot} & \SYM{\top} & \SYM{\angle} & \SYM{\surd} \\ + \SYM{\diamondsuit} & \SYM{\heartsuit} & \SYM{\clubsuit} & \SYM{\spadesuit} \\ + \SYM{\neg} or \cmd{lnot} & \SYM{\flat} & \SYM{\natural} & \SYM{\sharp} \\ +\hline +\end{symbols} +\end{table} + +\clearpage +\subsection{\hologo{AmS} 符号} + +本小节所有符号依赖 \pkg{amssymb} 宏包。 + +\begin{table}[htp] +\centering +\caption{\AmS{} 希腊字母和希伯来字母} \label{tbl:ams-greek-hebrew} +\begin{symbols}{*5{cl}} +\hline +\AMSSYM{\digamma} &\AMSSYM{\varkappa} & \AMSSYM{\beth} &\AMSSYM{\gimel} & \AMSSYM{\daleth}\\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{\AmS{} 二元关系符} \label{tbl:ams-rel} +\begin{symbols}{*3{cl}} +\hline + \AMSSYM{\lessdot} & \AMSSYM{\gtrdot} & \AMSSYM{\doteqdot} \\ + \AMSSYM{\leqslant} & \AMSSYM{\geqslant} & \AMSSYM{\risingdotseq} \\ + \AMSSYM{\eqslantless} & \AMSSYM{\eqslantgtr} & \AMSSYM{\fallingdotseq} \\ + \AMSSYM{\leqq} & \AMSSYM{\geqq} & \AMSSYM{\eqcirc} \\ + \AMSSYM{\lll} or \cmd{llless}& \AMSSYM{\ggg} & \AMSSYM{\circeq} \\ + \AMSSYM{\lesssim} & \AMSSYM{\gtrsim} & \AMSSYM{\triangleq} \\ + \AMSSYM{\lessapprox} & \AMSSYM{\gtrapprox} & \AMSSYM{\bumpeq} \\ + \AMSSYM{\lessgtr} & \AMSSYM{\gtrless} & \AMSSYM{\Bumpeq} \\ + \AMSSYM{\lesseqgtr} & \AMSSYM{\gtreqless} & \AMSSYM{\thicksim} \\ + \AMSSYM{\lesseqqgtr} & \AMSSYM{\gtreqqless} & \AMSSYM{\thickapprox} \\ + \AMSSYM{\preccurlyeq} & \AMSSYM{\succcurlyeq} & \AMSSYM{\approxeq} \\ + \AMSSYM{\curlyeqprec} & \AMSSYM{\curlyeqsucc} & \AMSSYM{\backsim} \\ + \AMSSYM{\precsim} & \AMSSYM{\succsim} & \AMSSYM{\backsimeq} \\ + \AMSSYM{\precapprox} & \AMSSYM{\succapprox} & \AMSSYM{\vDash} \\ + \AMSSYM{\subseteqq} & \AMSSYM{\supseteqq} & \AMSSYM{\Vdash} \\ + \AMSSYM{\shortparallel} & \AMSSYM{\Supset} & \AMSSYM{\Vvdash} \\ + \AMSSYM{\blacktriangleleft} & \AMSSYM{\sqsupset} & \AMSSYM{\backepsilon} \\ + \AMSSYM{\vartriangleright} & \AMSSYM{\because} & \AMSSYM{\varpropto} \\ + \AMSSYM{\blacktriangleright}& \AMSSYM{\Subset} & \AMSSYM{\between} \\ + \AMSSYM{\trianglerighteq} & \AMSSYM{\smallfrown} & \AMSSYM{\pitchfork} \\ + \AMSSYM{\vartriangleleft} & \AMSSYM{\shortmid} & \AMSSYM{\smallsmile} \\ + \AMSSYM{\trianglelefteq} & \AMSSYM{\therefore} & \AMSSYM{\sqsubset} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{\hologo{AmS} 二元运算符} \label{tbl:ams-op} +\begin{symbols}{*3{cl}} +\hline + \AMSSYM{\dotplus} & \AMSSYM{\centerdot} & \\ + \AMSSYM{\ltimes} & \AMSSYM{\rtimes} & \AMSSYM{\divideontimes} \\ + \AMSSYM{\doublecup} & \AMSSYM{\doublecap} & \AMSSYM{\smallsetminus} \\ + \AMSSYM{\veebar} & \AMSSYM{\barwedge} & \AMSSYM{\doublebarwedge}\\ + \AMSSYM{\boxplus} & \AMSSYM{\boxminus} & \AMSSYM{\circleddash} \\ + \AMSSYM{\boxtimes} & \AMSSYM{\boxdot} & \AMSSYM{\circledcirc} \\ + \AMSSYM{\intercal} & \AMSSYM{\circledast} & \AMSSYM{\rightthreetimes} \\ + \AMSSYM{\curlyvee} & \AMSSYM{\curlywedge} & \AMSSYM{\leftthreetimes} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{\hologo{AmS} 箭头}\label{tbl:ams-arrows} +\begin{symbols}{*2{cl}} +\hline + \AMSSYM{\dashleftarrow} & \AMSSYM{\dashrightarrow} \\ + \AMSSYM{\leftleftarrows} & \AMSSYM{\rightrightarrows} \\ + \AMSSYM{\leftrightarrows} & \AMSSYM{\rightleftarrows} \\ + \AMSSYM{\Lleftarrow} & \AMSSYM{\Rrightarrow} \\ + \AMSSYM{\twoheadleftarrow} & \AMSSYM{\twoheadrightarrow} \\ + \AMSSYM{\leftarrowtail} & \AMSSYM{\rightarrowtail} \\ + \AMSSYM{\leftrightharpoons} & \AMSSYM{\rightleftharpoons} \\ + \AMSSYM{\Lsh} & \AMSSYM{\Rsh} \\ + \AMSSYM{\looparrowleft} & \AMSSYM{\looparrowright} \\ + \AMSSYM{\curvearrowleft} & \AMSSYM{\curvearrowright} \\ + \AMSSYM{\circlearrowleft} & \AMSSYM{\circlearrowright} \\ + \AMSSYM{\multimap} & \AMSSYM{\upuparrows} \\ + \AMSSYM{\downdownarrows} & \AMSSYM{\upharpoonleft} \\ + \AMSSYM{\upharpoonright} & \AMSSYM{\downharpoonright} \\ + \AMSSYM{\rightsquigarrow} & \AMSSYM{\leftrightsquigarrow}\\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{\hologo{AmS} 反义二元关系符和箭头}\label{tbl:ams-negative} +\begin{symbols}{*3{cl}} +\hline + \AMSSYM{\nless} & \AMSSYM{\ngtr} & \AMSSYM{\varsubsetneqq} \\ + \AMSSYM{\lneq} & \AMSSYM{\gneq} & \AMSSYM{\varsupsetneqq} \\ + \AMSSYM{\nleq} & \AMSSYM{\ngeq} & \AMSSYM{\nsubseteqq} \\ + \AMSSYM{\nleqslant} & \AMSSYM{\ngeqslant} & \AMSSYM{\nsupseteqq} \\ + \AMSSYM{\lneqq} & \AMSSYM{\gneqq} & \AMSSYM{\nmid} \\ + \AMSSYM{\lvertneqq} & \AMSSYM{\gvertneqq} & \AMSSYM{\nparallel} \\ + \AMSSYM{\nleqq} & \AMSSYM{\ngeqq} & \AMSSYM{\nshortmid} \\ + \AMSSYM{\lnsim} & \AMSSYM{\gnsim} & \AMSSYM{\nshortparallel} \\ + \AMSSYM{\lnapprox} & \AMSSYM{\gnapprox} & \AMSSYM{\nsim} \\ + \AMSSYM{\nprec} & \AMSSYM{\nsucc} & \AMSSYM{\ncong} \\ + \AMSSYM{\npreceq} & \AMSSYM{\nsucceq} & \AMSSYM{\nvdash} \\ + \AMSSYM{\precneqq} & \AMSSYM{\succneqq} & \AMSSYM{\nvDash} \\ + \AMSSYM{\precnsim} & \AMSSYM{\succnsim} & \AMSSYM{\nVdash} \\ + \AMSSYM{\precnapprox} & \AMSSYM{\succnapprox} & \AMSSYM{\nVDash} \\ + \AMSSYM{\subsetneq} & \AMSSYM{\supsetneq} & \AMSSYM{\ntriangleleft} \\ + \AMSSYM{\varsubsetneq} & \AMSSYM{\varsupsetneq} & \AMSSYM{\ntriangleright} \\ + \AMSSYM{\nsubseteq} & \AMSSYM{\nsupseteq} & \AMSSYM{\ntrianglelefteq} \\ + \AMSSYM{\subsetneqq} & \AMSSYM{\supsetneqq} & \AMSSYM{\ntrianglerighteq} \\ + \AMSSYM{\nleftarrow} & \AMSSYM{\nrightarrow} & \AMSSYM{\nleftrightarrow} \\ + \AMSSYM{\nLeftarrow} & \AMSSYM{\nRightarrow} & \AMSSYM{\nLeftrightarrow} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{\hologo{AmS} 定界符}\label{tbl:ams-delims} +\begin{symbols}{*4{cl}} +\hline +\AMSSYM{\ulcorner} & \AMSSYM{\urcorner} & \AMSSYM{\llcorner} & \AMSSYM{\lrcorner} \\ +\hline +\end{symbols} +\end{table} + +\begin{table}[htp] +\centering +\caption{\hologo{AmS} 其它符号}\label{tbl:ams-misc} +\begin{symbols}{*3{cl}} +\hline + \AMSSYM{\hbar} & \AMSSYM{\hslash} & \AMSSYM{\Bbbk} \\ + \AMSSYM{\square} & \AMSSYM{\blacksquare} & \AMSSYM{\circledS} \\ + \AMSSYM{\vartriangle} & \AMSSYM{\blacktriangle} & \AMSSYM{\complement} \\ + \AMSSYM{\triangledown} & \AMSSYM{\blacktriangledown}& \AMSSYM{\Game} \\ + \AMSSYM{\lozenge} & \AMSSYM{\blacklozenge} & \AMSSYM{\bigstar} \\ + \AMSSYM{\angle} & \AMSSYM{\measuredangle} & \\ + \AMSSYM{\diagup} & \AMSSYM{\diagdown} & \AMSSYM{\backprime} \\ + \AMSSYM{\nexists} & \AMSSYM{\Finv} & \AMSSYM{\varnothing} \\ + \AMSSYM{\eth} & \AMSSYM{\sphericalangle} & \AMSSYM{\mho} \\ +\hline +\end{symbols} +\end{table} + +\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/titlepage.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/titlepage.tex new file mode 100644 index 00000000000..3a7f4e97ebb --- /dev/null +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/chap/titlepage.tex @@ -0,0 +1,35 @@ +\pdfbookmark{标题页}{title} +\thispagestyle{empty} + +\vspace*{\stretch{1}} +\noindent\begin{minipage}{\textwidth} +\raggedleft +{\huge \bfseries 一份(不太)简短的~\LaTeXe{}~介绍} +\noindent\rule[-1ex]{\textwidth}{5pt}\\[2.5ex] +\hfill\emph{\Large 或~\pageref{lshort-minutes}~分钟了解~\LaTeXe} +\end{minipage} + +\vspace{\stretch{1}} +\noindent\rlap{% + \begin{minipage}{\textwidth} + \linespread{2}\selectfont\raggedleft + {\bfseries 英文作者:} Tobias Oetiker\\ + Hubert Partl, Irene Hyna and Elisabeth Schlegl \\ + {\bfseries 英文版本:} Version~\lshortversionoriginal, \lshortdateoriginal\\[4ex] + {\bfseries 中文翻译:} \hologo{CTeX} 开发小组 \\ + {\bfseries 中文版本:} 版本~\lshortversioncn,\zhdigits*{\the\year}年\zhnumber{\the\month}月 + \end{minipage}% +} + +\vspace{\stretch{2}} + +\newpage\thispagestyle{empty} +\begin{quote}\footnotesize + Copyright \copyright{} {\the\year} Chinese \TeX{} Society. \\ + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. +\end{quote} diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/fdl.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/fdl.tex deleted file mode 100644 index 820a486b1fb..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/fdl.tex +++ /dev/null @@ -1,490 +0,0 @@ -\chapter{GNU Free Documentation License} - -\begingroup \small - -\begin{center} -Version 1.3, 3 November 2008 -\end{center} -\bigskip - -Copyright \copyright\ 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. \texttt{} - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -\begin{flushleft} -{\large\bfseries\sffamily 0. Preamble\par} -\end{flushleft} - -The purpose of this License is to make a manual, textbook, or other -functional and useful document ``free'' in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of ``copyleft'', which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -\begin{flushleft} -{\large\bfseries\sffamily 1. APPLICABILITY AND DEFINITIONS\par} -\end{flushleft} - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The ``\textbf{Document}'', below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as ``\textbf{you}''. You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A ``\textbf{Modified Version}'' of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A ``\textbf{Secondary Section}'' is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The ``\textbf{Invariant Sections}'' are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The ``\textbf{Cover Texts}'' are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A ``\textbf{Transparent}'' copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not ``Transparent'' is called ``\textbf{Opaque}''. - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The ``\textbf{Title Page}'' means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, ``Title Page'' means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -The ``\textbf{publisher}'' means any person or entity that distributes -copies of the Document to the public. - -A section ``\textbf{Entitled XYZ}'' means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as ``\textbf{Acknowledgements}'', -``\textbf{Dedications}'', ``\textbf{Endorsements}'', or ``\textbf{History}''.) -To ``\textbf{Preserve the Title}'' -of such a section when you modify the Document means that it remains a -section ``Entitled XYZ'' according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -\begin{flushleft} -{\large\bfseries\sffamily 2. VERBATIM COPYING\par} -\end{flushleft} - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section~3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -\begin{flushleft} -{\large\bfseries\sffamily 3. COPYING IN QUANTITY\par} -\end{flushleft} - - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -\begin{flushleft} -{\large\bfseries\sffamily 4. MODIFICATIONS\par} -\end{flushleft} - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -\begin{itemize} -\item[A.] - Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. - -\item[B.] - List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. - -\item[C.] - State on the Title page the name of the publisher of the - Modified Version, as the publisher. - -\item[D.] - Preserve all the copyright notices of the Document. - -\item[E.] - Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. - -\item[F.] - Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. - -\item[G.] - Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. - -\item[H.] - Include an unaltered copy of this License. - -\item[I.] - Preserve the section Entitled ``History'', Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled ``History'' in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. - -\item[J.] - Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the ``History'' section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. - -\item[K.] - For any section Entitled ``Acknowledgements'' or ``Dedications'', - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. - -\item[L.] - Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. - -\item[M.] - Delete any section Entitled ``Endorsements''. Such a section - may not be included in the Modified Version. - -\item[N.] - Do not retitle any existing section to be Entitled ``Endorsements'' - or to conflict in title with any Invariant Section. - -\item[O.] - Preserve any Warranty Disclaimers. -\end{itemize} - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled ``Endorsements'', provided it contains -nothing but endorsements of your Modified Version by various -parties---for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -\begin{flushleft} -{\large\bfseries\sffamily 5. COMBINING DOCUMENTS\par} -\end{flushleft} - - -You may combine the Document with other documents released under this -License, under the terms defined in section~4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled ``History'' -in the various original documents, forming one section Entitled -``History''; likewise combine any sections Entitled ``Acknowledgements'', -and any sections Entitled ``Dedications''. You must delete all sections -Entitled ``Endorsements''. - -\begin{flushleft} -{\large\bfseries\sffamily 6. COLLECTIONS OF DOCUMENTS\par} -\end{flushleft} - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -\begin{flushleft} -{\large\bfseries\sffamily 7. AGGREGATION WITH INDEPENDENT WORKS\par} -\end{flushleft} - - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an ``aggregate'' if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section~3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -\begin{flushleft} -{\large\bfseries\sffamily 8. TRANSLATION\par} -\end{flushleft} - - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section~4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled ``Acknowledgements'', -``Dedications'', or ``History'', the requirement (section~4) to Preserve -its Title (section~1) will typically require changing the actual -title. - - -\begin{flushleft} -{\large\bfseries\sffamily 9. TERMINATION\par} -\end{flushleft} - - -You may not copy, modify, sublicense, or distribute the Document -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense, or distribute it is void, and -will automatically terminate your rights under this License. - -However, if you cease all violation of this License, then your license -from a particular copyright holder is reinstated (a) provisionally, -unless and until the copyright holder explicitly and finally -terminates your license, and (b) permanently, if the copyright holder -fails to notify you of the violation by some reasonable means prior to -60 days after the cessation. - -Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - -Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, receipt of a copy of some or all of the same material does -not give you any rights to use it. - - -\begin{flushleft} -{\large\bfseries\sffamily 10. FUTURE REVISIONS OF THIS LICENSE\par} -\end{flushleft} - - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -\texttt{http://www.gnu.org/copyleft/}. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License ``or any later version'' applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. If the Document -specifies that a proxy can decide which future versions of this -License can be used, that proxy's public statement of acceptance of a -version permanently authorizes you to choose that version for the -Document. - - -\begin{flushleft} -{\large\bfseries\sffamily 11. RELICENSING\par} -\end{flushleft} - - -``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any -World Wide Web server that publishes copyrightable works and also -provides prominent facilities for anybody to edit those works. A -public wiki that anybody can edit is an example of such a server. A -``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the -site means any set of copyrightable works thus published on the MMC -site. - -``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 -license published by Creative Commons Corporation, a not-for-profit -corporation with a principal place of business in San Francisco, -California, as well as future copyleft versions of that license -published by that same organization. - -``Incorporate'' means to publish or republish a Document, in whole or -in part, as part of another Document. - -An MMC is ``eligible for relicensing'' if it is licensed under this -License, and if all works that were first published under this License -somewhere other than this MMC, and subsequently incorporated in whole -or in part into the MMC, (1) had no cover texts or invariant sections, -and (2) were thus incorporated prior to November 1, 2008. - -The operator of an MMC Site may republish an MMC contained in the site -under CC-BY-SA on the same site at any time before August 1, 2009, -provided the MMC is eligible for relicensing. - -\endgroup - -\endinput diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn-style.sty b/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn-style.sty index 6f8ae9e3069..3aca98d561a 100644 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn-style.sty +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn-style.sty @@ -8,7 +8,8 @@ % 基本工具宏包 % \RequirePackage{amsmath,amsthm} -\RequirePackage{hologo,ulem,verbatim,fancyvrb,layout,multicol} +\RequirePackage{hologo,verbatim,fancyvrb,layout,multicol} +\RequirePackage[normalem]{ulem} \RequirePackage{colortbl,tabularx,multirow,makecell,booktabs} \RequirePackage{graphicx,xcolor,float,subfig} \RequirePackage{makeidx} @@ -21,17 +22,19 @@ % 中文正文字体使用 Fandol % \PassOptionsToPackage{no-math}{fontspec} -\RequirePackage[zihao=false,scheme=chinese,heading=true]{ctex}[2015/06/24] +\RequirePackage[zihao=false,scheme=chinese,heading=true,fontset=fandol]{ctex}[2015/06/24] % % 字体和符号宏包 % \setmainfont{cmun}[ - Extension = .otf, - UprightFont = *rm, - ItalicFont = *ti, - BoldFont = *bx, - BoldItalicFont = *bi, + Extension = .otf, + UprightFont = *rm, + ItalicFont = *ti, + SlantedFont = *sl, + BoldFont = *bx, + BoldItalicFont = *bi, + BoldSlantedFont = *bl, ] \setsansfont{cmun}[ Extension = .otf, @@ -48,6 +51,10 @@ BoldItalicFont = *tx, ] \RequirePackage{amssymb,latexsym,textcomp,mathrsfs,euscript,yhmath} % 与默认字体不冲突的一些符号包 +% 消除 \t 命令的字体 warning +\AtBeginDocument{%} + \renewcommand*\t[1]{{\edef\restore@font{\the\font}\usefont{OML}{cmm}{m}{it}\accent"7F\restore@font#1}} +} % 调整 layout 宏包的命令使之能够放入浮动体,手动指定奇偶页的 layout \input lshort-zh-cn-layout @@ -146,6 +153,22 @@ {\clearpage\if@twoside \ifodd\c@page\else \hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi} +% 允许 hologo 断词 +\hologoSetup{discretionarybreak=true} +% 新定义 hologo +\def\HoLogo@TeXLive#1{% + \hologo{TeX}\HOLOGO@space\HOLOGO@mbox{Live}% +} +\def\HoLogo@MacTeX#1{% + \HOLOGO@mbox{Mac}\hologo{TeX}% +} +\def\HoLogo@CTeX#1{% + \HOLOGO@mbox{C}\hologo{TeX}% +} +\def\HoLogo@TikZ#1{% + \HOLOGO@mbox{Ti\textit{k\/}Z} +} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % lshort 用到的自定义命令 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -159,15 +182,6 @@ \def\CTAN|#1|{\href{http://mirrors.tuna.tsinghua.edu.cn/CTAN/#1}{\CTANref|CTAN://#1|}} \newcommand{\contrib}[3]{#1\quad\mailto|#2|{\small\\\quad\textit{#3}}\\[1ex]} -\DeclareRobustCommand*\TikZ{Ti\textit{k\/}Z} -% -% PDF 书签中对符号的特殊处理 -% -\pdfstringdefDisableCommands{% - \def\AmS{AMS}% - \def\TikZ{TikZ}% -} - % % 示意长度 % diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn.tex index fca438c9b08..1569155b6c4 100644 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn.tex +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/lshort-zh-cn.tex @@ -3,7 +3,7 @@ \def\lshortversionoriginal{6.2} \def\lshortdateoriginal{Februrary 28, 2018} -\def\lshortversioncn{6.01} +\def\lshortversioncn{6.02} \hypersetup{% pdftitle={The Short Introduction to LaTeX2e (Chinese Simplified)},% @@ -24,32 +24,32 @@ \begin{document} \pagenumbering{Alph} -\input{titlepage} +\input{chap/titlepage} \frontmatter -\input{preface.contrib} -\input{preface.overview} +\input{chap/preface.contrib} +\input{chap/preface.overview} \tableofcontents \mainmatter -\input{chap.01.basics} -\input{chap.02.text} -\input{chap.03.elements} -\input{chap.04.math} -\input{sec.symbol.table} -\input{chap.05.style} -\input{chap.06.spec} -\input{chap.07.graphic} -\input{chap.08.custom} +\input{chap/chap.01.basics} +\input{chap/chap.02.text} +\input{chap/chap.03.elements} +\input{chap/chap.04.math} +\input{chap/sec.symbol.table} +\input{chap/chap.05.style} +\input{chap/chap.06.spec} +\input{chap/chap.07.graphic} +\input{chap/chap.08.custom} \appendix -\input{app.A.install} -\input{app.B.error.help} +\input{chap/app.A.install} +\input{chap/app.B.error.help} \refstepcounter{minutes}\label{lshort-minutes} \backmatter -\input{biblio} -\input{fdl} +\input{chap/biblio} +\input{chap/fdl} \printindex -\end{document} \ No newline at end of file +\end{document} diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/make.bat b/Master/texmf-dist/doc/latex/lshort-chinese/src/make.bat index e58af4ae36e..5ed26b3178b 100755 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/make.bat +++ b/Master/texmf-dist/doc/latex/lshort-chinese/src/make.bat @@ -1,32 +1,34 @@ -@echo off -set LSHORT=lshort-zh-cn -set PDF=%LSHORT%.pdf -set TEMP=%LSHORT%.xdv %LSHORT%.aux %LSHORT%.log %LSHORT%.idx %LSHORT%.ind %LSHORT%.ilg %LSHORT%.out %LSHORT%.toc %LSHORT%.los %LSHORT%-example.aux %LSHORT%.synctex.gz - -if "%1"=="clean" goto clean - -set TEX=xelatex -set NOPDFMODE=-interaction=nonstopmode -synctex=1 --no-pdf -set MODE=-interaction=nonstopmode -synctex=1 -set MAKEINDEX=makeindex - -%TEX% %NOPDFMODE% %LSHORT% -%MAKEINDEX% -s %LSHORT%.ist %LSHORT% -%TEX% %NOPDFMODE% %LSHORT% -%TEX% %MODE% %LSHORT% - -if exist %PDF% ( -copy %PDF% .. -) -exit - -:clean -del %TEMP% -del %PDF% -exit - -:distclean -del %TEMP% -del %PDF% -del ..\%PDF% -exit +@echo off +cd %~dp0 +set LSHORT=lshort-zh-cn +set PDF=%LSHORT%.pdf +set TEMP=%LSHORT%.xdv %LSHORT%.aux %LSHORT%.log %LSHORT%.idx %LSHORT%.ind %LSHORT%.ilg %LSHORT%.out %LSHORT%.toc %LSHORT%.los %LSHORT%-example.aux %LSHORT%.synctex.gz + +if "%1"=="clean" goto clean +if "%1"=="distclean" goto distclean + +set TEX=xelatex +set NOPDFMODE=-interaction=nonstopmode -synctex=1 --no-pdf +set MODE=-interaction=nonstopmode -synctex=1 +set MAKEINDEX=makeindex + +%TEX% %NOPDFMODE% %LSHORT% +%MAKEINDEX% -s %LSHORT%.ist %LSHORT% +%TEX% %NOPDFMODE% %LSHORT% +%TEX% %MODE% %LSHORT% + +if exist %PDF% ( +copy %PDF% .. +) +exit /B + +:clean +del %TEMP% +del %PDF% +exit /B + +:distclean +del %TEMP% +del %PDF% +del ..\%PDF% +exit /B diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/preface.contrib.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/preface.contrib.tex deleted file mode 100644 index 61b6186cdf3..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/preface.contrib.tex +++ /dev/null @@ -1,238 +0,0 @@ -\chapter{中文版致谢} - -\section*{5.05 中文版致谢} - -对 lshort-zh-cn 的新一轮修订在 China\TeX\ 交流 QQ 群 (91940767) 的网友支持下完成。 -参与此次修订的朋友包括: - -\begin{center} -\begin{tabular}{lll} - \toprule - 网友 ID & E-mail \\ - \midrule - hello & 312439151@qq.com \\ - $\varepsilon$ & 554502177@qq.com \\ - \bottomrule -\end{tabular} -\end{center} - -\noindent\dotfill - -\section*{4.20 中文版致谢} - -中文 \TeX\ 学会启动的 lshort-zh-cn 修正计划! -本项计划历时八个月,参加的朋友有: - -\begin{center} -\begin{tabular}{ll} -\toprule -\textbf{C\TeX 论坛 ID} & \textbf{翻译章节} \\ -\midrule -zpxing & 前言、第二章、第五章 1-2.4 {\&} 3、第六章 \\ -Frogge & 第一章 \\ -liwenjun & 第三章 \\ -lijian605 & 第四章 \\ -gprsnl & 第五章 2.5-2.11 \\ -\bottomrule -\end{tabular} -\end{center} - -haginile 和 Frogge 通读了全篇,并给出了详细的勘误表。 -blackold 对于第二章亦有所贡献。最后由 zpxing 统筹全书。 - -\noindent\dotfill - -\section*{3.20 中文版致谢} - -本文档的翻译工作由 C\TeX{} 版主“经典问题”倡议,历经近十个月才得以完成。 -期间参与翻译工作的朋友有: - -\begin{center} -\begin{tabular}{lll} -\toprule -\textbf{C\TeX 论坛 ID} & \textbf{翻译章节} & \textbf{源文件名} \\ -\midrule -经典问题 & 前言 & overview.tex \\ -高原之狼 & 第一章 & things.tex \\ -controlong & 第二章 & typeset.tex \\ -cxterm & 第三章 & math.tex, lssym.tex \\ -aloft & 第四章 & spec.tex \\ -ganzhi & 第五章 & custom.tex \\ -\bottomrule -\end{tabular} -\end{center} - -\vspace{20pt} - -\begin{flushright} -\large\textbf{在此特向这些奉献者表示感谢!} -\end{flushright} - -\chapter{英文版致谢} - -\noindent Much of the material used in this introduction comes from an -Austrian introduction to \LaTeX\ 2.09 written in German by: -\begin{verse} -\contrib{Hubert Partl}{partl@mail.boku.ac.at}% -{Zentraler Informatikdienst der Universit\"at f\"ur Bodenkultur Wien} -\contrib{Irene Hyna}{Irene.Hyna@bmwf.ac.at}% - {Bundesministerium f\"ur Wissenschaft und Forschung Wien} -\contrib{Elisabeth Schlegl}{no email}% - {in Graz} -\end{verse} - -If you are interested in the German document, you can find a version -updated for \LaTeXe{} by J\"org Knappen at -\CTAN|info/lshort/german| - -\newpage \noindent -The following individuals helped with corrections, suggestions and -material to improve this paper. They put in a big effort to help me -get this document into its present shape. I would like to -sincerely thank all of them. Naturally, all the mistakes you'll find -in this book are mine. If you ever find a word that is spelled -correctly, it must have been one of the people below dropping me a -line. - -\begin{flushleft}\small -Eric~Abrahamsen, % -Lenimar~Nunes~de~Andrade, % 12 Nov 1999 -Eilinger~August, % -Rosemary~Bailey, % 0.2 -Barbara~Beeton, % -Marc~Bevand, % -Connor~Blakey, % it's Ligatures! -Salvatore~Bonaccorso, % -Pietro~Braione, % -Friedemann~Brauer, % 3.4 -Markus~Br\"uhwiler, % -Jan~Busa, % -David~Carlisle, % GONE 1.0 -Neil~Carter, % -Carl~Cerecke, % -Mike~Chapman, % 3.16 -Pierre~Chardaire, % -Xingyou~Chen, % 5.04 -Christopher~Chin, % 3.1 -Diego~Clavadetscher, % -Wim~van~Dam, % GONE 2.2 -Benjamin~Deschwanden % -Jan~Dittberner, % 3.15 -Michael~John~Downes, % 14 Oct 1999 -Matthias~Dreier, % -David~Dureisseix, % 1.1 -Hans~Ehrbar, % -Elliot, % GONE 1.1 -Rockrush~Engch, % -William~Faulk, % -Robin~Fairbairns, % 0.2 1.0 -Johan~Falk, % 5.0.1 -J\"org~Fischer, % 3.16 -Frank~Fischli, % -Daniel~Flipo, % -Frank, % 11 Feb 2000 -Mic~Milic~Frederickx, % -David~Frey, % 2.2 -Erik~Frisk, % 3.4 -Hans~Fugal, % -Robert~Funnell, % 5.1 -Greg~Gamble, % 2.2 -Andy~Goth, % -Cyril~Goutte, % 2.1 2.2 -Kasper~B.~Graversen, % -Arlo~Griffiths, % -Alexandre~Guimond, % 0.9 -Neil~Hammond, % 0.3 -Christoph~Hamburger, % -Rasmus~Borup~Hansen, % GONE 0.2 0.9 0.91 0.92 1.9.9 -Joseph~Hilferty, % -Daniel~Hirsbrunner, % -Martien~Hulsen, % 1.0 1.1 -Bj\"orn Hvittfeldt, % 3.13 -Morten~H\o gholm, % -Werner~Icking, % 3.1 -Eric~Jacoboni, % GONE 0.1 0.9 -Jakob, % -Alan~Jeffrey, % 0.2 -Martin~Jenkins, % xqp.ltd@gmail.com 5.04 -Byron~Jones, % 1.1 -David~Jones, % GONE 1.1 -Johannes-Maria~Kaltenbach, % 3.01 -Nils~Kanning, % -Andrzej~Kawalec, % GONE 1.9.9 -Christian~Kern, % 2.1 -Alain~Kessi, % 2.2 -Axel~Kielhorn, % -Sander~de~Kievit, % -Kjetil~Kjernsmo, % 3.2 -Tobias~Klauser, % 4.17 -J\"org~Knappen, % 0.1 -Michael~Koundouros, % -Matt~Kraai, % -Tobias~Krewer, % -Flori~Lambrechts, % -Mike~Lee, % -Maik~Lehradt, % 0.1 -R\'emi~Letot, % -Axel~Liljencrantz, % -Jasper~Loy, % -Johan~Lundberg, % -Martin~Maechler, % 2.2 -Alexander~Mai, % 3.8 -Claus~Malten, % GONE 1.1 -Kevin~Van~Maren, % 24 Nov 1999 -Pablo~Markin, -I.~J.~Vera~Mar\'un, % -Hendrik~Maryns, % -Chris~McCormack, % GONE 0.1 -Aleksandar~S.~Milosevic, % -Henrik~Mitsch, % -Stefan~M.~Moser, % -Philipp~Nagele, % -Richard~Nagy, % -Manuel~Oetiker, % -Urs~Oswald, % -Hubert~Partl, % 0.2 1.1 -Marcelo~Pasin, % -Martin~Pfister, % -Lan~Thuy~Pham, % -Breno~Pietracci, % -Demerson~Andre~Polli, % -Maksym~Polyakov, % -Nikos~Pothitos, % -John~Refling, % 0.1 0.9 -Mike~Ressler, % 0.1 0.2 0.9 1.0 1.9.9 -Brian~Ripley, % 2.1 -Kurt~Rosenfeld, % -Bernd~Rosenlecher, % <9rosenle@informatik.uni-hamburg.de> 10 Feb 2000 -Chris~Rowley, % 0.91 -Young~U.~Ryu, % 2.1 -Risto~Saarelma, % -Andr{\'a}s~Salamon, % -Jos\'e~Carlos~Santos, % -Christopher~Sawtell, % 1 Sep 1999 -Gilles~Schintgen, % -Craig~Schlenter, % 0.1 0.2 0.9 -Hanspeter~Schmid, % -Baron~Schwartz, % -Jordi~Serra~i~Solanich, % -Miles~Spielberg, % -Susan~Stewart, -Matthieu~Stigler, -Geoffrey~Swindale, % -Laszlo~Szathmary, % -Boris~Tobotras, % -Josef~Tkadlec, % 2.0 2.2 -Scott~Veirs, % -Didier~Verna, % 2.2 -Carl-Gustav~Werner, % 11 Oct 1999, 3.16 -Fabian~Wernli, % 3.2 -Matthew~Widmann, % -David~Woodhouse, % 3.16 -Chris~York, % 21 Nov 1999 -Rick~Zaccone, % 2.2 -Fritz~Zaucker, % 3.0 -and Mikhail~Zotov. % 3.1 -\end{flushleft} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/preface.overview.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/preface.overview.tex deleted file mode 100644 index 3bf947d2ae9..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/preface.overview.tex +++ /dev/null @@ -1,58 +0,0 @@ -\chapter{前言} - -\LaTeX\ \cite{manual} 是一个文档准备系统(Document Preparing System),它非常适用于生成高印刷质量 -的科技类和数学类文档。它也能够生成所有其他种类的文档,小到简单的信件,大到完整的书籍。 -\LaTeX~使用 \TeX\ \cite{texbook} 作为它的排版引擎。% - -这份短小的手册描述了 \LaTeXe\ 的使用,对 \LaTeX 的大多数应用来说应该是足够了。 -参考文献 \cite{manual,companion} 对 \LaTeX\ 系统提供了完整的描述。% - -\bigskip -本手册在英文版 lshort 的基础上进行了适当的重新编排,共有八章和两篇附录:% -\begin{description}% -\item[第一章] 讲述 \LaTeX\ 的来源,源代码的基本结构,以及如何编译源代码生成文档。 -\item[第二章] 讲述在 \LaTeX\ 中如何书写文字,包括中文。% -\item[第三章] 讲述文档排版的基本元素——标题、目录、列表、图片、表格等等。结合前一章的内容,你应当能够制作内容较为丰富的文档了。% -\item[第四章] \LaTeX\ 排版公式的能力是众人皆知的。本章的内容涉及了一些排版公式经常用到的命令、环境和符号。 - 章节末尾列出了 \LaTeX\ 常见的数学符号。% -\item[第五章] 介绍了如何修改文档的一些基本样式,包括字体、段落、页面尺寸、页眉页脚等。 -\item[第六章] 介绍了 \LaTeX\ 的一些扩展功能:排版参考文献、排版索引、排版带有颜色和超链接的电子文档。 -\item[第七章] 介绍了如何在 \LaTeX\ 里使用 \TikZ\ 绘图。作为入门手册,这一部分点到为止。 -\item[第八章] 当你相当熟悉前面几章的内容,需要自己编写命令和宏包扩展 \LaTeX\ 的功能时,本章介绍了一些基本的命令满足你的需求。 -\end{description}% -\begin{description} -\item[附录A] 介绍了如何安装 \TeX\ 发行版和更新宏包。 -\item[附录B] 当新手遇到错误和需要寻求更多帮助时,本章提供了一些基本的参考。 -\end{description} - -\bigskip -这些章节是循序渐进的,建议刚刚熟悉 \LaTeX\ 的读者按顺序阅读。一定要认真阅读例子的源代码,它们贯穿全篇手册,包含了很多的信息。% - -\bigskip -如果你已经对 \LaTeX\ 较为熟练,本手册的资源已不足够解决你的问题时,请访问``Comprehensive -\TeX\ Archive Network'' (\texttt{CTAN}) 站点,主页是 \url{www.ctan.org}。 -所有的宏包也可以从 \url{mirrors.ctan.org} 和遍布全球的各个镜像站点中获得。 - -在本书中你会找到其他引用 \texttt{CTAN} 的地方,形式为 \texttt{CTAN://} 和之后的树状结构。 -引用本身是一个超链接,点击后将打开内容在 \texttt{CTAN} 上相应位置的页面。 - -要在自己的电脑上安装 \TeX\ 发行版,请参考附录 \ref{app:install} 中的内容。 -各个操作系统下的 \TeX\ 发行版位于 \CTAN|systems|。 - -\bigskip -如果你有意在这份文档中增加、删除或者改变一些内容,请通知作者。作者对 \LaTeX\ -初学者的反馈特别感兴趣,尤其是关于这份介绍哪些内容很容易理解,哪些内容可能需要更好地解释, -而哪些内容由于太过难以理解、非常不常用而不适宜放在本手册。 - -\bigskip -\begin{flushright} -C\TeX\ 开发小组\par -\url{https://github.com/CTeX-org} -\end{flushright} - -\vfill - -\noindent\begingroup\small lshort 的的最新中文版本位于 \CTAN|info/lshort/chinese|。 -如果用户对其他语言的版本感兴趣,请浏览 \CTAN|info/lshort|。\endgroup - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/sec.symbol.table.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/sec.symbol.table.tex deleted file mode 100644 index cbd06ec9cef..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/sec.symbol.table.tex +++ /dev/null @@ -1,392 +0,0 @@ -% Definitions -\def\lsym{$\mathsurround=0pt {}^\ell$} -\def\LSYM #1{$#1$ & \texttt{\string#1}\lsym} - -\def\SYM #1{$#1$ & \texttt{\string#1}} -\def\BIGSYM #1{$#1$ & $\displaystyle #1$ & \texttt{\string#1}} -\def\ACC #1#2{$#1{#2}$ & \texttt{\string#1}\marg*{#2}} -\def\DEL #1{$\big#1 \bigg#1$ & \texttt{\string#1}} - -\def\AMSSYM #1{$#1$ & \texttt{\string#1}} -% These symbols rely on `amsmath' package -\def\AMSM #1{$#1$ & \textcolor{blue}{\texttt{\string#1}}} -\def\AMSACC#1#2{$#1{#2}$ & \textcolor{blue}{\texttt{\string#1}}\marg*{#2}} -\def\AMSBIG #1{$#1$ & $\displaystyle #1$ & \textcolor{blue}{\texttt{\string#1}}} - -\def\SC #1{#1 & \texttt{\string#1}} - -\newenvironment{symbols}[1]% - {\small\def\arraystretch{1.1} - \begin{tabular}{@{}#1@{}}}% - {\end{tabular}} - -\clearpage -\section{符号表}\label{sec:math-tables} - -\pkgindex{latexsym} -有几个注意事项: -\begin{enumerate} - \item \textcolor{blue}{蓝色}的命令依赖 \pkg{amsmath} 宏包(非 \pkg{amssymb} 宏包); - \item 带有角标\lsym 的符号命令依赖 \pkg{latexsym} 宏包。 -\end{enumerate} - -\subsection{\LaTeX\ 普通符号} -\symindex{dag,ddag,P,S,copyright,pounds} - -\begin{table}[htp] -\centering -\caption{文本/数学模式通用符号。}\label{tbl:general-syms} -\begin{quote}\footnotesize% -这些符号可用于文本和数学模式。 -\end{quote} -\begin{symbols}{*4{cl}} -\hline - \SC{\{} & \SC{\}} & \SC{\$} & \SC{\%} \\ - \SC{\dag} & \SC{\S} & \SC{\copyright} & \SC{\dots} \\ - \SC{\ddag} & \SC{\P} & \SC{\pounds} & \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{希腊字母。} \label{tbl:math-greek} -\begin{quote}\footnotesize% -\cmd{Alpha},\cmd{Beta} 等希腊字母符号不存在,因为它们和拉丁字母 A,B 等一模一样; -小写字母里也不存在 \cmd{omicron},直接用拉丁字母 $o$ 代替。 -\end{quote} -\begin{symbols}{*4{cl}} -\hline - \SYM{\alpha} & \SYM{\theta} & \SYM{o} & \SYM{\upsilon} \\ - \SYM{\beta} & \SYM{\vartheta} & \SYM{\pi} & \SYM{\phi} \\ - \SYM{\gamma} & \SYM{\iota} & \SYM{\varpi} & \SYM{\varphi} \\ - \SYM{\delta} & \SYM{\kappa} & \SYM{\rho} & \SYM{\chi} \\ - \SYM{\epsilon} & \SYM{\lambda} & \SYM{\varrho} & \SYM{\psi} \\ - \SYM{\varepsilon}& \SYM{\mu} & \SYM{\sigma} & \SYM{\omega} \\ - \SYM{\zeta} & \SYM{\nu} & \SYM{\varsigma} & \\ - \SYM{\eta} & \SYM{\xi} & \SYM{\tau} & \\[1ex] - \SYM{\Gamma} & \SYM{\Lambda} & \SYM{\Sigma} & \SYM{\Psi} \\ - \SYM{\Delta} & \SYM{\Xi} & \SYM{\Upsilon} & \SYM{\Omega} \\ - \SYM{\Theta} & \SYM{\Pi} & \SYM{\Phi} & \\[1ex] - \AMSM{\varGamma} & \AMSM{\varLambda}& \AMSM{\varSigma} & \AMSM{\varPsi} \\ - \AMSM{\varDelta} & \AMSM{\varXi} & \AMSM{\varUpsilon}& \AMSM{\varOmega} \\ - \AMSM{\varTheta} & \AMSM{\varPi} & \AMSM{\varPhi} & \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{二元关系符。} \label{tbl:math-rel} -\begin{quote}\footnotesize% -所有的二元关系符都可以加 \cmd{not} 前缀得到相反意义的关系符,例如 \cmd{not}\texttt{=} 就得到不等号(同 \cmd{ne})。 -\end{quote} -\begin{symbols}{*3{cl}} -\hline - \SYM{<} & \SYM{>} & \SYM{=} \\ - \SYM{\leq} or \cmd{le} & \SYM{\geq} or \cmd{ge} & \SYM{\equiv} \\ - \SYM{\ll} & \SYM{\gg} & \SYM{\doteq} \\ - \SYM{\prec} & \SYM{\succ} & \SYM{\sim} \\ - \SYM{\preceq} & \SYM{\succeq} & \SYM{\simeq} \\ - \SYM{\subset} & \SYM{\supset} & \SYM{\approx} \\ - \SYM{\subseteq} & \SYM{\supseteq} & \SYM{\cong} \\ - \LSYM{\sqsubset} & \LSYM{\sqsupset} & \LSYM{\Join} \\ - \SYM{\sqsubseteq} & \SYM{\sqsupseteq} & \SYM{\bowtie} \\ - \SYM{\in} & \SYM{\ni}, \cmd{owns} & \SYM{\propto} \\ - \SYM{\vdash} & \SYM{\dashv} & \SYM{\models} \\ - \SYM{\mid} & \SYM{\parallel} & \SYM{\perp} \\ - \SYM{\smile} & \SYM{\frown} & \SYM{\asymp} \\ - \SYM{:} & \SYM{\notin} & \SYM{\neq} or \cmd{ne} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{二元运算符。}\label{tbl:math-op} -\begin{symbols}{*3{cl}} -\hline - \SYM{+} & \SYM{-} & \\ - \SYM{\pm} & \SYM{\mp} & \SYM{\triangleleft} \\ - \SYM{\cdot} & \SYM{\div} & \SYM{\triangleright}\\ - \SYM{\times} & \SYM{\setminus} & \SYM{\star} \\ - \SYM{\cup} & \SYM{\cap} & \SYM{\ast} \\ - \SYM{\sqcup} & \SYM{\sqcap} & \SYM{\circ} \\ - \SYM{\vee}, \cmd{lor}& \SYM{\wedge},\cmd{land} & \SYM{\bullet} \\ - \SYM{\oplus} & \SYM{\ominus} & \SYM{\diamond} \\ - \SYM{\odot} & \SYM{\oslash} & \SYM{\uplus} \\ - \SYM{\otimes} & \SYM{\bigcirc} & \SYM{\amalg} \\ - \SYM{\bigtriangleup} &\SYM{\bigtriangledown}& \SYM{\dagger} \\ - \LSYM{\lhd} & \LSYM{\rhd} & \SYM{\ddagger} \\ - \LSYM{\unlhd} & \LSYM{\unrhd} & \SYM{\wr} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{巨算符。}\label{tbl:math-bigop} -\def\arraystretch{2.2} -\begin{symbols}{*3{ccl}} -\hline - \BIGSYM{\sum} & \BIGSYM{\bigcup} & \BIGSYM{\bigvee} \\ - \BIGSYM{\prod} & \BIGSYM{\bigcap} & \BIGSYM{\bigwedge} \\ - \BIGSYM{\coprod} & \BIGSYM{\bigsqcup} & \BIGSYM{\biguplus} \\ - \BIGSYM{\int} & \BIGSYM{\oint} & \BIGSYM{\bigodot} \\ - \BIGSYM{\bigoplus} & \BIGSYM{\bigotimes} & \\ - \AMSBIG{\iint} & \AMSBIG{\iiint} & \AMSBIG{\iiiint} \\ - \AMSBIG{\idotsint} & & \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{数学重音符号。}\label{tbl:math-accents} -\begin{quote}\footnotesize% -最后一个 \cmd{wideparen} 依赖 \pkg{yhmath} 宏包。 -\end{quote} -\begin{symbols}{*3{cl}} -\hline -\ACC{\hat}{a} & \ACC{\check}{a} & \ACC{\tilde}{a} \\ -\ACC{\acute}{a} & \ACC{\grave}{a} & \ACC{\breve}{a} \\ -\ACC{\bar}{a} & \ACC{\vec}{a} & \ACC{\mathring}{a} \\ -\ACC{\dot}{a} & \ACC{\ddot}{a} & \AMSACC{\dddot}{a} \\ -\AMSACC{\ddddot}{a} \\[1ex] -\ACC{\widehat}{AAA} & \ACC{\widetilde}{AAA} & \ACC{\wideparen}{AAA} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{箭头。} \label{tbl:math-arrows} -\begin{symbols}{*2{cl}} -\hline - \SYM{\leftarrow} or \cmd{gets} & \SYM{\longleftarrow} \\ - \SYM{\rightarrow} or \cmd{to} & \SYM{\longrightarrow} \\ - \SYM{\leftrightarrow} & \SYM{\longleftrightarrow} \\ - \SYM{\Leftarrow} & \SYM{\Longleftarrow} \\ - \SYM{\Rightarrow} & \SYM{\Longrightarrow} \\ - \SYM{\Leftrightarrow} & \SYM{\Longleftrightarrow}\\ - \SYM{\mapsto} & \SYM{\longmapsto} \\ - \SYM{\hookleftarrow} & \SYM{\hookrightarrow} \\ - \SYM{\leftharpoonup} & \SYM{\rightharpoonup} \\ - \SYM{\leftharpoondown} & \SYM{\rightharpoondown} \\ - \SYM{\rightleftharpoons} & \SYM{\iff} \\ - \SYM{\uparrow} & \SYM{\downarrow} \\ - \SYM{\updownarrow} & \SYM{\Uparrow} \\ - \SYM{\Downarrow} & \SYM{\Updownarrow} \\ - \SYM{\nearrow} & \SYM{\searrow} \\ - \SYM{\swarrow} & \SYM{\nwarrow} \\ - \LSYM{\leadsto} & \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{作为重音的箭头符号。} \label{tbl:math-arrow-accents} -\begin{symbols}{*2{cl}} -\hline -\ACC{\overrightarrow}{AB} & \AMSACC{\underrightarrow}{AB} \\ -\ACC{\overleftarrow}{AB} & \AMSACC{\underleftarrow}{AB} \\ -\AMSACC{\overleftrightarrow}{AB} & \AMSACC{\underleftrightarrow}{AB} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{定界符。}\label{tbl:math-delims} -\begin{symbols}{*3{cl}} -\hline - \SYM{(} & \SYM{)} & \SYM{\uparrow} \\ - \SYM{[} or \cmd{lbrack} & \SYM{]} or \cmd{rbrack} & \SYM{\downarrow} \\ - \SYM{\{} or \cmd{lbrace} & \SYM{\}} or \cmd{rbrace} & \SYM{\updownarrow} \\ - \SYM{\langle} & \SYM{\rangle} & \SYM{\Uparrow} \\ - \SYM{|} or \cmd{vert} & \SYM{\|} or \cmd{Vert} & \SYM{\Downarrow} \\ - \SYM{/} & \SYM{\backslash} & \SYM{\Updownarrow} \\ - \SYM{\lfloor} & \SYM{\rfloor} & \\ - \SYM{\rceil} & \SYM{\lceil} & & \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{用于行间公式的大定界符。}\label{tbl:math-large-delims} -\def\arraystretch{1.8} -\begin{symbols}{*3{cl}} -\hline - \DEL{\lgroup} & \DEL{\rgroup} & \DEL{\lmoustache} \\ - \DEL{\arrowvert} & \DEL{\Arrowvert} & \DEL{\bracevert} \\ - \DEL{\rmoustache} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{其他符号。}\label{tbl:math-misc} -\begin{symbols}{*4{cl}} -\hline - \SYM{\dots} & \SYM{\cdots} & \SYM{\vdots} & \SYM{\ddots} \\ - \SYM{\hbar} & \SYM{\imath} & \SYM{\jmath} & \SYM{\ell} \\ - \SYM{\Re} & \SYM{\Im} & \SYM{\aleph} & \SYM{\wp} \\ - \SYM{\forall} & \SYM{\exists} & \LSYM{\mho} & \SYM{\partial} \\ - \SYM{'} & \SYM{\prime} & \SYM{\emptyset} & \SYM{\infty} \\ - \SYM{\nabla} & \SYM{\triangle} & \LSYM{\Box} & \LSYM{\Diamond} \\ - \SYM{\bot} & \SYM{\top} & \SYM{\angle} & \SYM{\surd} \\ - \SYM{\diamondsuit} & \SYM{\heartsuit} & \SYM{\clubsuit} & \SYM{\spadesuit} \\ - \SYM{\neg} or \cmd{lnot} & \SYM{\flat} & \SYM{\natural} & \SYM{\sharp} \\ -\hline -\end{symbols} -\end{table} - -\clearpage -\subsection{\AmS\ 符号} - -本小节所有符号依赖 \pkg{amssymb} 宏包。 - -\begin{table}[htp] -\centering -\caption{\AmS\ 希腊字母和希伯来字母。} \label{tbl:ams-greek-hebrew} -\begin{symbols}{*5{cl}} -\hline -\AMSSYM{\digamma} &\AMSSYM{\varkappa} & \AMSSYM{\beth} &\AMSSYM{\gimel} & \AMSSYM{\daleth}\\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{\AmS\ 二元关系符。} \label{tbl:ams-rel} -\begin{symbols}{*3{cl}} -\hline - \AMSSYM{\lessdot} & \AMSSYM{\gtrdot} & \AMSSYM{\doteqdot} \\ - \AMSSYM{\leqslant} & \AMSSYM{\geqslant} & \AMSSYM{\risingdotseq} \\ - \AMSSYM{\eqslantless} & \AMSSYM{\eqslantgtr} & \AMSSYM{\fallingdotseq} \\ - \AMSSYM{\leqq} & \AMSSYM{\geqq} & \AMSSYM{\eqcirc} \\ - \AMSSYM{\lll} or \cmd{llless}& \AMSSYM{\ggg} & \AMSSYM{\circeq} \\ - \AMSSYM{\lesssim} & \AMSSYM{\gtrsim} & \AMSSYM{\triangleq} \\ - \AMSSYM{\lessapprox} & \AMSSYM{\gtrapprox} & \AMSSYM{\bumpeq} \\ - \AMSSYM{\lessgtr} & \AMSSYM{\gtrless} & \AMSSYM{\Bumpeq} \\ - \AMSSYM{\lesseqgtr} & \AMSSYM{\gtreqless} & \AMSSYM{\thicksim} \\ - \AMSSYM{\lesseqqgtr} & \AMSSYM{\gtreqqless} & \AMSSYM{\thickapprox} \\ - \AMSSYM{\preccurlyeq} & \AMSSYM{\succcurlyeq} & \AMSSYM{\approxeq} \\ - \AMSSYM{\curlyeqprec} & \AMSSYM{\curlyeqsucc} & \AMSSYM{\backsim} \\ - \AMSSYM{\precsim} & \AMSSYM{\succsim} & \AMSSYM{\backsimeq} \\ - \AMSSYM{\precapprox} & \AMSSYM{\succapprox} & \AMSSYM{\vDash} \\ - \AMSSYM{\subseteqq} & \AMSSYM{\supseteqq} & \AMSSYM{\Vdash} \\ - \AMSSYM{\shortparallel} & \AMSSYM{\Supset} & \AMSSYM{\Vvdash} \\ - \AMSSYM{\blacktriangleleft} & \AMSSYM{\sqsupset} & \AMSSYM{\backepsilon} \\ - \AMSSYM{\vartriangleright} & \AMSSYM{\because} & \AMSSYM{\varpropto} \\ - \AMSSYM{\blacktriangleright}& \AMSSYM{\Subset} & \AMSSYM{\between} \\ - \AMSSYM{\trianglerighteq} & \AMSSYM{\smallfrown} & \AMSSYM{\pitchfork} \\ - \AMSSYM{\vartriangleleft} & \AMSSYM{\shortmid} & \AMSSYM{\smallsmile} \\ - \AMSSYM{\trianglelefteq} & \AMSSYM{\therefore} & \AMSSYM{\sqsubset} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{\AmS\ 二元运算符。} \label{tbl:ams-op} -\begin{symbols}{*3{cl}} -\hline - \AMSSYM{\dotplus} & \AMSSYM{\centerdot} & \\ - \AMSSYM{\ltimes} & \AMSSYM{\rtimes} & \AMSSYM{\divideontimes} \\ - \AMSSYM{\doublecup} & \AMSSYM{\doublecap} & \AMSSYM{\smallsetminus} \\ - \AMSSYM{\veebar} & \AMSSYM{\barwedge} & \AMSSYM{\doublebarwedge}\\ - \AMSSYM{\boxplus} & \AMSSYM{\boxminus} & \AMSSYM{\circleddash} \\ - \AMSSYM{\boxtimes} & \AMSSYM{\boxdot} & \AMSSYM{\circledcirc} \\ - \AMSSYM{\intercal} & \AMSSYM{\circledast} & \AMSSYM{\rightthreetimes} \\ - \AMSSYM{\curlyvee} & \AMSSYM{\curlywedge} & \AMSSYM{\leftthreetimes} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{\AmS\ 箭头。}\label{tbl:ams-arrows} -\begin{symbols}{*2{cl}} -\hline - \AMSSYM{\dashleftarrow} & \AMSSYM{\dashrightarrow} \\ - \AMSSYM{\leftleftarrows} & \AMSSYM{\rightrightarrows} \\ - \AMSSYM{\leftrightarrows} & \AMSSYM{\rightleftarrows} \\ - \AMSSYM{\Lleftarrow} & \AMSSYM{\Rrightarrow} \\ - \AMSSYM{\twoheadleftarrow} & \AMSSYM{\twoheadrightarrow} \\ - \AMSSYM{\leftarrowtail} & \AMSSYM{\rightarrowtail} \\ - \AMSSYM{\leftrightharpoons} & \AMSSYM{\rightleftharpoons} \\ - \AMSSYM{\Lsh} & \AMSSYM{\Rsh} \\ - \AMSSYM{\looparrowleft} & \AMSSYM{\looparrowright} \\ - \AMSSYM{\curvearrowleft} & \AMSSYM{\curvearrowright} \\ - \AMSSYM{\circlearrowleft} & \AMSSYM{\circlearrowright} \\ - \AMSSYM{\multimap} & \AMSSYM{\upuparrows} \\ - \AMSSYM{\downdownarrows} & \AMSSYM{\upharpoonleft} \\ - \AMSSYM{\upharpoonright} & \AMSSYM{\downharpoonright} \\ - \AMSSYM{\rightsquigarrow} & \AMSSYM{\leftrightsquigarrow}\\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{\AmS\ 反义二元关系符和箭头。}\label{tbl:ams-negative} -\begin{symbols}{*3{cl}} -\hline - \AMSSYM{\nless} & \AMSSYM{\ngtr} & \AMSSYM{\varsubsetneqq} \\ - \AMSSYM{\lneq} & \AMSSYM{\gneq} & \AMSSYM{\varsupsetneqq} \\ - \AMSSYM{\nleq} & \AMSSYM{\ngeq} & \AMSSYM{\nsubseteqq} \\ - \AMSSYM{\nleqslant} & \AMSSYM{\ngeqslant} & \AMSSYM{\nsupseteqq} \\ - \AMSSYM{\lneqq} & \AMSSYM{\gneqq} & \AMSSYM{\nmid} \\ - \AMSSYM{\lvertneqq} & \AMSSYM{\gvertneqq} & \AMSSYM{\nparallel} \\ - \AMSSYM{\nleqq} & \AMSSYM{\ngeqq} & \AMSSYM{\nshortmid} \\ - \AMSSYM{\lnsim} & \AMSSYM{\gnsim} & \AMSSYM{\nshortparallel} \\ - \AMSSYM{\lnapprox} & \AMSSYM{\gnapprox} & \AMSSYM{\nsim} \\ - \AMSSYM{\nprec} & \AMSSYM{\nsucc} & \AMSSYM{\ncong} \\ - \AMSSYM{\npreceq} & \AMSSYM{\nsucceq} & \AMSSYM{\nvdash} \\ - \AMSSYM{\precneqq} & \AMSSYM{\succneqq} & \AMSSYM{\nvDash} \\ - \AMSSYM{\precnsim} & \AMSSYM{\succnsim} & \AMSSYM{\nVdash} \\ - \AMSSYM{\precnapprox} & \AMSSYM{\succnapprox} & \AMSSYM{\nVDash} \\ - \AMSSYM{\subsetneq} & \AMSSYM{\supsetneq} & \AMSSYM{\ntriangleleft} \\ - \AMSSYM{\varsubsetneq} & \AMSSYM{\varsupsetneq} & \AMSSYM{\ntriangleright} \\ - \AMSSYM{\nsubseteq} & \AMSSYM{\nsupseteq} & \AMSSYM{\ntrianglelefteq}\\ - \AMSSYM{\subsetneqq} & \AMSSYM{\supsetneqq} &\AMSSYM{\ntrianglerighteq}\\[0.5ex] - \AMSSYM{\nleftarrow} & \AMSSYM{\nrightarrow} & \AMSSYM{\nleftrightarrow}\\ - \AMSSYM{\nLeftarrow} & \AMSSYM{\nRightarrow} & \AMSSYM{\nLeftrightarrow} \\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{\AmS\ 定界符}\label{tbl:ams-delims} -\begin{symbols}{*4{cl}} -\hline -\AMSSYM{\ulcorner}&\AMSSYM{\urcorner}&\AMSSYM{\llcorner}&\AMSSYM{\lrcorner}\\ -\AMSSYM{\lvert} &\AMSSYM{\rvert} &\AMSSYM{\lVert} &\AMSSYM{\rVert}\\ -\hline -\end{symbols} -\end{table} - -\begin{table}[htp] -\centering -\caption{\AmS\ 其它符号。}\label{tbl:ams-misc} -\begin{symbols}{*3{cl}} -\hline - \AMSSYM{\hbar} & \AMSSYM{\hslash} & \AMSSYM{\Bbbk} \\ - \AMSSYM{\square} & \AMSSYM{\blacksquare} & \AMSSYM{\circledS} \\ - \AMSSYM{\vartriangle} & \AMSSYM{\blacktriangle} & \AMSSYM{\complement} \\ - \AMSSYM{\triangledown} & \AMSSYM{\blacktriangledown}& \AMSSYM{\Game} \\ - \AMSSYM{\lozenge} & \AMSSYM{\blacklozenge} & \AMSSYM{\bigstar} \\ - \AMSSYM{\angle} & \AMSSYM{\measuredangle} & \\ - \AMSSYM{\diagup} & \AMSSYM{\diagdown} & \AMSSYM{\backprime} \\ - \AMSSYM{\nexists} & \AMSSYM{\Finv} & \AMSSYM{\varnothing} \\ - \AMSSYM{\eth} & \AMSSYM{\sphericalangle} & \AMSSYM{\mho} \\ -\hline -\end{symbols} -\end{table} - -\endinput \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/lshort-chinese/src/titlepage.tex b/Master/texmf-dist/doc/latex/lshort-chinese/src/titlepage.tex deleted file mode 100644 index e6d3bb0be45..00000000000 --- a/Master/texmf-dist/doc/latex/lshort-chinese/src/titlepage.tex +++ /dev/null @@ -1,35 +0,0 @@ -\pdfbookmark{标题页}{title} -\thispagestyle{empty} - -\vspace*{\stretch{1}} -\noindent\begin{minipage}{\textwidth} -\raggedleft -{\huge \bfseries 一份(不太)简短的~\LaTeXe{}~介绍} -\noindent\rule[-1ex]{\textwidth}{5pt}\\[2.5ex] -\hfill\emph{\Large 或~\pageref{lshort-minutes}~分钟了解~\LaTeXe} -\end{minipage} - -\vspace{\stretch{1}} -\noindent\rlap{% - \begin{minipage}{\textwidth} - \linespread{2}\selectfont\raggedleft - {\bfseries 英文作者:} Tobias Oetiker\\ - Hubert Partl, Irene Hyna and Elisabeth Schlegl \\ - {\bfseries 英文版本:} Version~\lshortversionoriginal, \lshortdateoriginal\\[4ex] - {\bfseries 中文翻译:} C\TeX\ 开发小组 \\ - {\bfseries 中文版本:} 版本~\lshortversioncn,\zhdigits*{\the\year}年\zhnumber{\the\month}月 - \end{minipage}% -} - -\vspace{\stretch{2}} - -\newpage\thispagestyle{empty} -\begin{quote}\footnotesize - Copyright \copyright{} {\the\year} Chinese \TeX\ Society. \\ - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.3 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled ``GNU - Free Documentation License''. -\end{quote} \ No newline at end of file -- cgit v1.2.3