diff options
Diffstat (limited to 'info/lshort/chinese/src/chap/chap.03.elements.tex')
-rw-r--r-- | info/lshort/chinese/src/chap/chap.03.elements.tex | 106 |
1 files changed, 62 insertions, 44 deletions
diff --git a/info/lshort/chinese/src/chap/chap.03.elements.tex b/info/lshort/chinese/src/chap/chap.03.elements.tex index 4d289d43e3..a1f67029e0 100644 --- a/info/lshort/chinese/src/chap/chap.03.elements.tex +++ b/info/lshort/chinese/src/chap/chap.03.elements.tex @@ -10,7 +10,7 @@ \subsection{章节标题}\label{subsec:secs} \cmdindex{part,chapter,section,subsection,subsubsection,paragraph,subparagraph} -\clsindex{article,book,report} +\clsindex{article,report,book} 一篇结构化的、条理清晰文档一定是层次分明的,通过不同的命令分割为章、节、小节。三个标准文档类 \cls{article}、\cls{report} 和 \cls{book}% \footnote{千万注意是\textbf{标准文档类},其它文档类,如果不是从标准文档类衍生而来, @@ -24,7 +24,7 @@ \cmd{paragraph}\marg{title} \quad \cmd{subparagraph}\marg{title} \end{command} -其中 \cmd{chapter} \textbf{只在 \cls{book} 和 \cls{report} 文档类有定义}。这些命令生成章节标题,并能够自动编号。 +其中 \cmd{chapter} \textbf{只在 \cls{report} 和 \cls{book} 文档类有定义}。这些命令生成章节标题,并能够自动编号。 除此之外 \LaTeX{} 还提供了 \cmd{part} 命令,用来将整个文档分割为大的分块,但不影响 \cmd{chapter} 或 \cmd{section} 等的编号。 上述命令除了生成带编号的标题之外,还向目录中添加条目,并影响页眉页脚的内容(详见 \ref{sec:pagestyle} 节)。每个命令有两种变体: @@ -38,7 +38,7 @@ 较低层次如 \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} 三级。 + \item \cls{report} / \cls{book} 文档类带编号的层级为 \cmd{chapter} / \cmd{section} / \cmd{sub\-section} 三级。 \end{itemize} 对此的详细解释和调整方法见 \ref{subsec:latex-counts} 小节。 @@ -54,7 +54,7 @@ \cmd{tableofcontents} \end{command} -这个命令会生成单独的一章(\cls{book} / \cls{report})或一节(\cls{article}),标题默认为 ``Contents''{},可通过 \ref{sec:latex-settings} 节给出的方法定制标题。 +这个命令会生成单独的一章(\cls{report} / \cls{book})或一节(\cls{article}),标题默认为“Contents”,可通过 \ref{sec:latex-settings} 节给出的方法定制标题。 \cmd{tableof\-contents} 生成的章节默认不写入目录(\cmd{section*} 或 \cmd{chapter*}),可使用 \pkg{tocbibind} 等宏包修改设置。 正确生成目录项,一般需要编译两次源代码。 @@ -82,8 +82,8 @@ \cmdindex{frontmatter,mainmatter,backmatter} \cls{book} 文档类还提供了前言、正文、后记结构的划分命令: \begin{description} - \item[\cmd{frontmatter}] 前言部分,页码为小写罗马字母格式;其后的 \cmd{chapter} 不编号。 - \item[\cmd{mainmatter}] 正文部分,页码为阿拉伯数字格式,从 1 开始计数;其后的章节编号正常。 + \item[\cmd{frontmatter}] 前言部分,页码使用小写罗马数字;其后的 \cmd{chapter} 不编号。 + \item[\cmd{mainmatter}] 正文部分,页码使用阿拉伯数字,从 1 开始计数;其后的章节编号正常。 \item[\cmd{backmatter}] 后记部分,页码格式不变,继续正常计数;其后的 \cmd{chapter} 不编号。 \end{description} @@ -117,7 +117,7 @@ ... \backmatter % 后记部分 -\include{prologue} % 后记 prologue.tex +\include{epilogue} % 后记 epilogue.tex \bibliography{books} % 利用 BibTeX 工具从数据库文件 books.bib 生成参考文献 \printindex % 利用 makeindex 工具生成索引 @@ -229,7 +229,7 @@ page~\pageref{sec:this}.'' \item[定理环境] 在定理环境内部任意位置使用。 \end{description} -在使用不记编号的命令形式(\cmd{section*}、\cmd{caption*}、带可选参数的 \cmd{item} 命令等)时不要使用 \cmd{label} 命令, +在使用不记编号的命令形式(\cmd{section*}、\cmd{caption*}\footnote{需加载相关宏包,如 \pkg{caption}}、带可选参数的 \cmd{item} 命令等)时不要使用 \cmd{label} 命令, 否则生成的引用编号不正确。 \section{脚注和边注}\label{sec:footnote-marginpar} @@ -521,7 +521,7 @@ for (int i=0; i<4; ++i) \crcmd{} 用来换行;\cmd{hline} 用来在行与行之间绘制横线。 直接使用 \env{tabular} 环境的话,会\textbf{和周围的文字混排}。此时可用一个可选参数 \Arg{align} 控制垂直对齐: -\verb|t| 和 \verb|b| 分别表示按按表格顶部、底部对齐,其他参数或省略不写(默认)表示居中对齐。 +\verb|t| 和 \verb|b| 分别表示按表格顶部、底部对齐,其他参数或省略不写(默认)表示居中对齐。 \begin{example} \begin{tabular}{|c|} center-\\ aligned \\ @@ -587,6 +587,7 @@ for (int i=0; i<4; ++i) 有时需要为整列修饰格式,比如整列改变为粗体,如果每个单元格都加上 \cmd{bfseries} 命令会比较麻烦。 \pkg{array} 宏包提供了辅助格式 \texttt> 和 \texttt<,用于给列格式前后加上修饰命令: \begin{example} +% \usepackage{array} \begin{tabular}{>{\itshape}r<{*}l} \hline italic & normal \\ @@ -601,7 +602,8 @@ for (int i=0; i<4; ++i) \cmd{array\-back\-slash} 用来恢复之。如果不加 \cmd{array\-back\-slash} 命令, 也可以用 \cmd{tabular\-newline} 命令代替原来的 \crcmd{} 实现表格换行。}: \begin{example} -\begin{tabular} +% \usepackage{array} +\begin{tabular}% {>{\centering\arraybackslash}p{9em}} \hline Some center-aligned long text. \\ @@ -612,8 +614,8 @@ for (int i=0; i<4; ++i) \pkg{array} 宏包还提供了类似 \texttt{p} 格式的 \texttt{m} 格式和 \texttt{b} 格式, 三者分别在垂直方向上靠顶端对齐、居中以及底端对齐。 \begin{example} -\newcommand\txt - {a b c d e f g h i} +% \usepackage{array} +\newcommand\txt{a b c d e f g h i} \begin{tabular}{cp{2em}m{2em}b{2em}} \hline pos & \txt & \txt & \txt \\ @@ -645,6 +647,7 @@ for (int i=0; i<4; ++i) 不过会根据表格宽度自动计算列宽,多个 \texttt{X} 列格式平均分配列宽。 \texttt{X} 列格式也可以用 \pkg{array} 里的辅助格式修饰对齐方式: \begin{example} +% \usepackage{array,tabularx} \begin{tabularx}{14em}% {|*{4}{>{\centering\arraybackslash}X|}} \hline @@ -672,6 +675,7 @@ for (int i=0; i<4; ++i) 三线表由 \pkg{booktabs} 宏包支持,它提供了 \cmd{toprule}、\cmd{midrule} 和 \cmd{bottomrule} 命令用以排版三线表的三条线, 以及和 \cmd{cline} 对应的 \cmd{cmidrule}。除此之外,最好不要用其它横线以及竖线: \begin{example} +% \usepackage{booktabs} \begin{tabular}{cccc} \toprule & \multicolumn{3}{c}{Numbers} \\ @@ -714,6 +718,7 @@ for (int i=0; i<4; ++i) 我们看一个结合 \cmd{cline}、\cmd{multi\-column} 和 \cmd{multi\-row} 命令的例子: \begin{example} +% \usepackage{multirow} \begin{tabular}{ccc} \hline \multirow{2}{*}{Item} & @@ -747,6 +752,7 @@ for (int i=0; i<4; ++i) 如果不需要为“拆分的单元格”画线,并且只在垂直方向“拆分”的话,\pkg{makecell} 宏包提供的 \cmd{make\-cell} 命令是一个简单的解决方案: \begin{example} +% \usepackage{makecell} \begin{tabular}{|c|c|} \hline a & \makecell{d1 \\ d2} \\ @@ -781,7 +787,7 @@ for (int i=0; i<4; ++i) \end{tabular} \end{example} -但是这种换行方式的存在导致了一个缺陷——\textbf{表格的首个单元格不能直接使用中括号 \texttt{[]}}, +但是这种换行方式的存在导致了一个缺陷——\textbf{从第二行开始,表格的首个单元格不能直接使用中括号 \texttt{[]}}, 否则 \crcmd{} 往往会将下一行的中括号当作自己的可选参数,因而出错。如果要使用中括号,应当放在花括号 \marg*{} 里面。 或者也可以选择将换行命令写成 \crcmd\texttt{[0pt]}。 @@ -800,7 +806,7 @@ for (int i=0; i<4; ++i) \ref{sec:hyperlinks} 节中的 \pkg{hyperref} 宏包同理。};而使用 \texttt{pdflatex} 或 \texttt{xelatex} 命令编译时不需要。 读者可能听说过“\LaTeX{} 只能插入 \texttt{.eps} 格式的图片,需要把 \texttt{.jpg} 转成 \texttt{.eps} 格式”的观点。 -\LaTeX{} 发展到今天,这个观点早已过时。事实上不同的编译命令支持的图片格式范围各异,见表 \ref{tbl:figure-format}。 +\LaTeX{} 发展到今天,这个观点早已过时。事实上不同编译命令支持的图片格式种类各异,见表~\ref{tbl:figure-format}。 这个表格也能解答诸如“为什么 \texttt{.eps} 格式图片在 \texttt{pdflatex} 编译命令下出错”之类的问题。本表格也再一次说明,使用 \texttt{xelatex} 命令是笔者最推荐的方式。 @@ -811,7 +817,7 @@ for (int i=0; i<4; ++i) \hline \textbf{格式} & \textbf{矢量图} & \textbf{位图} \\ \hline - \texttt{latex + dvipdfmx} & \texttt{.eps} & n/a \\ + \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] @@ -841,7 +847,8 @@ for (int i=0; i<4; ++i) \graphicspath{{figures/}{logo/}} \end{verbatim} -\cmd{includegraphics} 命令的可选参数 \Arg{options} 支持 \Arg{key}=\Arg{value} 形式赋值,常用的参数如下: +在 \cmd{includegraphics} 命令的可选参数 \Arg{options} 中可以使用 \Arg{key}=\Arg{value} 的形式, +常用的参数如下: \begin{table}[htp] \centering \caption{\cmd{includegraphics} 命令的可选参数}\label{tbl:graphics-options} @@ -852,17 +859,20 @@ for (int i=0; i<4; ++i) \texttt{width=}\Arg{width} & 将图片缩放到宽度为 \Arg{width} \\ \texttt{height=}\Arg{height} & 将图片缩放到高度为 \Arg{height} \\ \texttt{scale=}\Arg{scale} & 将图片相对于原尺寸缩放 \Arg{scale} 倍 \\ - \texttt{angle=}\Arg{angle} & 令图片逆时针旋转 \Arg{angle} 度 \\ + \texttt{angle=}\Arg{angle} & 将图片逆时针旋转 \Arg{angle} 度 \\ \hline \end{tabular} \end{table} +\pkg{graphicx} 宏包也支持 \texttt{draft}/\texttt{final} 选项。当 \pkg{graphicx} 宏包或文档类指定 +\texttt{draft} 选项时,图片将不会被实际插入,取而代之的是一个包含文件名的与原图片等大的方框。 + \section{盒子}\label{sec:box} -盒子是 \LaTeX{} 排版的基础单元,虽然解释上去有些抽象:每一行是一个盒子, -里面的文字从左到右依次排列;每一页也是一个盒子,各行文字从上到下依次排布……颇有一些活字印刷术的味道。 +盒子是 \LaTeX{} 排版的基础单元,虽然解释略有抽象:每一行是一个盒子,里面的文字从左到右依次排列; +每一页也是一个盒子,各行文字从上到下依次排布……颇有一些活字印刷术的味道。 -不管如何,\LaTeX{} 提供了一些命令让我们生成一些有特定用途的盒子。 +不管如何,\LaTeX{} 提供了一些命令让我们手动生成一些有特定用途的盒子。 \subsection{水平盒子}\label{subsec:mbox} @@ -878,7 +888,9 @@ for (int i=0; i<4; ++i) \cmd{makebox} 更进一步,可以加上可选参数用于控制盒子的宽度 \Arg{width},以及内容的对齐方式 \Arg{align}, 可选居中 \texttt{c}(默认值)、左对齐 \texttt{l}、右对齐 \texttt{r} 和分散对齐 \texttt{s}% -\footnote{分散对齐方式强行拉开单词的间距,往往会报 \texttt{Underfull} \cmd{hbox} 的消息。}。 +\footnote{分散对齐方式强行拉开单词的间距,往往会报 \texttt{Underfull} \cmd{hbox} 的警告。}。 + +% 此处会有 Underfull \hbox 警告 \begin{example} |\mbox{Test some words.}|\\ |\makebox[10em]{Test some words.}|\\ @@ -1025,12 +1037,12 @@ A \rule[-.4pt]{3em}{.4pt} line. \begin{command} \cmd{caption}\marg*{\ldots} \end{command} -\cmd{caption} 的用法非常类似于 \cmd{section} 等命令,可以用带星号的命令 \cmd{caption*} 生成不带编号的标题, +\cmd{caption} 的用法非常类似于 \cmd{section} 等命令,可以用带星号的命令 \cmd{caption*}\footnote{需加载相关宏包,如 \pkg{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{caption} 生成的标题形如“Figure 1: \ldots”(\env{figure} 环境)或“Table 1: \ldots”(\env{table} 环境)。 可通过修改 \cmd{figurename} 和 \cmd{tablename} 的内容来修改标题的前缀(详见第 \ref{sec:latex-settings} 节)。 标题样式的定制功能由 \pkg{caption} 宏包提供,详见该宏包的帮助文档,在此不作赘述。 @@ -1052,7 +1064,7 @@ A \rule[-.4pt]{3em}{.4pt} line. \centering \includegraphics[width=...]{...} \qquad - \includegraphics[width=...]{...} \\[..pt] + \includegraphics[width=...]{...} \\[...pt] \includegraphics[width=...]{...} \caption{...} \end{figure} @@ -1102,44 +1114,50 @@ A \rule[-.4pt]{3em}{.4pt} line. \end{minipage} \end{figure} -\pkgindex{subfig} -\cmdindex[subfig]{subfloat} -当我们需要更进一步,给每个图片定义小标题时,就要用到 \pkg{subfig} 宏包的功能了。 -这里仅举一例,效果见图 \ref{fig:subfig}。更详细的用法请参考 \pkg{subfig} 宏包的帮助文档。 +\pkgindex{subcaption} +\envindex[subcaption]{subfigure} +当我们需要更进一步,给每个图片定义小标题时,就要用到 \pkg{subcaption} 宏包的功能了。这里仅举一例, +效果见图 \ref{fig:subfigure-cap1} 和 \ref{fig:subfigure-cap2}。更详细的用法请参考 \pkg{subcaption} +宏包的帮助文档。 \begin{verbatim} \begin{figure}[htbp] \centering - \subfloat[...]{\label{sub-fig-1}% 为子图加交叉引用 - \begin{minipage}{...} + \begin{subfigure}{...} \centering \includegraphics[width=...]{...} - \end{minipage} - } + \caption{...} + \end{subfigure} \qquad - \subfloat[...]{% - \begin{minipage}{...} + \begin{subfigure}{...} \centering \includegraphics[width=...]{...} - \end{minipage} - } - \caption{...} + \caption{...} + \end{subfigure} \end{figure} \end{verbatim} \begin{figure}[htp] \centering - \subfloat[并排子图1]{% - \begin{minipage}{12em} + \begin{subfigure}{12em} \centering \fcolorbox[gray]{0}{0.96}{\parbox{10em}{\vrule width 0pt height 12ex\hfil}} - \end{minipage}} + \caption{并排子图 1} + \label{fig:subfigure-cap1} + \end{subfigure} \qquad - \subfloat[并排子图2]{% - \begin{minipage}{12em} + \begin{subfigure}{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} + \caption{并排子图 2} + \label{fig:subfigure-cap2} + \end{subfigure} + \caption{使用 \pkg{subcaption} 宏包的 \env{subfigure} 环境排版子图。} + \label{fig:subcaption} \end{figure} +\pkgindex{caption,subfig} +\cmdindex[subfig]{subfloat} +\pkg{subcaption} 依赖上文提到过的 \pkg{caption} 宏包,因此也支持子图表标题样式的定制。并排子图表的 +功能也可通过 \pkg{subfig} 宏包的 \cmd{subfloat} 命令实现,具体请参考宏包文档。 + \endinput |