[关闭]
@gnat-xj 2015-11-17T02:44:50.000000Z 字数 78936 阅读 7263

LaTeX 入门(刘海洋) --- example code(已经备份)

tex


LaTeX 入门

<--Code Highlight-->

src/0-1.tex

  1. $\Delta = b^2 - 4ac$

src/0-2.tex

  1. \[
  2. x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
  3. \]

src/1-1-01.tex

  1. \documentclass{article}
  2. \begin{document}
  3. This is my first document.
  4. Happy \TeX ing!
  5. \end{document}

src/1-1-02.tex

  1. \documentclass[UTF8]{ctexart}
  2. \begin{document}
  3. \section{文字}
  4. 特可爱排版。
  5. \section{数学}
  6. \[
  7. a^2 + b^2 = c^2
  8. \]
  9. \end{document}

src/1-2-01.tex

  1. \begin{equation}
  2. a(b+c) = ab + ac
  3. \end{equation}

src/1-2-02.tex

  1. $\angle ACB = \pi / 2$

src/1-2-03.tex

  1. \begin{equation}
  2. AB^2 = BC^2 + AC^2.
  3. \end{equation}

src/1-2-04.tex

  1. \includegraphics[width=3cm]{xiantu.pdf}

src/1-2-05.tex

  1. \begin{table}[H]
  2. \begin{tabular}{|rrr|}
  3. \hline
  4. 直角边 $a$ & 直角边 $b$ & 斜边 $c$\\
  5. \hline
  6. 3 & 4 & 5 \\
  7. 5 & 12 & 13 \\
  8. \hline
  9. \end{tabular}%
  10. \qquad
  11. ($a^2 + b^2 = c^2$)
  12. \end{table}

src/2-1-01.tex

  1. % UTF-8 编码
  2. café\quad Gödel\quad Antonín Dvořák
  3. χαϊδεύης\qquad Крюкова

src/2-1-02.tex

  1. \usepackage[greek,english]{babel}

src/2-1-03.tex

  1. % 导言区 \usepackage[OT2,OT1]{fontenc}
  2. {\fontencoding{OT2}\selectfont ABCabc}

src/2-1-04.tex

  1. % coding: utf-8
  2. % pdflatex 命令编译
  3. \documentclass{article}
  4. \usepackage[OT2,T1]{fontenc}
  5. \usepackage[utf8]{inputenc}
  6. \begin{document}
  7. café \qquad Gödel
  8. {\fontencoding{OT2}\selectfont Крюкова}
  9. \end{document}

src/2-1-05.tex

  1. differ find flight difficlut ruffle

src/2-1-06.tex

  1. shelfful shelf{}ful shelf\/ful

src/2-1-07.tex

  1. ``\,`A' or `B?'\,'' he asked.

src/2-1-08.tex

  1. An inter-word dash or, hyphen, as in X-ray.
  2. A medium dash for number ranges, like 1--2.
  3. A punctuation dash---like this.

src/2-1-09.tex

  1. Good: One, two, three\ldots
  2. Bad: One, two, three...

src/2-1-10.tex

  1. She $\ldots$ she got it.
  2. I've no idea\ldots.

src/2-1-11.tex

  1. \# \quad \$ \quad \% \quad \& \quad
  2. \{ \quad \} \quad \_ \quad
  3. \textbackslash

src/2-1-12.tex

  1. This is a short
  2. sentence. This is
  3. another.

src/2-1-13.tex

  1. Happy \TeX ing. Happy \TeX\ ing.
  2. Happy \TeX{} ing. Happy {\TeX} ing.

src/2-1-14.tex

  1. Question~1 % 名称与编号间
  2. Donald~E. Knuth % 教名之间,但姓可以断行
  3. Mr.~Knuth % 称谓缩写与名字间
  4. function~$f(x)$ % 名字后的短公式
  5. 1,~2, and~3 % 序列的部分符号间

src/2-1-15.tex

  1. A sentence. And another.
  2. U.S.A. means United States Army?
  3. Tinker et al.\ made the double play.
  4. Roman number XII\@. Yes.

src/2-1-16.tex

  1. 中文和English的混排效果
  2. 并不依赖于 space 的有无。

src/2-1-17.tex

  1. \mbox{条目}-a 不同于条目-b

src/2-1-18.tex

  1. \CJKsetecglue{}
  2. 汉字word

src/2-1-19.tex

  1. 幻影\phantom{参数}速速隐形
  2. 幻影参数速速显形

src/2-1-20.tex

  1. 这是一行文字\\另一行
  2. 这是一行文字\linebreak 另一行

src/2-1-21.tex

  1. \begin{align*}
  2. [2 - (3+5)]\times 7 &= 42 \\{}
  3. [2 + (3-5)]\times 7 &= 0
  4. \end{align*}

src/2-1-22.tex

  1. ® © £ §

src/2-1-23.tex

  1. \usefont{T1}{t1xr}{m}{n}
  2. \symbol{"DE}\symbol{"FE}

src/2-1-24.tex

  1. \symbol{28450}\symbol{35486}

src/2-1-25.tex

  1. \textit{Italic font test}
  2. {\bfseries Bold font test}

src/2-1-26.tex

  1. \sffamily
  2. \textbf{This is a paragraph of bold and
  3. \textit{italic font, sometimes returning
  4. to \textnormal{normal font} is necessary.}}

src/2-1-27.tex

  1. {\itshape M}M
  2. \textit{M}M
  3. {\itshape M\/}M

src/2-1-28.tex

  1. Bold `{\bfseries leaf}'
  2. Bold `{\bfseries leaf\/}'
  3. Bold `\textbf{leaf}'

src/2-1-29.tex

  1. \textit{M}M
  2. \textit{M\nocorr}M

src/2-1-30.tex

  1. {\CJKfamily{hei}这是黑体}
  2. {\CJKfamily{kai}这是楷书}

src/2-1-31.tex

  1. {\songti 宋体} \quad {\heiti 黑体} \quad
  2. {\fangsong 仿宋} \quad {\kaishu 楷书}

src/2-1-32.tex

  1. % ctex 宏包下默认相当于 \CJKfamily{rm}
  2. % \rmfamily \textrm 也会同时设置此字体
  3. 中文字体的\textbf{粗体}与\textit{斜体}

src/2-1-33.tex

  1. \fontencoding{OT1}\fontfamily{pzc}
  2. \fontseries{mb}\fontshape{it}
  3. \fontsize{14}{17}\selectfont
  4. PostScript New Century Schoolbook

src/2-1-34.tex

  1. \usefont{T1}{pbk}{db}{n}
  2. PostScript Bookman Demibold Normal

src/2-1-35.tex

  1. \documentclass{article}
  2. \usepackage{txfonts}
  3. \begin{document}
  4. Test text
  5. \end{document}

src/2-1-36.tex

  1. \documentclass{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{ccfonts,eulervm}
  4. \begin{document}
  5. Test text
  6. \end{document}

src/2-1-37.tex

  1. % 在导言区设置全文字体为 Windows 提供的
  2. % Times New Roman, Verdana, Courier New 字体
  3. \usepackage{fontspec}
  4. \setmainfont{Times New Roman}
  5. \setsansfont{Verdana}
  6. \setmonofont{Courier New}

src/2-1-38.tex

  1. % 导言区使用
  2. \newfontfamily\lucidasans{Lucida Sans}
  3. % 正文使用
  4. {\lucidasans This is Lucida Sans.}

src/2-1-39.tex

  1. \newfontfamily\minion[Numbers=SlashedZero]{Minion Pro}
  2. \minion 100, OK.

src/2-1-40.tex

  1. \documentclass{article}
  2. \usepackage{ccfonts}% 公式使用 Concrete 系列字体
  3. \usepackage[no-math]{fontspec}% \mathrm 等也使用 Concrete 系列字体
  4. \setmainfont{Latin Modern Mono Prop}% 正文使用 Ladin Modern Mono 字体

src/2-1-41.tex

  1. \documentclass[no-math]{ctexart}
  2. \usepackage[utopia]{mathdesign}% 数字字体使用 mathdesign Utopia
  3. \usepackage[EU1]{fontenc}% 恢复正文字体的 Unicode 编码
  4. \setmainfont{Utopia Std}% 正文字体使用 OpenType 格式的 Adobe Utopia

src/2-1-42.tex

  1. \documentclass[UTF8]{ctexart}
  2. % 西文正文和数学字体
  3. \let\hbar\relax % 解决 xunicode fourier 的符号冲突
  4. \usepackage{fourier}
  5. % 设置默认编码为 T1,以支持 fourier 宏包
  6. \usepackage[T1]{fontenc}
  7. % 定义新的西文 Times 字体族
  8. \newfontfamily\times{Times New Roman}
  9. % 设置西文等宽字体,并重定义 \ttfamily 来切换到 EU1 编码
  10. \setmonofont{Consolas}
  11. \let\oldttfamily\ttfamily
  12. \def\ttfamily{\oldttfamily\fontencoding{EU1}\selectfont}
  13. % 设置中文字体
  14. \setCJKmainfont{Adobe Kaiti Std}
  15. \begin{document}
  16. Utopia text and $\sum math$ fonts.
  17. 汉字楷书与 {\times Times New Roman} 字体。
  18. \texttt{Consolas 0123}
  19. \end{document}

src/2-1-43.tex

  1. % XeLaTeX 编译
  2. \documentclass[UTF8]{ctexart}
  3. % 不需要 tipa 宏包,xunicode 已经实现其功能
  4. \setmainfont{CMU Serif} % Computer Modern Roman Unicode 版本
  5. \begin{document}
  6. \LaTeX{} 读音为 \textipa{["lA:tEx]}。
  7. \end{document}

src/2-1-44.tex

  1. % XeLaTeX 编译
  2. \documentclass[UTF8]{ctexart}
  3. \usepackage{tipa}% 宏包已经正确加载 fontenc
  4. % \mytipa 的定义参考原来的 \textipa 的旧定义,手工切换编码
  5. \newcommand\mytipa[1]{{\fontencoding{T3}\selectfont#1}}
  6. \begin{document}
  7. \LaTeX{} 读音为 \mytipa{["lA:tEx]}。
  8. \end{document}

src/2-1-45.tex

  1. \fontfamily{cmfib}\selectfont
  2. Computer Modern Fibonacci Roman

src/2-1-46.tex

  1. % 导言区修改全文默认字体 Computer Modern Fibonacci 字体族
  2. \renewcommand\rmdefault{cmfib}

src/2-1-47.tex

  1. % 导言区修改全文默认字体为无衬线字体族 phvHelvetica
  2. \renewcommand\familydefault{\sfdefault}
  3. \renewcommand\sfdefault{phv}

src/2-1-48.tex

  1. \renewcommand\CJKfamilydefault{\CJKsfdefault}

src/2-1-49.tex

  1. \xfonttable{OT1}{lmr}{m}{n}

src/2-1-50.tex

  1. You \emph{should} use fonts carefully.
  2. \textit{%
  3. You \emph{should} use fonts carefully.}

src/2-1-51.tex

  1. This is {\em emphasized\/} text.

src/2-1-52.tex

  1. \newcommand\Emph{\textbf}
  2. This is \Emph{emphasized} text.

src/2-1-53.tex

  1. \underline{Emphasized} text and
  2. \underline{another}.

src/2-1-54.tex

  1. % 导言区用 \usepackage{ulem}
  2. \uline{Emphasized} text and \uline{another}.
  3. A \emph{very very very very very very very
  4. very very very very very} long sentence.

src/2-1-55.tex

  1. \uuline{urgent}\qquad \uwave{boat}\qquad
  2. \sout{wrong}\qquad \xout{removed}\qquad
  3. \dashuline{dashing}\qquad \dotuline{dotty}

src/2-1-56.tex

  1. \CJKunderdot{汉字,下加点}\\
  2. \CJKunderline{汉字,下划线} \\
  3. \CJKunderdblline{汉字,下划线} \\
  4. \CJKunderwave{汉字,下划线} \\
  5. \CJKsout{汉字,删除线}\\
  6. \CJKxout{汉字,删除线}

src/2-1-57.tex

  1. \begin{CJKfilltwosides}{5cm}
  2. 汉字,分散对齐
  3. \end{CJKfilltwosides}

src/2-1-58.tex

  1. \emph{汉字,强调}\\
  2. \CTEXunderdot{汉字,加点}

src/2-1-59.tex

  1. The text can be {\Large larger}.

src/2-1-60.tex

  1. \setlength{\lineskiplimit}{2.625bp} % 五号字 1/4 字高
  2. \setlength{\lineskip}{2.625bp}

src/2-1-61.tex

  1. 1\,234\,567\,890

src/2-1-62.tex

  1. \newcommand\dbldag{\dag\!\dag}
  2. \dbldag\ versus \dag\dag

src/2-1-63.tex

  1. Space\hspace{1cm}1\,cm

src/2-1-64.tex

  1. text\\
  2. \hspace{1cm}text\\
  3. \hspace*{1cm}text

src/2-1-65.tex

  1. \newcommand\test{longggggggg%
  2. \hspace{2em plus 1em minus 0.25em}}
  3. \test\test\test\test\test\test\test\test

src/2-1-66.tex

  1. left\hspace{\fill}middle%
  2. \hfill right

src/2-1-67.tex

  1. left\hspace{\stretch{2}}$2/3$%
  2. \hspace{\fill}right

src/2-1-68.tex

  1. left\hrulefill middle\dotfill right

src/2-1-69.tex

  1. \setlength{\parindent}{8em}
  2. Paragraph indent can be very wide in \LaTeX.

src/2-1-70.tex

  1. Para\par
  2. \addtolength{\parindent}{2em}Para\par
  3. \addtolength{\parindent}{2em}Para\par

src/2-1-71.tex

  1. \mbox{cannot be broken}

src/2-1-72.tex

  1. \makebox[1em]{\textbullet}text \\
  2. \makebox[5cm][s]{some stretched text}

src/2-1-73.tex

  1. 语言文字\llap{word}\\
  2. \rlap{word}语言文字

src/2-1-74.tex

  1. \fbox{framed} \\
  2. \framebox[3cm][s]{framed box}

src/2-1-75.tex

  1. \setlength{\fboxsep}{0pt} \fbox{tight}
  2. \setlength{\fboxsep}{1em} \fbox{loose}

src/2-1-76.tex

  1. \newsavebox{\mybox} % 通常在导言区定义
  2. \sbox{\mybox}{test text}
  3. \usebox{\mybox} \fbox{\usebox{\mybox}}

src/2-1-77.tex

  1. \newsavebox{\verbbox} % 通常在导言区定义
  2. \begin{lrbox}{\verbbox}
  3. \verb|#$%^&{}|
  4. \end{lrbox}
  5. \usebox{\verbbox} \fbox{\usebox{\verbbox}}

src/2-1-78.tex

  1. \framebox[2\width]{带边框}

src/2-2-01.tex

  1. \setlength{\parskip}{0pt}

src/2-2-02.tex

  1. \raggedright
  2. English words like `technology' stem from a
  3. Greek root beginning with the letters τεχ\dots

src/2-2-03.tex

  1. \begin{center}
  2. 居中
  3. \end{center}

src/2-2-04.tex

  1. \hyphenation{man-u-script com-pu-ter gym-na-sium}

src/2-2-05.tex

  1. % 导言区 \usepackage{ragged2e}
  2. \RaggedRight
  3. English words like `technology' stem from a
  4. Greek root beginning with the letters τεχ\dots

src/2-2-06.tex

  1. \setlength{\leftskip}{4em}
  2. \setlength{\rightskip}{1em}
  3. These parameters tell \TeX{} how much glue
  4. to place at the left and at the right end
  5. of each line of the current paragraph.

src/2-2-07.tex

  1. \hangindent=5pc \hangafter=-2
  2. These two parameters jointly specify
  3. ``hanging indentation'' for a paragraph.
  4. The hanging indentation indicates to \TeX{}
  5. that certain lines of the paragraph should
  6. be indented and the remaining lines should
  7. have their normal width.

src/2-2-08.tex

  1. % 导言区 \usepackage{lettrine}
  2. \lettrine{T}{he} \TeX{} in \LaTeX{} refers
  3. to Donald Knuth's \TeX{} typesetting system.
  4. The \LaTeX{} program is a special version of
  5. \TeX{} that understands \LaTeX{} commands.

src/2-2-09.tex

  1. % 导言区 \usepackage{shapepar}
  2. \heartpar{%
  3. 绿草苍苍,白雾茫茫,有位佳人,在水一方。
  4. 绿草萋萋,白雾迷离,有位佳人,靠水而居。
  5. 我愿逆流而上,依偎在她身旁。无奈前有险滩,道路又远又长。
  6. 我愿顺流而下,找寻她的方向。却见依稀仿佛,她在水的中央。
  7. 我愿逆流而上,与她轻言细语。无奈前有险滩,道路曲折无已。
  8. 我愿顺流而下,找寻她的足迹。却见仿佛依稀,她在水中伫立。}

src/2-2-10.tex

  1. 前文……
  2. \begin{quote}
  3. 学而时习之,不亦说乎?
  4. 有朋自远方来,不亦乐乎?
  5. \end{quote}
  6. 后文……

src/2-2-11.tex

  1. 前文……
  2. \begin{quotation}
  3. 学而时习之,不亦说乎?
  4. 有朋自远方来,不亦乐乎?
  5. 默而识之,学而不厌,诲人不倦,何有于我哉?
  6. \end{quotation}
  7. 后文……

src/2-2-12.tex

  1. \begin{verse}
  2. 在一段内使用 \verb=\\= 换行,\\
  3. 分段仍用空行。
  4. 过长的长会在折行时悬挂缩进,
  5. 就像现在这一句。
  6. \end{verse}

src/2-2-13.tex

  1. \begin{abstract}
  2. 本书讲解 \LaTeX{} 的使用。
  3. \end{abstract}

src/2-2-14.tex

  1. \CTEXoptions[abstractname={摘\quad 要}]

src/2-2-15.tex

  1. \begin{enumerate}
  2. \item 中文
  3. \item English
  4. \item Français
  5. \end{enumerate}

src/2-2-16.tex

  1. \begin{itemize}
  2. \item 中文
  3. \item English
  4. \item Français
  5. \end{itemize}

src/2-2-17.tex

  1. \begin{description}
  2. \item[中文] 中国的语言文字
  3. \item[English] The language of England
  4. \item[Français] La langue de France
  5. \end{description}

src/2-2-18.tex

  1. \begin{enumerate}
  2. \item 中文
  3. \begin{enumerate}
  4. \item 古代汉语
  5. \item 现代汉语
  6. \begin{enumerate}
  7. \item 口语
  8. \begin{enumerate}
  9. \item 普通话
  10. \item 方言
  11. \end{enumerate}
  12. \item 书面语
  13. \end{enumerate}
  14. \end{enumerate}
  15. \item English
  16. \item Français
  17. \end{enumerate}

src/2-2-19.tex

  1. \begin{enumerate}
  2. \item 中文
  3. \item[1a.] 汉语
  4. \item English
  5. \end{enumerate}

src/2-2-20.tex

  1. \begin{itemize}
  2. \item[\dag] 中文
  3. \item English
  4. \item Français
  5. \end{itemize}

src/2-2-21.tex

  1. \begin{enumerate}
  2. \item 这是编号 \theenumi
  3. \item 这是编号 \theenumi
  4. \end{enumerate}

src/2-2-22.tex

  1. \begin{enumerate}
  2. \item 编号
  3. \arabic{enumi}, \roman{enumi}, \Roman{enumi},
  4. \alph{enumi}, \Alph{enumi}, \fnsymbol{enumi}
  5. \item 编号
  6. \arabic{enumi}, \roman{enumi}, \Roman{enumi},
  7. \alph{enumi}, \Alph{enumi}, \fnsymbol{enumi}
  8. \item 编号
  9. \arabic{enumi}, \roman{enumi}, \Roman{enumi},
  10. \alph{enumi}, \Alph{enumi}, \fnsymbol{enumi}
  11. \end{enumerate}

src/2-2-23.tex

  1. \renewcommand\theenumi{\roman{enumi}}
  2. \renewcommand\labelenumi{(\theenumi)}
  3. \begin{enumerate}
  4. \item 使用中文
  5. \item Using English
  6. \end{enumerate}

src/2-2-24.tex

  1. % 计数器设置,通常在导言区
  2. \newcounter{mycnt}
  3. \setcounter{mycnt}{0} % 默认值就是 0
  4. \renewcommand\themycnt{\arabic{mycnt}} % 默认值就是阿拉伯数字
  5. % 计数器使用,通常做成自定义命令的一部分
  6. \stepcounter{mycnt}\themycnt 输出计数器值为 1
  7. \stepcounter{mycnt}\themycnt 输出计数器值为 2
  8. \addtocounter{mycnt}{1}\themycnt 输出计数器值为 3
  9. \addtocounter{mycnt}{-1}\themycnt 输出计数器值为 2
  10. \addtocounter{mycnt}{-1}\themycnt 输出计数器值为 1

src/2-2-25.tex

  1. \usepackage{amsmath}
  2. \numberwithin{equation}{section}

src/2-2-26.tex

  1. {% 使用分组让 \descriptionlabel 的修改局部化
  2. \renewcommand\descriptionlabel[1]{\normalfont\Large\itshape
  3. \textbullet\ #1}
  4. \begin{description}
  5. \item[标签] 可以修改 \verb=\descriptionlabel= 改变标签的格式。
  6. \item[其他] 其他格式的也可以参考后面的列表环境修改。
  7. \end{description}
  8. }

src/2-2-27.tex

  1. \newcounter{mylist}
  2. \begin{list}{\#\themylist}%
  3. {\usecounter{mylist}}
  4. \item 中文
  5. \item English
  6. \end{list}

src/2-2-28.tex

  1. \begin{list}{\textbullet}{%
  2. \setlength{\topsep}{0pt} \setlength{\partopsep}{0pt}
  3. \setlength{\parsep}{0pt} \setlength{\itemsep}{0pt}}
  4. \item 中文
  5. 又一段中文
  6. \item English
  7. \item Français
  8. \end{list}

src/2-2-29.tex

  1. \newenvironment{myitemize}{%
  2. \begin{list}{\textbullet}{%
  3. \setlength{\topsep}{0pt} \setlength{\partopsep}{0pt}
  4. \setlength{\parsep}{0pt} \setlength{\itemsep}{0pt}}}
  5. {\end{list}}

src/2-2-30.tex

  1. \newenvironment{mycenter}
  2. {\begin{trivlist}
  3. \centering
  4. \item[]}
  5. {\end{trivlist}}

src/2-2-31.tex

  1. % \usepackage{enumitem}
  2. \begin{enumerate}[itemsep=0pt,parsep=0pt,
  3. label=(\arabic*)]
  4. \item 中文
  5. \item English
  6. \item Français
  7. \end{enumerate}

src/2-2-32.tex

  1. \usepackage{enumitem}
  2. % 仿照 enumerate 环境定义可二级嵌套的 mylist
  3. \newlist{mylist}{enumerate}{2}
  4. % 分别定义每级的格式
  5. \setlist[mylist,1]{itemsep=0pt,parsep=0pt,label=(\arabic*)}
  6. \setlist[mylist,2]{itemsep=0pt,parsep=0pt,label=(\alph*)}

src/2-2-33.tex

  1. % \usepackage{enumitem}
  2. \AddEnumerateCounter{\chinese}{\chinese}{}
  3. \begin{enumerate}[label={\chinese*、},labelsep=0pt]
  4. \item 内容清晰
  5. \item 格式美观
  6. \end{enumerate}

src/2-2-34.tex

  1. \newtheorem{thm}{定理} % 一般在导言区
  2. \begin{thm}
  3. 直角三角形斜边的平方等于两腰的平方和。
  4. \end{thm}

src/2-2-35.tex

  1. \begin{thm}[勾股定理]
  2. 直角三角形斜边的平方等于两腰的平方和。
  3. \end{thm}

src/2-2-36.tex

  1. \newtheorem{lemma}{引理}[chapter]% 按章
  2. \begin{lemma} 偏序集可良序化。 \end{lemma}
  3. \begin{lemma} 实数集不可数。 \end{lemma}

src/2-2-37.tex

  1. \newtheorem{prop}[thm]{命题}
  2. \begin{prop}
  3. 直角三角形的斜边大于直角边。
  4. \end{prop}

src/2-2-38.tex

  1. % 导言区
  2. \usepackage{theorem}
  3. \theoremstyle{changebreak}
  4. \theoremheaderfont{\sffamily\bfseries}
  5. \theorembodyfont{\normalfont}
  6. \newtheorem{definition}{定义}[chapter]

src/2-2-39.tex

  1. \begin{definition}
  2. 有一个角是直角的三角形是\emph{直角三角形}。
  3. \end{definition}

src/2-2-40.tex

  1. % 导言区
  2. \usepackage[thmmarks]{ntheorem}
  3. { % 利用分组,格式设置只作用于证明环境
  4. \theoremstyle{nonumberplain}
  5. \theoremheaderfont{\bfseries}
  6. \theorembodyfont{\normalfont}
  7. \theoremsymbol{\mbox{$\Box$}} % 放进盒子,或用 \ensuremath
  8. \newtheorem{proof}{证明}
  9. }

src/2-2-41.tex

  1. \begin{proof}
  2. 证明是显然的。
  3. \end{proof}

src/2-2-42.tex

  1. \usepackage{amsthm}
  2. \renewcommand\proofname{证明}
  3. \renewcommand\qedsymbol{\ensuremath{\Box}}

src/2-2-43.tex

  1. % \usepackage{amsthm}
  2. \begin{proof}
  3. 最后我们有
  4. \[
  5. f(x) = 0. \qedhere
  6. \]
  7. \end{proof}

src/2-2-44.tex

  1. \verb"\LaTeX \& \TeX" \qquad
  2. \verb!\/}{#$%&~!

src/2-2-45.tex

  1. 显示空格 \verb*!1 2 3 4!

src/2-2-46.tex

  1. \begin{verbatim}
  2. #!usr/bin/env perl
  3. $name = "guy";
  4. print "Hello, $name!\n";
  5. \end{verbatim}

src/2-2-47.tex

  1. \begin{verbatim*}
  2. #include <stdio.h>
  3. main() {
  4. printf("Hello, world.\n");
  5. }
  6. \end{verbatim*}

src/2-2-48.tex

  1. % \usepackage{fancyvrb}
  2. \SaveVerb{myverb}|#$%^&|
  3. \fbox{套中 \UseVerb{myverb}}

src/2-2-49.tex

  1. % \usepackage{cprotect}
  2. \cprotect\fbox{套中 \verb|#$%^&|}

src/2-2-50.tex

  1. verbatim |\LaTeX|

src/2-2-51.tex

  1. \begin{lstlisting}[language=C]
  2. /* hello.c */
  3. #include <stdio.h>
  4. main() {
  5. printf("Hello.\n");
  6. }
  7. \end{lstlisting}

src/2-2-52.tex

  1. \lstset{ % 整体设置
  2. basicstyle=\sffamily,
  3. keywordstyle=\bfseries,
  4. commentstyle=\rmfamily\itshape,
  5. stringstyle=\ttfamily}
  6. \begin{lstlisting}[language=C]
  7. /* hello.c */
  8. #include <stdio.h>
  9. main() {
  10. printf("Hello.\n");
  11. }
  12. \end{lstlisting}

src/2-2-53.tex

  1. \lstset{flexiblecolumns}% column=flexible
  2. \begin{lstlisting}[language=C]
  3. /* hello.c */
  4. #include <stdio.h>
  5. main() {
  6. printf("Hello.\n");
  7. }
  8. \end{lstlisting}

src/2-2-54.tex

  1. \lstset{columns=flexible,
  2. numbers=left,numberstyle=\footnotesize}
  3. \begin{lstlisting}[language=C]
  4. /* hello.c */
  5. #include <stdio.h>
  6. main() {
  7. printf("Hello.\n");
  8. }
  9. \end{lstlisting}

src/2-2-55.tex

  1. \lstset{language=C,flexiblecolumns}
  2. 语句 \lstinline!typedef char byte!

src/2-2-56.tex

  1. \lstset{language=C,flexiblecolumns,
  2. escapechar=`} % 设置 ` 为逃逸字符
  3. \begin{lstlisting}
  4. int n; // `一个整数`
  5. \end{lstlisting}

src/2-2-57.tex

  1. \lstset{language=C,flexiblecolumns,
  2. escapechar=`}
  3. \begin{lstlisting}
  4. double x = 1/sin(x); // `$\frac1{\sin x}$`
  5. \end{lstlisting}

src/2-2-58.tex

  1. \begin{tabbing}
  2. 格式\hspace{3em} \= 作者 \\
  3. Plain \TeX \> 高德纳 \\
  4. \LaTeX \> Leslie Lamport
  5. \end{tabbing}

src/2-2-59.tex

  1. \begin{tabbing}
  2. 格式\hspace{3em} \= 作者 \kill
  3. Plain \TeX \> 高德纳 \\
  4. \LaTeX \> Leslie Lamport
  5. \end{tabbing}

src/2-2-60.tex

  1. \newcommand\kw{\textbf} % 表示描述算法的关键字
  2. \begin{tabbing}
  3. \pushtabs
  4. 算法:在序列 $A$ 中对 $x$ 做二分检索 \\
  5. 输入:$A$, $x$ 及下标上下界 $L$, $H$ \\
  6. \qquad\=\+\kw{integer} $L, H, M, j$ \\
  7. \kw{while} \=\+ $L \leq H$ \kw{do} \` $L$ $H$ 是左右分点 \\
  8. $M \gets \lfloor(L+H)/2\rfloor$ \` $M$ 是中间分点 \\
  9. \kw{case} \=\+\\
  10. condition \= foo \+\kill
  11. $x > A[M]$:\' $H \gets M-1$ \\
  12. $x < A[M]$:\' $H \gets M+1$ \\
  13. \kw{else}:\' \= $j \gets M$ \` 找到 $x$,返回位置\\
  14. \> \kw{return}$(j)$ \\
  15. \<\< \kw{endcase} \-\-\-\\
  16. $j \gets 0$ \\
  17. \kw{return}$(j)$ \-\\
  18. \poptabs
  19. 算法示例:\\
  20. $A = \{2, 3, 5, 7, 11\}$, $x=3$\\
  21. \qquad\=\+ $M$\qquad \= $L$\qquad \= $H$\qquad \= \\
  22. \> 1 \> 5 \> 初始值,进入循环 \\
  23. 3 \> 1 \> 2 \> $H$ 变化 \\
  24. 2 \> \> \> 找到 $x$,输出位置 2
  25. \end{tabbing}

src/2-2-61.tex

  1. 例如\footnote{这是一个脚注。}。

src/2-2-62.tex

  1. \begin{minipage}{8em}
  2. 这是小页环境\footnote{脚注。}中的脚注。
  3. \end{minipage}

src/2-2-63.tex

  1. \renewcommand\thefootnote{\fnsymbol{footnote}}

src/2-2-64.tex

  1. \usepackage{pifont}
  2. \renewcommand\thefootnote{\ding{\numexpr171+\value{footnote}}}

src/2-2-65.tex

  1. \begin{tabular}{r|r}
  2. 自变量 & 因变量\footnotemark \\ \hline
  3. $x$ & $y$
  4. \end{tabular}
  5. \footnotetext{$y=x^2$。}

src/2-2-66.tex

  1. \section[节标题]{节标题\protect\footnote{标题中的脚注}}

src/2-2-67.tex

  1. \usepackage[perpage]{footmisc}

src/2-2-68.tex

  1. 有边注的文字\marginpar[\hfill $\rightarrow$]{$\leftarrow$ 右}

src/2-2-69.tex

  1. 前言\parbox{2em}{不搭后语}。

src/2-2-70.tex

  1. 前言\parbox[t]{2em}{不搭后语}。
  2. 后语\parbox[b]{2em}{不搭前言}。

src/2-2-71.tex

  1. \begin{minipage}[c][2.5cm][t]{2em} 两个 \end{minipage}\quad
  2. \begin{minipage}[c][2.5cm][c]{3em} 黄鹂鸣翠柳, \end{minipage}\quad
  3. \begin{minipage}[c][2.5cm][b]{3em} 一行白鹭上青天。 \end{minipage}\quad
  4. \begin{minipage}[c][2.5cm][s]{4em}
  5. \setlength{\parskip}{0pt plus 1pt}% 恢复正文默认段间距
  6. 窗含西岭千秋雪,\par
  7. 门泊东吴万里船。
  8. \end{minipage}

src/2-2-72.tex

  1. \newsavebox{\verbatimbox} % 通常在导言区定义
  2. \begin{lrbox}{\verbatimbox}
  3. \begin{minipage}{10em}
  4. \begin{verbatim}
  5. #!/bin/sh
  6. cat ~/${file}
  7. \end{verbatim}
  8. \end{minipage}
  9. \end{lrbox}
  10. \fbox{\usebox{\verbatimbox}}\quad\fbox{\usebox{\verbatimbox}}

src/2-2-73.tex

  1. \rule{1pt}{1em}Middle\rule{1pt}{1em} \\
  2. Left\rule[0.5ex]{2cm}{0.6pt}Right \\
  3. \rule[-0.1em]{1em}{1em} 也可以用作证毕符号

src/2-2-74.tex

  1. \fbox{---}\qquad
  2. \fbox{\strut---}\qquad
  3. \fbox{\rule{0pt}{2em}---}

src/2-2-75.tex

  1. % 这与实际 \TeX 的定义基本等价
  2. \mbox{T\hspace{-0.1667em}%
  3. \raisebox{-0.5ex}{E}%
  4. \hspace{-0.125em}X}

src/2-2-76.tex

  1. \fbox{\begin{varwidth}{10cm}
  2. 自然\\宽度
  3. \end{varwidth}}

src/2-3-01.tex

  1. \title{杂谈勾股定理\\——勾股定理的历史与现状}
  2. \author{张三\\九章学堂}
  3. \date{庚寅盛夏}

src/2-3-02.tex

  1. \author{张三\\九章学堂 \and 李四\\天元研究所}

src/2-3-03.tex

  1. \title{杂谈勾股定理\thanks{本文由九章基金会赞助。}}
  2. \author{张三\thanks{九章学堂讲师。}\\九章学堂}

src/2-3-04.tex

  1. % 手工排版的标题页
  2. \begin{titlepage}
  3. \vspace*{\fill}
  4. \begin{center}
  5. \normalfont
  6. {\Huge\bfseries 杂谈勾股定理}
  7. \bigskip
  8. {\Large\itshape 张三}
  9. \medskip
  10. \today
  11. \end{center}
  12. \vspace{\stretch{3}}
  13. \end{titlepage}

src/2-3-05.tex

  1. \documentclass{book}
  2. \title{Languages}\author{someone}
  3. \begin{document}
  4. \maketitle
  5. \tableofcontents
  6. % 这里用缩进显示层次
  7. \part{Introduction} % Part I
  8. \chapter{Background} % Chapter 1
  9. \part{Classification} % Part II
  10. \chapter{Natural Language} % Chapter 2
  11. \chapter{Computer Languages} % Chapter 3
  12. \section{Machine Languages} % 3.1
  13. \section{High Level Languages} % 3.2
  14. \subsection{Compiled Language} % 3.2.1
  15. \subsection{Interpretative Language} % 3.2.2
  16. \subsubsection{Lisp}
  17. \paragraph{Common Lisp}
  18. \paragraph{Scheme}
  19. \subsubsection{Perl}
  20. \end{document}

src/2-3-06.tex

  1. % languages.tex
  2. % 整个文档的主文件
  3. \documentclass{ctexbook}
  4. \usepackage{syntonly}
  5. \syntaxonly % 只检查语法,不输出 DVI/PDF 文件
  6. \begin{document}
  7. ……
  8. \end{document}

src/2-3-07.tex

  1. \usepackage[sf,bf,it,centering]{titlesec}

src/2-3-08.tex

  1. \titlelabel{\S~\thetitle\quad}

src/2-3-09.tex

  1. \titleformat*{\section}{\Large\itshape\centering}

src/2-4-01.tex

  1. \documentclass[a4paper,titlepage]{article}

src/2-4-02.tex

  1. \documentclass{moderncv}
  2. \usepackage{ctex}
  3. \zihao{-4}
  4. \begin{document}
  5. …………
  6. \end{document}

src/2-4-03.tex

  1. \XeTeXinputencoding "GBK"
  2. \documentclass{ctexart}
  3. \begin{document}
  4. GBK 编码的中文文档。
  5. \end{document}

src/2-4-04.tex

  1. \usepackage[a4paper,left=3cm,right=3cm]{geometry}

src/2-4-05.tex

  1. \usepackage{geometry}
  2. \geometry{a4paper,left=3cm,right=3cm}

src/2-4-06.tex

  1. \pagenumbering{roman}

src/2-4-07.tex

  1. \documentclass{article}
  2. \pagestyle{headings}

src/2-4-08.tex

  1. \begin{figure}[p]
  2. \thispagestyle{plain}
  3. …………
  4. \end{figure}

src/2-4-09.tex

  1. \documentclass{ctexart}
  2. \pagestyle{headings}
  3. \markright{张三}

src/2-4-10.tex

  1. \documentclass[twoside]{ctexrep}
  2. \usepackage{fancyhdr}
  3. \pagestyle{fancy} % 使用 fancy 风格
  4. \fancyhf{} % 清除所有页眉页脚
  5. \cfoot{\thepage} % 页脚居中页码
  6. \fancyhead[CO]{张三} % 奇数页居中页眉作者名
  7. \fancyhead[CE]{论语言} % 偶数页居中页眉文章题目
  8. \fancyfoot[RO,LE]{$\heartsuit$}
  9. % 奇数页脚右,偶数页脚左(即外侧)装饰符号

src/2-4-11.tex

  1. \documentclass[twoside,fancyhdr]{ctexrep}
  2. \fancyhf{}
  3. % ……

src/2-4-12.tex

  1. \renewcommand\headrulewidth{0.6pt} % 默认为 0.4pt
  2. \renewcommand\footrulewidth{0.6pt} % 默认为 0pt

src/2-4-13.tex

  1. \fancypagestyle{plain}{%
  2. \fancyhf{}
  3. \cfoot{--\textit{\thepage}--} % 改变页码形状
  4. \renewcommand\headrulewidth{0pt} % 无页眉线
  5. \renewcommand\footrulewidth{0pt} % 无页脚线
  6. }

src/2-4-14.tex

  1. \newcommand\PRC{People's Republic of \emph{China}}

src/2-4-15.tex

  1. \newcommand\loves[2]{#1喜欢#2}
  2. \newcommand\hatedby[2]{#2不受#1喜欢}

src/2-4-16.tex

  1. \newcommand\loves[3][喜欢]{{#2#1#3}}

src/2-4-17.tex

  1. \newcommand\Emph[1]{\emph{#1}}
  2. \newcommand\setEmph[1]{%
  3. \renewcommand\Emph[1]{%
  4. #1{##1}}}

src/2-4-18.tex

  1. \newenvironment{myabstract}[1][摘要]%
  2. {\small
  3. \begin{center}\bfseries #1\end{center}%
  4. \begin{quotation}}%
  5. {\end{quotation}}

src/2-4-19.tex

  1. \newenvironment{Quotation}[1]%
  2. {\newcommand\quotesource{#1}%
  3. \begin{quotation}}%
  4. {\par\hfill ——《\textit{\quotesource}》%
  5. \end{quotation}}
  6. \begin{Quotation}{易·乾}
  7. 初九,潜龙勿用。
  8. \end{Quotation}

src/3-1-01.tex

  1. \documentclass{article}
  2. \begin{document}
  3. \tableofcontents
  4. \section{Foo}
  5. \subsection{blah}
  6. \section{Bar}
  7. \end{document}

src/3-1-02.tex

  1. \setcounter{secnumdepth}{4} % 增加编号深度
  2. \setcounter{tocdepth}{4} % 增加目录深度

src/3-1-03.tex

  1. \addcontentsline{toc}{section}{Title}
  2. \maketitle
  3. \tableofcontents

src/3-1-04.tex

  1. \usepackage{tocbibind}

src/3-1-05.tex

  1. \addtocontents{toc}{\newpage}
  2. \part{Foo}

src/3-1-06.tex

  1. % \usepackage{tocloft}
  2. \renewcommand\cfttoctitlefont{\hfill\Large\sffamily\bfseries}
  3. \renewcommand\cftaftertoctitle{\hfill}
  4. \setlength\cftbeforetoctitleskip{2ex}
  5. \setlength\cftaftertoctitleskip{2ex}

src/3-1-07.tex

  1. % \usepackage{tocloft}
  2. \renewcommand\cftdot{…}
  3. \renewcommand{\cftdotsep}{0}

src/3-1-08.tex

  1. \settowidth{\cftchapternumwidth}{第几十几章} % 最宽的可能编号
  2. \renewcommand\cftchapteraftersnumb{\hspace{0.5em}} % 额外间距

src/3-1-09.tex

  1. \documentclass{ctexbook} % ctexrep, ctexart
  2. \usepackage{tocloft}
  3. \makeatletter
  4. \renewcommand{\numberline}[1]{%
  5. \settowidth\@tempdimb{#1\hspace{0.5em}}%
  6. \ifdim\@tempdima<\@tempdimb%
  7. \@tempdima=\@tempdimb%
  8. \fi%
  9. \hb@xt@\@tempdima{\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}
  10. \makeatother

src/3-2-01.tex

  1. \section{Lanuages}
  2. \label{sec:lang}

src/3-2-02.tex

  1. \begin{align}
  2. c^2 &= a^2 + b^2
  3. \label{eq:gougu-formula} \\
  4. 5^2 &= 3^2 + 4^2
  5. \label{eq:gougu-example}
  6. \end{align}

src/3-2-03.tex

  1. 勾股定理公式 (\ref{eq:gougu-formula})
  2. 出现在 \pageref{eq:gougu-formula}~页。

src/3-2-04.tex

  1. \newcommand\thmref[1]{定理~\ref{#1}}

src/3-2-05.tex

  1. See \autoref{fig:xref}.

src/3-2-06.tex

  1. \renewcommand\figureautorefname{图}
  2. 参见\autoref{fig:xref}。

src/3-2-07.tex

  1. % 导言区 \usepackage{nameref}
  2. 见“\nameref{fig:xref}”。

src/3-2-08.tex

  1. page \thepage\ of \pageref{LastPage}

src/3-2-09.tex

  1. % languages.tex 导言区
  2. \usepackage{xr}
  3. \externaldocument[ch:]{chinese}

src/3-2-10.tex

  1. \documentclass[hyperref,UTF8]{ctexart}

src/3-2-11.tex

  1. \documentclass[hyperref,UTF8]{ctexbook}
  2. \usepackage{geometry}
  3. \geometry{screen}
  4. \hypersetup{
  5. colorlinks=true,
  6. bookmarks=true,
  7. bookmarksopen=false,
  8. pdfpagemode=FullScreen,
  9. pdfstartview=Fit,
  10. pdftitle={初等几何教程(电子版)},
  11. pdfauthor={张三}
  12. }

src/3-2-12.tex

  1. \url{http://bbs.ctex.org/forum.php?mod=viewthread&tid=48244#pid337079}

src/3-2-13.tex

  1. \href{http://bbs.ctex.org/}{CTeX 论坛}

src/3-2-14.tex

  1. \hyperref[eq:gougu-formula]{点击查看勾股定理公式}

src/3-2-15.tex

  1. \phantomsection
  2. \addcontentsline{toc}{section}{习题}
  3. \section*{本章习题}

src/3-2-16.tex

  1. \pdfbookmark[2]{勾股定理证明}{gouguproof}
  2. \begin{proof} …… \end{proof}

src/3-2-17.tex

  1. \section{\texorpdfstring{$\frac{1}{\pi}$}{1/π} 的计算}

src/3-3-01.bib

  1. % tex.bib 中的一条
  2. @BOOK{mittelbach2004,
  3. title = {The {{\LaTeX}} Companion},
  4. publisher = {Addison-Wesley},
  5. year = {2004},
  6. author = {Frank Mittelbach and Michel Goossens},
  7. series = {Tools and Techniques for Computer Typesetting},
  8. address = {Boston},
  9. edition = {Second}
  10. }

src/3-3-02.bib

  1. @String{ j-CJ = "The Computer Journal" }
  2. @Article{Knuth:CJ-2-27-97,
  3. author = "Donald E. Knuth",
  4. title = "Literate Programming",
  5. journal = j-CJ,
  6. year = "1984",
  7. number = "2",
  8. volume = "27",
  9. pages = "97--111",
  10. month = may,
  11. }

src/3-3-03.tex

  1. % 导言区
  2. % \usepackage{natbib}
  3. % \bibliographystyle{plainnat}
  4. % 正文
  5. \citet{lamport1994} 中提到了利用 \BibTeX{} 自动处理文献的方式,
  6. 在另一本书 \citep{mittelbach2004} 中则有进一步的格式与工具的说明。

src/3-3-04.tex

  1. \citet{Abrahams1990} \\
  2. \citet*{Abrahams1990}

src/3-3-05.tex

  1. \citep[\S~4.3~节]{lamport1994} \\
  2. \cite[又见][第~13~章]{mittelbach2004}

src/3-3-06.tex

  1. \citeauthor{Abrahams1990} \\
  2. \citefullauthor{Abrahams1990} \\ % 或加 *
  3. \citeyear{Abrahams1990} \\
  4. \citeyearpar{Abrahams1990} \\
  5. \citenum{Abrahams1990}

src/3-3-07.tex

  1. \citealt{Patashnik1988:btxdoc}\\
  2. \citealp{Patashnik1988:btxdoc}\\% 有逗号
  3. \citetext{同前} \\
  4. \citetext{参见 \citealp{Shell2007},
  5. 以及 \citealp{Markey2009}}

src/3-3-08.tex

  1. \usepackage[numbers,square]{natbib}

src/3-3-09.tex

  1. \CTEXoptions[bibname={本书引用的文献}]
  2. % \renewcommand\bibname{本书引用的文献}

src/3-3-10.tex

  1. \renewcommand\bibpreamble{下面给出本文参考的几篇文章。}

src/3-3-11.tex

  1. \renewcommand\bibfont{\small}

src/3-3-12.tex

  1. \renewcommand\citenumfont{\itshape}

src/3-3-13.tex

  1. \renewcommand\bibnumfmt[1]{\textbf{#1.}}

src/3-3-14.tex

  1. \setlength{\bibsep}{0pt}

src/3-3-15.tex

  1. % main.tex
  2. % 主文档
  3. \documentclass{book}
  4. \usepackage{chapterbib}
  5. \usepackage[sectionbib]{natbib}
  6. \begin{document}
  7. % ...
  8. \include{chap-intro}
  9. \include{chap-research}
  10. \include{chap-conclusion}
  11. \end{document}
  12. % chap-intro.tex
  13. % 其中一章
  14. \chapter{Introduction}
  15. % ...
  16. \bibliographystyle{plainnat}
  17. \bibliography{foo}
  18. % chap-research.tex
  19. % ...

src/3-3-16.tex

  1. \usepackage[numbers,sort&compress]{natbib}

src/3-3-17.tex

  1. % 导言 \usepackage[merge]{natbib}
  2. \citep*{knuthtex1986, *lamport1994, *mittelbach2004}

src/3-3-20.tex

  1. \documentclass[openbib]{article}
  2. \bibliographystyle{plain}
  3. \begin{document}
  4. \TeX{} and \LaTeX{} see \cite{knuthtex1986}, \cite{Lamport1994}.
  5. \nocite{mittelbach2004}
  6. \bibliography{tex}
  7. \end{document}

src/3-4-01.tex

  1. % foo.tex
  2. \documentclass{ctexart}
  3. \usepackage{makeidx}
  4. \makeindex
  5. % ...
  6. \begin{document}
  7. \section{勾股定理}
  8. % 1
  9. 勾股定理在西方称为毕达哥拉斯定理(Pythagoras' theorem)。
  10. \index{Pythagoras}
  11. % ...
  12. % 第 2 页
  13. 在中国常称勾股定理为商高定理。\index{商高}
  14. \printindex
  15. \end{document}

src/3-4-02.tex

  1. \renewcommand\seename{参见}
  2. \renewcommand\alsoname{又见}

src/3-4-03.tex

  1. \newcommand*\numsee[2]{#2\emph{参见} #1)}

src/3-4-04.tex

  1. \documentclass[UTF8]{ctexart}
  2. \usepackage{imakeidx}
  3. \makeindex[title={名词索引}]
  4. \makeindex[name=persons,title={人名索引}]
  5. \begin{document}
  6. ... \index{名词}
  7. ... \index[persons]{人名}
  8. ...
  9. \printindex % 输出名词索引
  10. \printindex[persons] % 输出人名索引
  11. \end{document}

src/3-4-05.tex

  1. \newcommand*\keyword[1]{\texttt{#1}\index{#1@\texttt{#1}}}

src/3-4-06.tex

  1. \documentclass[UTF8]{ctexbook}
  2. \usepackage{imakeidx}
  3. \makeindex[%
  4. name=persons, % 索引文件名(默认为 \jobname,即主文件名)
  5. title={人名索引}, % 索引表标题(默认为 \indexname
  6. intoc=true, % 加入目录(默认为 false,不加入目录)
  7. columns=2, % 分栏(默认为 1
  8. columnsep=1cm, % 栏间距(默认为 35pt
  9. columnseprule=true, % 分栏线(默认为 false
  10. program=makeindex, % 调用的索引程序(或用 xindytexindy
  11. options={-s mkind.ist}, % 索引程序的选项(默认为空)
  12. noautomatic=false % 不自动调用索引程序(默认为 false
  13. ]
  14. \indexsetup{%
  15. level=\section*, % 标题级别(默认 \chapter* 即不编号的章)
  16. toclevel=section, % 目录级别(不带反斜线,又如 chapter
  17. firstpagestyle=empty, % 索引第一页的页面风格(默认为 plain
  18. headers={人名}{人名}, % 索引的奇偶页眉
  19. othercode={ % 将在索引条目之前生效的任意代码
  20. \renewcommand{\indexspace}{\smallskip}}
  21. }
  22. \begin{document}
  23. 张三\index[persons]{张三} \newpage
  24. 李四\index[persons]{李四} \newpage
  25. 王五\index[persons]{王五}
  26. \indexprologue{这里列出本文涉及的所有人名。}
  27. \printindex[persons]
  28. \end{document}

src/3-4-08.tex

  1. \documentclass[UTF8]{ctexart}
  2. \usepackage{glossaries}
  3. \makeglossaries
  4. \begin{document}
  5. \newglossaryentry{gloss}{
  6. name=glossary,
  7. description={A vocabulary with annotations for a particular subject},
  8. plural=glossaries}
  9. \Glspl{gloss} are important for technical documents.
  10. \newglossaryentry{sec}{
  11. name=分节,
  12. description={把文章分成章节}}
  13. \gls{sec}对于长文档非常重要。
  14. \printglossaries
  15. \end{document}

src/4-1-01.tex

  1. 交换律是 $a+b=b+a$,如 $1+2=2+1=3$

src/4-1-02.tex

  1. % 用于 ntheorem 宏包
  2. \renewcommand\qedsymbol{\ensuremath{\Box}}
  3. 证毕符号:\qedsymbol $\qedsymbol$

src/4-1-03.tex

  1. 交换律是
  2. \[ a+b=b+a, \]
  3. \[
  4. 1+2=2+1=3.
  5. \]

src/4-1-04.tex

  1. \begin{equation}
  2. a+b=b+a \label{eq:commutative}
  3. \end{equation}

src/4-1-05.tex

  1. $\text{被减数} - \text{减数} = \text{差}$

src/4-1-06.tex

  1. 已知的变量有 $a$, $b$, $c$, $d$, $S$, $R$ $T$

src/4-2-01.tex

  1. $A_{ij} = 2^{i+j}$

src/4-2-02.tex

  1. $A_i^k = B^k_i$ \qquad
  2. $K_{n_i} = K_{2^i} = 2^{n_i}
  3. = 2^{2^i}$ \qquad
  4. $3^{3^{3^{\cdot^{\cdot^{\cdot^3}}}}}$

src/4-2-03.tex

  1. $a = a'$, $b_0' = b_0''$,
  2. ${c'}^2 = (c')^2$

src/4-2-04.tex

  1. $A = 90^\circ$

src/4-2-05.tex

  1. \newcommand\degree{^\circ}

src/4-2-06.tex

  1. \[
  2. \max_n f(n) = \sum_{i=0}^n A_i
  3. \]

src/4-2-07.tex

  1. % 导言区 \DeclareMathOperator\dif{d\!}
  2. \[ \int_0^1 f(t) \dif t
  3. = \iint_D g(x,y) \dif x \dif y \]

src/4-2-08.tex

  1. \[
  2. \iiint\limits_D \mathrm{d}f
  3. = \max\nolimits_D g
  4. \]

src/4-2-09.tex

  1. % \usepackage{mathtools}
  2. $\prescript{n}{m}{H}_i^j < L$

src/4-2-10.tex

  1. \[ \sideset{_a^b}{_c^d} \sum_{i=0}^n A_i
  2. = \sideset{}{'} \prod_k f_i \]

src/4-2-11.tex

  1. $\overset{*}{X}$ \qquad
  2. $\underset{*}{X}$ \qquad
  3. $\overset{*}{\underset{\dag}{X}}$

src/4-2-12.tex

  1. $A_m{}^n$ $A_m^{\phantom{m}n}$

src/4-2-13.tex

  1. % 导言区 \usepackage{tensor}
  2. $M\indices{^a_b^{cd}_e}$ \qquad
  3. $\tensor[^a_b^c_d]{M}{^a_b^c_d}$

src/4-2-14.tex

  1. % 导言区 \usepackage{mhchem}
  2. 醋中主要是 \ce{H2O},含有 \ce{CH3COO-}。
  3. \ce{^{227}_{90}Th} 元素具有强放射性。

src/4-2-15.tex

  1. \begin{equation}
  2. \ce{2H2 + O2 ->[\text{燃烧}] 2H2O}
  3. \end{equation}

src/4-2-16.tex

  1. $\overline{a+b} =
  2. \overline a + \overline b$ \\
  3. $\underline a = (a_0, a_1, a_2, \dots)$

src/4-2-17.tex

  1. $ \overline{\underline{\underline a}
  2. + \overline{b}^2} - c^{\underline n} $

src/4-2-18.tex

  1. $\overleftarrow{a+b}$\\
  2. $\overrightarrow{a+b}$\\
  3. $\overleftrightarrow{a+b}$\\
  4. $\underleftarrow{a-b}$\\
  5. $\underrightarrow{a-b}$\\
  6. $\underleftrightarrow{a-b}$

src/4-2-19.tex

  1. $\vec x = \overrightarrow{AB}$

src/4-2-20.tex

  1. $\overbrace{a+b+c} = \underbrace{1+2+3}$

src/4-2-21.tex

  1. \[ ( \overbrace{a_0,a_1,\dots,a_n}
  2. ^{\text{共 $n+1$ 项}} ) =
  3. ( \underbrace{0,0,\dots,0}_{n} , 1 ) \]

src/4-2-22.tex

  1. \[ \underbracket{\overbracket{1+2}+3}_3 \]

src/4-2-23.tex

  1. \[
  2. \frac 12 + \frac 1a = \frac{2+a}{2a}
  3. \]

src/4-2-24.tex

  1. \[ \frac{1}{\frac 12 (a+b)}
  2. = \frac{2}{a+b} \]

src/4-2-25.tex

  1. \[
  2. \tfrac 12 f(x) =
  3. \frac{1}{\dfrac 1a + \dfrac 1b + c}
  4. \]

src/4-2-26.tex

  1. \[ \cfrac{1}{1+\cfrac{2}{%
  2. 1+\cfrac{3}{1+x}}} =
  3. \cfrac[r]{1}{1+\cfrac{2}{%
  4. 1+\cfrac[l]{3}{1+x}}} \]

src/4-2-27.tex

  1. % \usepackage{xfrac}
  2. 区别 $\sfrac 1a + b$ $1/(a+b)$

src/4-2-28.tex

  1. \[
  2. (a+b)^2 = \binom 20 a^2
  3. + \binom 21 ab + \binom 22 b^2
  4. \]

src/4-2-29.tex

  1. \newcommand\stiring[2]{\genfrac{[}{]}{0pt}{}{#1}{#2}}
  2. \newcommand\dstiring[2]{\genfrac{[}{]}{0pt}{0}{#1}{#2}}
  3. \newcommand\tstiring[2]{\genfrac{[}{]}{0pt}{1}{#1}{#2}}
  4. \[ \stiring{n}{1} = (n-1)!, \qquad n > 0. \]

src/4-2-30.tex

  1. $\sqrt 4 = \sqrt[3]{8} = 2$

src/4-2-31.tex

  1. \[
  2. \sqrt[n]{\frac{x^2 + \sqrt 2}{x+y}}
  3. \]

src/4-2-32.tex

  1. \[
  2. (x^p+y^q)^{\frac{1}{1/p+1/q}}
  3. \]

src/4-2-33.tex

  1. \[
  2. \sqrt[\uproot{16}\leftroot{-2}n]
  3. {\frac{x^2 + \sqrt 2}{x+y}}
  4. \]

src/4-2-34.tex

  1. $\sqrt{\frac 12} <
  2. \sqrt{\vphantom{\frac12}2}$

src/4-2-35.tex

  1. $\sqrt b \sqrt y$ \qquad
  2. $\sqrt{\mathstrut b} \sqrt{\mathstrut y}$

src/4-2-36.tex

  1. \[ A = \begin{pmatrix}
  2. a_{11} & a_{12} & a_{13} \\
  3. 0 & a_{22} & a_{23} \\
  4. 0 & 0 & a_{33}
  5. \end{pmatrix} \]

src/4-2-37.tex

  1. \[ A = \begin{bmatrix}
  2. a_{11} & \dots & a_{1n} \\
  3. & \ddots & \vdots \\
  4. 0 & & a_{nn}
  5. \end{bmatrix}_{n\times n} \]

src/4-2-38.tex

  1. \[ \begin{pmatrix}
  2. 1 & \frac 12 & \dots & \frac 1n \\
  3. \hdotsfor{4} \\
  4. m & \frac m2 & \dots & \frac mn
  5. \end{pmatrix} \]

src/4-2-39.tex

  1. \[ \begin{pmatrix}
  2. \begin{matrix} 1&0\\0&1 \end{matrix}
  3. & \text{\Large 0} \\
  4. \text{\Large 0} &
  5. \begin{matrix} 1&0\\0&-1 \end{matrix}
  6. \end{pmatrix} \]

src/4-2-40.tex

  1. 复数 $z = (x,y)$ 也可用矩阵 \begin{math}
  2. \left( \begin{smallmatrix}
  3. x & -y \\ y & x
  4. \end{smallmatrix} \right)
  5. \end{math} 来表示。

src/4-2-41.tex

  1. \[
  2. \sum_{\substack{0<i<n \\ 0<j<i}} A_{ij}
  3. \]

src/4-2-42.tex

  1. \[ \sum_{\begin{subarray}{l}
  2. i<10 \\ j<100 \\ k<1000
  3. \end{subarray}} X(i,j,k) \]

src/4-2-43.tex

  1. \[ \setcounter{MaxMatrixCols}{15}
  2. \begin{Bmatrix}
  3. 0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 0 & 1\\
  4. 1 & 1 & 1 & 1 & 1 & 0 & 1 & 0 & 1 & 1 & 0 & 0 & 0 & 1 & 0
  5. \end{Bmatrix} \]

src/4-2-44.tex

  1. % \usepackage{mathtools}
  2. \[ \begin{pmatrix*}[r]
  3. 10 & -10 \\ -20 & 3
  4. \end{pmatrix*} \]

src/4-2-45.tex

  1. \[ \bordermatrix{
  2. & 1 & 2 & 3 \cr
  3. 1 & A & B & C \cr
  4. 2 & D & E & F \cr} \]

src/4-3-01.tex

  1. \newcommand\mi{\mathrm{i}}
  2. \newcommand\me{\mathrm{e}}

src/4-3-02.tex

  1. % \usepackage{accents}
  2. $\accentset{*}{A}$, $\accentset{@}{X}$,
  3. $\underaccent{\check}{a}$,
  4. $\underaccent{\hat}{b}$,
  5. $\undertilde{abc}$

src/4-3-03.tex

  1. % \usepackage{bm}
  2. % \hm 的效果需要实际字体支持
  3. \textbf{勾股定理 $\bm{a^2+b^2=c^2}$}
  4. \[ \bm u + \bm v = (1,0) + (0,1) \]
  5. \[ \hm\int > \bm\int > \int \]

src/4-3-04.tex

  1. \[
  2. \mathcal{F}(x) = \sum_{k=0}^\infty
  3. \oint_0^1 f_k(x,t) \,\mathrm{d}t
  4. \]

src/4-3-05.tex

  1. \[ \int f(x) \,\mathrm{d} x \]

src/4-3-06.tex

  1. \newcommand\diff{\,\mathrm{d}}
  2. \[ \iiint\limits_{0<x,y,z<1} f(x,y,z)
  3. \diff x \diff y \diff z \]

src/4-3-07.tex

  1. $ \cos 2x = \cos(x+x)
  2. = \cos^2 x - \sin^2 x $

src/4-3-08.tex

  1. \begin{equation}
  2. \varlimsup_{k\to\infty} A_k = \lim_{J\to\infty} \lim_{K\to\infty}
  3. \bigcap_{j=1}^J \bigcup_{k=j}^K A_k
  4. \end{equation}

src/4-3-09.tex

  1. % 导言区 \usepackage{amsmath}
  2. \DeclareMathOperator{\card}{card} % 集合基数
  3. \DeclareMathOperator*{\esssup}{ess\,sup} % 本性上确界

src/4-3-10.tex

  1. \[ \operatorname*{Prob}_{\{1,\ldots,n\}}
  2. (\bar X) =
  3. \operatorname{card}(\varnothing)/n = 0. \]

src/4-3-11.tex

  1. % 导言区 \DeclareMathOperator\dif{d\!}
  2. \[
  3. \int_0^1 \int_0^1 f(x,y) \int_0^1 \frac{\dif z}{g(x,y,z)} \dif x\dif y
  4. \]

src/4-3-12.tex

  1. $G$ $(H,K)$-双陪集为
  2. $H\backslash G/K$
  3. $S\cup T = (S\cap T)\cup (S\setminus T)$

src/4-3-13.tex

  1. \newcommand\defeq{\stackrel{\text{d}}{=}}
  2. $f(x) \defeq ax^2+bx+c$

src/4-3-14.tex

  1. \[ A \xleftarrow{0<x<1} B
  2. \xrightarrow[x\leq 0]{x\geq 1} C \]

src/4-3-15.tex

  1. $x=y \implies x+a=y+a$ \\
  2. $x=y \impliedby x+a=y+a$ \\
  3. $x=y \iff x\le y \And x\ge y$

src/4-3-16.tex

  1. 运算 $\heartsuit$ 的交换律:
  2. \[ a \mathbin{\heartsuit} b =
  3. b \mathbin{\heartsuit} a \]

src/4-3-17.tex

  1. \newcommand\varnotin{%
  2. \mathrel{\overline{\in}}}
  3. $\forall x$, $\forall S$, $x\varnotin S$.

src/4-3-18.tex

  1. \newcommand*\abs[1]{\lvert#1\rvert}
  2. $\abs{x+y} \le \abs{x} + \abs{y}$

src/4-3-19.tex

  1. \[
  2. \partial_x \partial_y \left[
  3. \frac12 \left( x^2+y^2 \right)^2 + xy
  4. \right]
  5. \]

src/4-3-20.tex

  1. \[ \left.
  2. \int_0^x f(t,\lambda) \,\mathrm{d}t
  3. \right|_{x=1}, \qquad
  4. \lambda \in
  5. \left[\frac12,\infty\right). \]

src/4-3-21.tex

  1. \[
  2. \Pr \left( X>\frac12
  3. \middle\vert Y=0 \right)
  4. = \left.
  5. \int_0^1 p(t)\,\mathrm{d}t
  6. \middle/ ( N^2+1 ) \right.
  7. \]

src/4-3-22.tex

  1. \[
  2. \biggl( \sum_{i=1}^n A_i \biggr) \cdot
  3. \biggl( \sum_{i=1}^n B_i \biggr) > 0
  4. \]

src/4-3-23.tex

  1. $ 1 + \Bigl(2 - \bigl(3 \times
  2. (4 \div 5) \bigr) \Bigr) $

src/4-3-24.tex

  1. \[ P = \biggl< \frac12 \biggr>, \qquad
  2. M = \left< \begin{matrix}
  3. a & b \\ c & d \\
  4. \end{matrix}\right> \]

src/4-3-25.tex

  1. $a:b = ac:bc$

src/4-3-26.tex

  1. \[ \Pr(x\colon g(x)>5) = 0.25,
  2. \qquad g\colon x \mapsto x^2 \]

src/4-3-27.tex

  1. \[ (1,\dots,n) \qquad 1+\dots+n
  2. \qquad a=\dots=z \]

src/4-3-28.tex

  1. \[ \prod_{i=1}^n a_i = a_1 \dotsm a_n
  2. \qquad \int_0^1\dotsi\int_0^1 \]

src/4-4-01.tex

  1. \begin{gather}
  2. a+b = b+a \\
  3. ab = ba
  4. \end{gather}

src/4-4-02.tex

  1. \begin{gather*}
  2. 3+5 = 5+3 = 8 \\
  3. 3\times 5 = 5\times 3
  4. \end{gather*}

src/4-4-03.tex

  1. \begin{gather}
  2. 3^2 + 4^2 = 5^2 \notag \\
  3. 5^2 + 12^2 = 13^2 \notag \\
  4. a^2 + b^2 = c^2
  5. \end{gather}

src/4-4-04.tex

  1. \begin{align}
  2. x &= t + \cos t + 1 \\
  3. y &= 2\sin t
  4. \end{align}

src/4-4-05.tex

  1. \begin{align*}
  2. x &= t & x &= \cos t & x &= t \\
  3. y &= 2t & y &= \sin(t+1) & y &= \sin t
  4. \end{align*}

src/4-4-06.tex

  1. % 关系符后对齐,需要使用空的分组
  2. % 代替关系符右侧符号,保证间距
  3. \begin{align*}
  4. & (a+b)(a^2-ab+b^2) \notag \\
  5. ={} & a^3 - a^2b + ab^2 + a^2b
  6. - ab^2 + b^2 \notag \\
  7. ={} & a^3 + b^3 \label{eq:cubesum}
  8. \end{align*}

src/4-4-07.tex

  1. % 缺少关系符,需要使用幻影给关系符
  2. % 占位,并利用 \mathrel 保证间距
  3. \begin{align*}
  4. &\mathrel{\phantom{=}}
  5. (a+b)(a^2-ab+b^2) \notag \\
  6. &= a^3 - a^2b + ab^2 + a^2b
  7. - ab^2 + b^2 \notag \\
  8. &= a^3 + b^3 \label{eq:cubesum}
  9. \end{align*}

src/4-4-08.tex

  1. \begin{flalign}
  2. x &= t & x &= 2 \\
  3. y &= 2t & y &= 4
  4. \end{flalign}

src/4-4-09.tex

  1. \begin{alignat}{2}
  2. x &= \sin t &\quad&\text{水平方向} \\
  3. y &= \cos t &&\text{垂直方向}
  4. \end{alignat}

src/4-4-10.tex

  1. \begin{alignat*}{6}
  2. &1 & &+2 & &+3 & &+4 & &+5 & &=15 \\
  3. &1 & & & &+3 & & & &+5 & &=9 \\
  4. & & &+2 & & & &+4 & & & &=6
  5. \end{alignat*}

src/4-4-11.tex

  1. \begin{align*}
  2. x^2 + 2x &= -1
  3. \intertext{移项得}
  4. x^2 + 2x + 1 &= 0
  5. \end{align*}

src/4-4-12.tex

  1. $G$ 是一个带有运算 $*$ 的集合,则 $G$ \emph{群},当且仅当:
  2. \begin{subequations}\label{eq:group}
  3. \begin{alignat}{2}
  4. \forall a,b,c &\in G, &\qquad (a*b)*c &= a*(b*c);\label{subeq:assoc}\\
  5. \exists e, \forall a &\in G, & e*a &= a; \\
  6. \forall a, \exists b &\in G, & b*a &= e.
  7. \end{alignat}
  8. \end{subequations}
  9. 式~\eqref{eq:group} 的三个条件中,\eqref{subeq:assoc}~又称为结合律。

src/4-4-13.tex

  1. \begin{multline}
  2. a+b+c+d+e \\
  3. +f+g+h+i+j \\
  4. +k+l+m+n+o \\
  5. +p+q+r+s+t
  6. \end{multline}

src/4-4-14.tex

  1. \setlength{\multlinegap}{3em}
  2. \setlength{\multlinetaggap}{3em}
  3. \begin{multline*}
  4. 1+2+3 \\ \shoveleft{+4+5+6} \\
  5. +7+8+9 \\
  6. \shoveright{+10+11+12} \\ +13+14+15
  7. \end{multline*}

src/4-4-15.tex

  1. \begin{equation} \begin{split}
  2. \cos 2x &= \cos^2 x - \sin^2 x \\
  3. &= 2\cos^2 x - 1
  4. \end{split} \end{equation}

src/4-4-16.tex

  1. \begin{equation}\label{eq:trigonometric}
  2. \begin{split}
  3. \frac12 (\sin(x+y) + \sin(x-y))
  4. &= \frac12(\sin x\cos y + \cos x\sin y) \\
  5. &\quad + \frac12(\sin x\cos y - \cos x\sin y) \\
  6. &= \sin x\cos y
  7. \end{split}
  8. \end{equation}

src/4-4-17.tex

  1. % \usepackage{breqn}
  2. \begin{dmath}\label{eq:trigonometric}
  3. \frac12 (\sin(x+y) + \sin(x-y)) = \frac12(\sin x\cos y + \cos x\sin y)
  4. + \frac12(\sin x\cos y - \cos x\sin y) = \sin x\cos y
  5. \end{dmath}

src/4-4-18.tex

  1. \begin{equation}\label{eq:dirichlet}
  2. D(x) = \begin{cases}
  3. 1, & \text{if } x \in \mathbb{Q}; \\
  4. 0, & \text{if } x \in
  5. \mathbb{R}\setminus\mathbb{Q}.
  6. \end{cases}
  7. \end{equation}

src/4-4-19.tex

  1. % \usepackage{mathtools}
  2. \[ \left\lvert x - \frac12 \right\rvert
  3. = \begin{dcases}
  4. x-\frac12, & x \geq \frac12;\\
  5. \frac12-x, & x < \frac12.
  6. \end{dcases} \]

src/4-4-20.tex

  1. % \usepackage{cases}
  2. \begin{numcases}{f(x)=}
  3. 1/q, & if $x = p/q \in \mathbb{Q}$; \\
  4. 0, & else.
  5. \end{numcases}

src/4-4-21.tex

  1. \[ \left. \begin{gathered}
  2. S \subseteq T \\
  3. S \supseteq T
  4. \end{gathered} \right\}
  5. \implies S = T \]

src/4-4-22.tex

  1. % \usepackage{mathtools}
  2. \[ \text{比较曲线}
  3. \left\{ \begin{lgathered}
  4. x = \sin t, y = \cos t \\
  5. x = t + \sin t, y = \cos t
  6. \end{lgathered} \right. \]

src/4-4-23.tex

  1. \begin{equation}\label{eq:trinary}
  2. \begin{aligned} x+y &= -1 \\ x+y+z &= 2 \\ xyz &= -6 \end{aligned}
  3. \implies
  4. \begin{aligned} x+y &= -1 \\ xy &= -2 \\ z &= 3 \end{aligned}
  5. \implies
  6. \begin{alignedat}{3}
  7. x &= 1, &\quad y &= -2, &\quad z &= 3 \\
  8. \text{或\ } x &= -2, & y &= 1, & z &= 3
  9. \end{alignedat}
  10. \end{equation}

src/4-4-24.tex

  1. % \usepackage{mathtools}
  2. \newcommand\Set[2]{%
  3. \left\{#1\ \middle\vert\ #2 \right\}}
  4. \[ \Omega = \Set{x}{\begin{multlined}
  5. x^7+x^6+x^5 \\ +x^4+x^3+x^2 \\ +x+1=0
  6. \end{multlined}} \]

src/4-4-25.tex

  1. \begin{align*}
  2. 2^5 &= (1+1)^5 \\
  3. &= \begin{multlined}[t]
  4. \binom50\cdot 1^5 + \binom51\cdot 1^4 \cdot 1
  5. + \binom52\cdot 1^3 \cdot 1^2 \\
  6. + \binom53\cdot 1^2 \cdot 1^3 + \binom54\cdot 1 \cdot 1^4
  7. + \binom55\cdot 1^5
  8. \end{multlined} \\
  9. &= \binom50 + \binom51 + \binom52 + \binom53 + \binom54 + \binom55
  10. \end{align*}

src/4-5-01.tex

  1. \documentclass[fleqn,leqno]{article}
  2. \usepackage[tbtags]{amsmath}

src/4-5-02.tex

  1. \begin{equation*}
  2. a^2 + b^2 = c^2 \tag{$\star$}
  3. \end{equation*}

src/4-5-03.tex

  1. \begin{equation*}
  2. \sum_{k=1}^n \frac1k
  3. = \ln n + \mathrm{C} \tag*{[Euler]}
  4. \end{equation*}

src/4-5-04.tex

  1. \newtagform{bracket}[\textit]{[}{]}
  2. \usetagform{bracket}
  3. \begin{equation}
  4. \sum_{k=1}^n \frac1k = \ln n + \mathrm{C}
  5. \end{equation}

src/4-5-05.tex

  1. \renewcommand\theequation{%
  2. \thechapter.\roman{equation}}
  3. \begin{equation}\label{eq:euler}
  4. \chi = V + F - E = 2
  5. \end{equation}

src/4-5-06.tex

  1. \newenvironment{mysubeqn}%
  2. {\begin{subequations}
  3. \renewcommand\theequation{\theparentequation-\roman{equation}}}%
  4. {\end{subequations}}
  5. \begin{mysubeqn}
  6. \begin{gather}
  7. \zeta(2) = \frac{\uppi^2}{6} \\
  8. \zeta(s) = \prod_{p\text{ prime}} \frac{1}{1 - p^{-s}}
  9. \end{gather}
  10. \end{mysubeqn}

src/4-5-07.tex

  1. \documentclass{book}
  2. \usepackage{chngcntr}
  3. \counterwithout{equation}{chapter}

src/4-5-08.tex

  1. {\Large\[F(x) \equiv 0\]}

src/4-5-09.tex

  1. \newcommand\D{\displaystyle}
  2. \[ \mathop{\text{\Large$\D\sum_i$}}
  3. \dfrac{\D\int f_i(x)\,\mathrm{d}x}
  4. {\D\oint g_i(x)\,\mathrm{d}x} \]

src/4-5-10.tex

  1. % 单位 pt,中文五号字(10.5 bp
  2. \DeclareMathSizes{10.54}{10.54}{6.32}{4.22}
  3. % 默认标号尺寸是正文 0.6
  4. \renewcommand\defaultscriptratio{0.6}
  5. % 默认小标号尺寸是正文 0.4
  6. \renewcommand\defaultscriptscriptratio{0.4}

src/4-5-11.tex

  1. \fbox{\parbox{17em}{%
  2. $F(x,y,z)\* G(x,y,z)$ 不同于 $F(x,y,z)\* G(x,y,z)$ 吗?}}

src/4-5-12.tex

  1. \[ \left\{
  2. 0, 1, -1, 2, -2, \frac12, -\frac12, \frac13, -\frac13, \dotsc
  3. \right\} \]

src/4-5-13.tex

  1. \renewcommand\*{%
  2. \discretionary{\,\mbox{$\cdot$}}{}{}}
  3. \fbox{\parbox{17em}{%
  4. $F(x,y,z)\* G(x,y,z)$ 不同于 $F(x,y,z)\* G(x,y,z)$}}

src/4-5-14.tex

  1. \begin{align*}
  2. & \int f(x)\,\mathrm{d}x\,\mathrm{d}y \\
  3. & \sqrt2 \, x && \sqrt{\,\log x} \\
  4. & x^2 \! / 2 && |\!{\gets} 5 {\to}\!|
  5. \end{align*}

src/4-5-15.tex

  1. \[
  2. f(x) \equiv 0, \qquad x > 0
  3. \]

src/4-5-16.tex

  1. \newcommand\lowint{%
  2. \mspace{2mu}\underline{\vphantom{\int}\mspace{7mu}}\mspace{-9mu}\int}
  3. \[
  4. \lowint_a^b f(x)\,\mathrm{d}x = \inf_P s(P).
  5. \]

src/4-5-17.tex

  1. \zihao{7}% 5.5bp
  2. \setlength{\abovedisplayskip}%
  3. {2pt plus 1pt minus 3pt}
  4. 当文字非常小时也应该同时减小
  5. 显示公式与文字的间距:
  6. \[ 1+2+3+4+5 = 15 \]

src/4-5-18.tex

  1. \setlength\jot{9pt}% 用来分开分式
  2. \begin{gather}
  3. a = \frac12 \\ b = \frac34
  4. \end{gather}

src/4-5-19.tex

  1. \setlength{\mathsurround}{3pt}
  2. 公式 $a+b$ 与文字比较松散。

src/4-5-20.tex

  1. $\ddot{h} \iff \skew{-2}{\ddot}{h}$

src/4-5-21.tex

  1. \begin{equation*}
  2. \begin{split}
  3. f(x) &= \left(\vphantom{\frac1x}
  4. x+2+3+4\right. \\
  5. & \left.\phantom{=\biggl(x+{}}
  6. 5+6+7+\frac1x \right)^2 \\
  7. &= g(x)
  8. \end{split}
  9. \end{equation*}

src/4-5-22.tex

  1. \[ \underline{
  2. \smash{\int f(x)\,\mathrm{d}x}
  3. } \]

src/4-5-23.tex

  1. $\sqrt{A_{n_k}} \qquad
  2. \sqrt{\smash[b]{A_{n_k}}}$

src/4-5-24.tex

  1. \vspace{\baselineskip}% 被忽略的高度
  2. \[
  3. \text{实数} \begin{cases}
  4. \text{有理数}\smash[t]{\begin{cases}
  5. \text{整数}\smash{\begin{cases}
  6. \text{奇数} \\ \text{偶数}
  7. \end{cases}}\\
  8. \text{分数}
  9. \end{cases}} \\[4ex]
  10. \text{无理数}\smash[b]{\begin{cases}
  11. \text{代数无理数} \\ \text{超越数}
  12. \end{cases}}
  13. \end{cases}
  14. \]

src/5-1-01.tex

  1. \begin{tabular}{lcr}
  2. left & center & right \\
  3. 本列左对齐 & 本列居中
  4. & 本列右对齐 \\
  5. \end{tabular}

src/5-1-02.tex

  1. \begin{tabular}{ll}
  2. \bfseries 功能 & \bfseries 环境 \\
  3. 表格 & \ttfamily tabular \\
  4. 对齐 & \ttfamily tabbing \\
  5. \end{tabular}

src/5-1-03.tex

  1. \[
  2. \begin{array}{r|r}
  3. \frac12 & 0 \\
  4. \hline
  5. 0 & -\frac12 \\
  6. \end{array}
  7. \]

src/5-1-04.tex

  1. \begin{tabular}[b]{c}
  2. \\ 中间 \\
  3. \end{tabular}
  4. 与底部对齐。

src/5-1-05.tex

  1. \begin{tabular}{|rr|}
  2. \hline
  3. 输入 & 输出 \\ \hline
  4. $-2$ & 4 \\
  5. 0 & 0 \\
  6. 2 & 4 \\
  7. \hline
  8. \end{tabular}
  9. \qquad
  10. 输入与输出有关系 $y = x^2$

src/5-1-06.tex

  1. \begin{tabular}{|c|rrr|p{4em}|}
  2. \hline
  3. 姓名 & 语文 & 数学 & 外语 & 备注 \\
  4. \hline
  5. 张三 & 87 & 100 & 93 & 优秀 \\
  6. 李四 & 75 & 63 & \emph{52} & 补考另行通知 \\
  7. 王小二 & 80 & 82 & 78 & \\
  8. \hline
  9. \end{tabular}

src/5-1-07.tex

  1. \begin{tabular}{|c|r@{.}l|}
  2. \hline
  3. 收入 & 12345&6 \\ \hline
  4. 支出 & 765&43 \\ \hline
  5. 节余 & 11580&17 \\ \hline
  6. \end{tabular}

src/5-1-08.tex

  1. \[
  2. \begin{array}{|c|*{3}{r@{.}l|}} % 相当于 |c|r@{.}l|r@{.}l|r@{.}l|
  3. \hline
  4. \text{收入} & 12345&6 & 5000&0 & 1020&55 \\ \hline
  5. \text{支出} & 765&43 & 5120&5 & 98760&0 \\ \hline
  6. \text{节余} & 11580&17 & -120&5 & -97739&45 \\ \hline
  7. \end{array}
  8. \]

src/5-1-09.tex

  1. % 导言区 \usepackage{dcolumn}
  2. \newcolumntype{d}{D{.}{.}{2}}
  3. \begin{tabular}{|c|*{3}{d|}} % 相当于 |c|d|d|d|
  4. \hline
  5. 姓名 & \multicolumn{1}{c|}{张三} & \multicolumn{1}{c|}{李四}
  6. & \multicolumn{1}{c|}{王五} \\ \hline
  7. 收入 & 12345.6 & 5000 & 1020.55 \\ \hline
  8. 支出 & 765.43 & 5120.5 & 98760 \\ \hline
  9. 节余 & 11580.17 & -120.5 & -97739.45 \\ \hline
  10. \end{tabular}

src/5-1-10.tex

  1. \verb=tabular= 环境可以在
  2. $\left(\begin{tabular}{@{}c@{}}
  3. 文本 \\ 数学
  4. \end{tabular}\right)$
  5. 模式下通用。

src/5-1-11.tex

  1. % 1 列前是原始间距,第 2 列前只有 1em 间距
  2. % 34 列前则是原始间距加 1em
  3. \begin{tabular}{|c|@{\extracolsep{1em}}c|c|c|}
  4. \hline
  5. 1 & 2 & 3 & 4 \\
  6. 1 & 2 & 3 & 4 \\
  7. \hline
  8. \end{tabular}

src/5-1-12.tex

  1. \renewcommand\arraystretch{2}
  2. \begin{tabular}{|l|r|}
  3. \hline
  4. 这是一个 & 宽松的表格 \\ \hline
  5. loose & table \\ \hline
  6. \end{tabular}

src/5-1-13.tex

  1. % 导言区 \usepackage{array}
  2. \begin{tabular}[b]{|c|}
  3. \firsthline
  4. \\ 中间 \\ \\
  5. \lasthline
  6. \end{tabular}
  7. 与底部对齐。

src/5-1-14.tex

  1. \begin{tabular}{|r|r|}
  2. \hline
  3. \multicolumn{2}{|c|}{成绩} \\ \hline
  4. 语文 & 数学 \\ \hline
  5. 87 & 100 \\ \hline
  6. \end{tabular}

src/5-1-15.tex

  1. \begin{tabular}{|r|r|}
  2. \hline
  3. \multicolumn{1}{|c|}{输入} &
  4. \multicolumn{1}{c|}{输出} \\ \hline
  5. 1 & 1 \\ 5 & 25 \\ 15 & 225 \\ \hline
  6. \end{tabular}

src/5-1-16.tex

  1. \begin{tabular}{|c|r|r|}
  2. \hline
  3. & \multicolumn{2}{c|}{成绩} \\ \cline{2-3}
  4. 姓名 & 语文 & 数学 \\ \hline
  5. 张三 & 87 & 100 \\ \hline
  6. \end{tabular}

src/5-1-17.tex

  1. \begin{tabular}{|c|}
  2. \hline
  3. 1 \\ \hline
  4. \begin{tabular}{@{}c|c@{}} 1 & 2 \end{tabular} \\ \hline
  5. \begin{tabular}{@{}c|c|c@{}} 1 & 2 & 3\end{tabular} \\ \hline
  6. \end{tabular}

src/5-1-18.tex

  1. % 导言区 \usepackage{multirow}
  2. \begin{tabular}{|c|r|r|}
  3. \hline
  4. \multirow{2}*{姓名} &
  5. \multicolumn{2}{c|}{成绩} \\ \cline{2-3}
  6. & 语文 & 数学 \\ \hline
  7. 张三 & 87 & 100 \\ \hline
  8. \end{tabular}

src/5-1-19.tex

  1. % 导言区 \usepackage{makecell}
  2. \begin{tabular}{|r|r|}
  3. \hline
  4. \makecell{处理前\\数据} &
  5. \makecell{处理后\\数据} \\ \hline
  6. 4934 & 8945 \\
  7. \hline
  8. \end{tabular}

src/5-1-20.tex

  1. % 导言区 \usepackage{makecell}
  2. \begin{tabular}{|r|r|}
  3. \hline
  4. \thead{处理前\\数据} &
  5. \thead{处理后\\数据} \\ \hline
  6. 4934 & 8945 \\
  7. \hline
  8. \end{tabular}

src/5-1-21.tex

  1. % 导言区 \usepackage{rotating,makecell}
  2. \settowidth\rotheadsize{\theadfont 数学课}
  3. \begin{tabular}{|c|c|}
  4. \hline
  5. \thead{姓名} & \rothead{数学课\\成绩} \\\hline
  6. 张三 & 100 \\\hline
  7. \end{tabular}

src/5-1-22.tex

  1. % 导言区 \usepackage{multirow,makecell}
  2. \begin{tabular}{|c|r|}
  3. \hline
  4. \multirowcell{3}{各科\\成绩} & 78 \\
  5. \cline{2-2} & 82 \\ \cline{2-2}
  6. & 86 \\ \hline
  7. \end{tabular}

src/5-1-23.tex

  1. % 导言区 \usepackage{diagbox}
  2. \begin{tabular}{|c|*{4}{c}|}
  3. \hline
  4. \diagbox{天干}{地支} & & & & \\
  5. \hline
  6. & 1 && 51 & \\
  7. && 2 && 52 \\
  8. & 13 && 3 & \\
  9. && 14 && 4\\
  10. \hline
  11. \end{tabular}

src/5-1-24.tex

  1. % 导言区 \usepackage{diagbox}
  2. \begin{tabular}{|c|*{4}{c}|}
  3. \hline
  4. \diagbox{天干}{序号}{地支} & & & & \\
  5. \hline
  6. & 1 && 51 & \\
  7. && 2 && 52 \\
  8. & 13 && 3 & \\
  9. && 14 && 4\\
  10. \hline
  11. \end{tabular}

src/5-1-25.tex

  1. \begin{tabular*}{\textwidth}{|c@{\extracolsep{\fill}}ccccc|}
  2. \hline
  3. 数字 & 1 & 2 & 3 & 4 & 5 \\
  4. 字母 & A & B & C & D & E \\
  5. 天干 & & & & & \\
  6. \hline
  7. \end{tabular*}

src/5-1-26.tex

  1. % 导言区 \usepackage{tabularx}
  2. \begin{tabularx}{\textwidth}{|c|X|X|X|X|X|}
  3. \hline
  4. 数字 & 1 & 2 & 3 & 4 & 5 \\ \hline
  5. 字母 & A & B & C & D & E \\ \hline
  6. 天干 & & & & & \\
  7. \hline
  8. \end{tabularx}

src/5-1-27.tex

  1. % 导言区 \usepackage{tabularx}
  2. \newcolumntype{Y}{>{\centering\arraybackslash}X}
  3. \begin{tabularx}{\textwidth}{|c|Y|Y|Y|Y|Y|}
  4. \hline
  5. 数字 & 1 & 2 & 3 & 4 & 5 \\ \hline
  6. 字母 & A & B & C & D & E \\ \hline
  7. 天干 & & & & & \\
  8. \hline
  9. \end{tabularx}

src/5-1-28.tex

  1. % 导言区使用 \usepackage{longtable}
  2. \newcommand\meta[1]{\emph{$\langle$#1$\rangle$}}
  3. \begin{longtable}{|l|l|}
  4. \caption{\texttt{longtable} 环境中的命令汇总} \\
  5. \hline
  6. \endfirsthead
  7. \caption{\texttt{longtable} 环境中的命令汇总(续表)} \\
  8. \hline
  9. \endhead
  10. \hline
  11. \multicolumn{2}{c}{\itshape 接下一页表格……} \\[2ex]
  12. \endfoot
  13. \hline
  14. \endlastfoot
  15. \multicolumn{2}{|c|}{环境的水平对齐可选项} \\ \hline
  16. 留空 & 表格居中%
  17. \footnote{实际上,留空的对齐方式是由一组命令控制的,参见宏包文档。} \\
  18. \verb=[c]= & 表格居中 \\
  19. \verb=[l]= & 表格左对齐 \\
  20. \verb=[r]= & 表格右对齐 \\
  21. \hline \multicolumn{2}{|c|}{结束表格一行的命令} \\ \hline
  22. \verb=\\= & 普通的结束一行表格 \\
  23. \verb=\\[=\meta{距离}\verb=]= & 结束一行,并增加额外间距 \\
  24. \verb=\\*= & 结束一行,禁止在此分页 \\
  25. \verb=\kill= & 当前行不输出,只参与宽度计算 \\
  26. \verb=\endhead= & 此命令以上部分是每页的表头 \\
  27. \verb=\endfirsthead= & 此命令以上部分是表格第一页的表头 \\
  28. \verb=\endfoot= & 此命令以上部分是每页的表尾 \\
  29. \verb=\endlastfoot= & 此命令以上部分是表格最后一页的表尾 \\
  30. \hline \multicolumn{2}{|c|}{标题命令} \\ \hline
  31. \verb=\caption{=\meta{标题}\verb=}= & 生成带编号的表格标题 \\
  32. \verb=\caption*{=\meta{标题}\verb=}= & 生成不带编号的表格标题 \\
  33. \hline \multicolumn{2}{|c|}{分页控制} \\ \hline
  34. \verb=\newpage= & 强制分页 \\
  35. \verb=\pagebreak[=\meta{程度}\verb=]= & 允许分页的程度(0--4 \\
  36. \verb=\nopagebreak[=\meta{程度}\verb=]= & 禁止分页的程度(0--4 \\
  37. \hline \multicolumn{2}{|c|}{脚注控制} \\ \hline
  38. \verb=\footnote= & 使用脚注\footnote{普通表格中不能用。},
  39. 注意不能用在表格头尾 \\
  40. \verb=\footnotemark= & 单独产生脚注编号,不能用在表格头尾 \\
  41. \verb=\footnotetext= & 单独产生脚注文字 \\
  42. \hline \multicolumn{2}{|c|}{长度参数} \\ \hline
  43. \verb=\LTleft= & 对齐方式留空时,表格左边的间距,默认为 \verb=\fill= \\
  44. \verb=\LTright= & 对齐方式留空时,表格右边的间距,默认为 \verb=\fill= \\
  45. \verb=\LTpre= & 表格上方间距,默认为 \verb=\bigskipamount= \\
  46. \verb=\LTpost= & 表格下方间距,默认为 \verb=\bigskipamount= \\
  47. \verb=\LTcapwidth= & 表格标题的宽度,默认为 4\,in \\
  48. \end{longtable}

src/5-1-29.tex

  1. % foo.tex
  2. % 导言区用:
  3. \usepackage{ltxtable}
  4. % 正文使用:
  5. \LTXtable{\textwidth}{mytable}

src/5-1-30.tex

  1. % mytable.tex
  2. \begin{longtable}{|X|X|X|}
  3. ...
  4. \end{longtable}

src/5-1-31.tex

  1. % 导言区使用
  2. % \usepackage{ltxtable}
  3. % \usepackage{fancyvrb}
  4. \begin{VerbatimOut}{\jobname.vrb}
  5. \begin{longtable}{|c|X|X|X|X|X|}
  6. \caption{各种序号} \\ \hline
  7. \endfirsthead
  8. \hline
  9. \endhead
  10. \hline
  11. \endfoot
  12. 数字 & 1 & 2 & 3 & 4 & 5 \\ \hline
  13. 字母 & A & B & C & D & E \\ \hline
  14. 天干 & & & & & \\
  15. \end{longtable}
  16. \end{VerbatimOut}
  17. \LTXtable{0.5\textwidth}{\jobname.vrb}

src/5-1-32.tex

  1. % \usepackage{tabu}
  2. % \usepackage{longtable} % 仍然需要载入 longtable
  3. \begin{longtabu}to 0.5\textwidth{|c|X|X|X|X|X|}
  4. \hline
  5. \endhead
  6. \hline
  7. \endfoot
  8. \caption{各种序号} \\ \hline
  9. \endfirsthead
  10. 数字 & 1 & 2 & 3 & 4 & 5 \\ \hline
  11. 字母 & A & B & C & D & E \\ \hline
  12. 天干 & & & & & \\
  13. \end{longtabu}

src/5-1-33.tex

  1. % \usepackage{xtab}
  2. \begin{center}
  3. \tablecaption{各种序号}
  4. \tablefirsthead{\hline}
  5. \tabletail{\hline \multicolumn{6}{r}{\small 接下页}\\}
  6. \tablelasttail{\hline}
  7. \begin{xtabular}{|*{6}{c|}}
  8. 数字 & 1 & 2 & 3 & 4 & 5 \\ \hline
  9. 字母 & A & B & C & D & E \\ \hline
  10. 天干 & & & & & \\ \hline
  11. \end{xtabular}
  12. \end{center}

src/5-1-34.tex

  1. \begin{tabular}{ccccc}
  2. \toprule
  3. 序号 & 性别 & 年龄 & 身高/cm & 体重/kg \\
  4. \midrule
  5. 1 & F & 14 & 156 & 42 \\
  6. 2 & F & 16 & 158 & 45 \\
  7. 3 & M & 14 & 162 & 48 \\
  8. 4 & M & 15 & 163 & 50 \\
  9. \bottomrule
  10. \end{tabular}

src/5-1-35.tex

  1. % 导言区 \usepackage{multirow,booktabs}
  2. \begin{tabular}{*{6}{c}}
  3. \bottomrule
  4. \multirow{2}*{姓名} & \multicolumn{2}{c}{文科} &
  5. \multicolumn{2}{c}{理科} & \\
  6. \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-6}
  7. \morecmidrules\cmidrule(lr){6-6}
  8. & 历史 & 文学 & 物理 & 化学 & 总评 \\
  9. \midrule
  10. 张三 & A & A & B & A & A \\
  11. \bottomrule
  12. \end{tabular}

src/5-1-36.tex

  1. % 导言区 \usepackage{makecell}
  2. \begin{tabular}{c|cc}
  3. \Xhline{2pt}
  4. 自变量 & \multicolumn{2}{c}{因变量} \\
  5. \Xcline{2-3}{0.4pt}
  6. 半径 & 周长 & 面积 \\
  7. \Xhline{1pt}
  8. 1.00 & 6.28 & 6.28 \\
  9. 2.00 & 12.57 & 12.57 \\
  10. 3.00 & 18.85 & 28.27 \\
  11. \Xhline{2pt}
  12. \end{tabular}

src/5-1-37.tex

  1. % \usepackage{makecell}
  2. \newcolumntype{V}{!{\vrule width 2pt}}
  3. \begin{tabular}{Vc|ccV}
  4. \Xhline{2pt}
  5. 自变量 & \multicolumn{2}{cV}{因变量} \\
  6. \Xcline{2-3}{0.4pt}
  7. 半径 & 周长 & 面积 \\
  8. \Xhline{1pt}
  9. 1.00 & 6.28 & 6.28 \\
  10. 2.00 & 12.57 & 12.57 \\
  11. 3.00 & 18.85 & 28.27 \\
  12. \Xhline{2pt}
  13. \end{tabular}

src/5-1-38.tex

  1. \begin{tabular}{|c||cc|}
  2. \hline\hline
  3. 自变量 & \multicolumn{2}{c|}{因变量} \\
  4. \cline{2-3}
  5. 半径 & 周长 & 面积 \\
  6. \hline\hline
  7. 1.00 & 6.28 & 6.28 \\
  8. 2.00 & 12.57 & 12.57 \\
  9. 3.00 & 18.85 & 28.27 \\
  10. \hline\hline
  11. \end{tabular}

src/5-1-39.tex

  1. % \usepackage{hhline}
  2. \begin{tabular}{|c||cc|}
  3. \hhline{|=:t:==|}
  4. 半径 & 周长 & 面积 \\
  5. \hhline{|=::==|}
  6. 1.00 & 6.28 & 6.28 \\
  7. \hhline{|=:b:==|}
  8. \end{tabular}

src/5-1-40.tex

  1. % \usepackage{arydshln}
  2. \[
  3. \left(
  4. \begin{array}{@{}ccc:c@{}}
  5. a_{11} & a_{12} & a_{13} & b_1 \\
  6. a_{21} & a_{22} & a_{23} & b_2 \\
  7. a_{31} & a_{32} & a_{33} & b_3 \\
  8. \cdashline{1-3}
  9. 0 & 0 & 0 & b_4 \\
  10. \end{array}
  11. \right)
  12. \]

src/5-1-41.tex

  1. % \usepackage{arydshln}
  2. \setlength\dashlinedash{1pt}
  3. \setlength\dashlinegap{2pt}
  4. \begin{tabular}{:cc:cc:}
  5. \hdashline
  6. & & & \\
  7. \cdashline{1-2}
  8. & & & \\
  9. \hdashline
  10. \end{tabular}

src/5-1-42.tex

  1. % \usepackage{arydshln}
  2. \begin{tabular}{;{8pt/2pt}cc;{2pt/2pt}cc;{8pt/2pt}}
  3. \hdashline[8pt/2pt]
  4. & & & \\
  5. \cdashline{1-2}[2pt/2pt]
  6. & & & \\
  7. \hdashline[8pt/2pt]
  8. \end{tabular}

src/5-1-43.tex

  1. % 解决 arydshln hhline, makecell 的冲突
  2. \usepackage{array}
  3. \newcolumntype{|}{!{\vline}}

src/5-1-44.tex

  1. % \usepackage{array} 或调用其他依赖 array 的宏包
  2. \begin{tabular}{>{\bfseries}c|>{\itshape}c>{$}c<{$}}
  3. \hline
  4. 姓名 & \textnormal{得分} & \multicolumn{1}{c}{额外加分} \\
  5. \hline
  6. 张三 & 85 & +7 \\
  7. 李四 & 82 & 0 \\
  8. 王五 & 70 & -2 \\
  9. \hline
  10. \end{tabular}

src/5-1-45.tex

  1. % \usepackage{array}
  2. \begin{tabular}{|>{$}r<{$}|>{\setlength\parindent{2em}}m{15em}|%
  3. >{\centering\arraybackslash}m{4em}|}
  4. \hline
  5. \pi & 希腊字母,多用于表示圆周率,也常用作变量。表示圆周率时多使用
  6. 直立体。 & 常用 \\
  7. \hline
  8. \aleph & 希伯来字母的第一个,在数学中通常用于表示特殊集合的基数。
  9. & 不常用 \\
  10. \hline
  11. \end{tabular}

src/5-1-46.tex

  1. % \usepackage{array}
  2. \begin{tabular}{c!{$\Rightarrow$}c}
  3. 张三 & 85 \\
  4. 李四 & 82 \\
  5. 王五 & 70 \\
  6. \end{tabular}

src/5-1-47.tex

  1. % \usepackage{array}
  2. \newcolumntype{M}{>{$}c<{$}}
  3. \newcolumntype{P}[1]{>{\setlength\parindent{2em}}p{#1}}
  4. \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
  5. % 使用新的列格式:
  6. \begin{tabular}{|M|P{15em}|C{4em}|}
  7. ...
  8. \end{tabular}

src/5-1-48.tex

  1. % \usepackage{tabu}
  2. \begin{tabu}{ccc}
  3. \hline
  4. \rowfont{\bfseries}
  5. 姓名 & 得分 & 额外加分 \\
  6. \hline
  7. 张三 & 85 & $+7$ \\
  8. \rowfont{\itshape}
  9. 李四 & 82 & 0 \\
  10. 王五 & 70 & $-2$ \\
  11. \hline
  12. \end{tabu}

src/5-1-49.tex

  1. \[ \left\{ \begin{matrix}
  2. 1 & 2 \\ 3 & 4
  3. \end{matrix} \right. \]

src/5-1-50.tex

  1. % \usepackage{delarray}
  2. \[
  3. \begin{array}({cc}] % 左边圆括号,右边方括号
  4. 1 & 2 \\
  5. 3 & 4
  6. \end{array}
  7. \]

src/5-1-51.tex

  1. % \usepackage[delarray]{tabu}
  2. \[ \begin{tabu}({cc})
  3. 1 & 2 \\
  4. 3 & 4
  5. \end{tabu} \]

src/5-1-52.tex

  1. % \usepackage{blkarray}
  2. % 如果不用 &| 说明,则竖线 | 将会被看成是中间一列的内容
  3. \begin{blockarray}{|l|c&|r|}
  4. 张三 & Zhang & 80 \\
  5. % 不用在 r 后面用 |,也不影响表格线
  6. 李四 & \BAmulticolumn{1}{r}{Li} & 78 \\
  7. 王五 & Wang & 100 \\
  8. \end{blockarray}

src/5-1-53.tex

  1. % \usepackage{blkarray}
  2. \[ \begin{blockarray}{(cc]}
  3. 1 & 2 \\
  4. 3 & 4
  5. \end{blockarray} \]

src/5-1-54.tex

  1. % \usepackage{blkarray}
  2. \[ \left[
  3. \begin{blockarray}{*4r}
  4. \begin{block}{(rr)rr}
  5. a & -b & 0 & 0 \\
  6. -c & d & 0 & 0 \\
  7. \end{block}
  8. \begin{block}{rr(rr)}
  9. 0 & 0 & -a & b \\
  10. 0 & 0 & c & -d \\
  11. \end{block}
  12. \end{blockarray}
  13. \right] \]

src/5-1-55.tex

  1. \[
  2. \begin{blockarray}{ccc}
  3. \begin{block}{cc\}\BAmultirow{4em}}
  4. 1 & 2 & 自然数 \\
  5. 3 & 4 & {} \\ % 空白 {} 占位
  6. \end{block}
  7. \begin{block}{cc\}l}
  8. -1.5 & \frac12 & \BAmultirow{4em}{实数} \\
  9. 3.5 & 40 & \\
  10. \end{block}
  11. \end{blockarray}
  12. \]

src/5-1-56.tex

  1. \usepackage{blkarray}
  2. \makeatletter
  3. \newbox\BA@first@box
  4. \makeatother

src/5-2-01.tex

  1. % 导言区 \usepackage{graphics}
  2. % \usepackage{graphicx}
  3. 狮子:\includegraphics{lion}

src/5-2-02.tex

  1. \includegraphics[width=2em]{lion}
  2. \includegraphics[height=1cm]{lion}
  3. \includegraphics[scale=0.5]{lion}

src/5-2-03.tex

  1. 旋转的狮子:
  2. \includegraphics[angle=90]
  3. {lion.eps}
  4. \includegraphics[angle=-45,origin=c]
  5. {lion.eps}

src/5-2-04.tex

  1. 基线\rule{2cm}{0.4pt}%
  2. \includegraphics[angle=90,origin=b,
  3. totalheight=1.5cm]{lion.eps}

src/5-2-05.tex

  1. % 导言区 \usepackage[draft]{graphicx}
  2. \includegraphics{lion}

src/5-2-06.tex

  1. \graphicspath{{figures/}} % 本书的设置,图片在当前目录下的 figures 目录
  2. \graphicspath{{pdf/}{png/}{jpg/}} % 按图片类型管理的

src/5-2-07.tex

  1. \scalebox{2}{大字}
  2. \scalebox{2}[1]{扁字}
  3. \scalebox{1}[2]{长字}

src/5-2-08.tex

  1. \LARGE 汉字\reflectbox{汉字}

src/5-2-09.tex

  1. \resizebox{2cm}{1cm}{扁}
  2. \resizebox{!}{1cm}{\fbox{高 1cm}}

src/5-2-10.tex

  1. \rotatebox[origin=c]{90}{旋}%
  2. \rotatebox[origin=c]{90}{转}%
  3. 的汉字

src/5-2-11.tex

  1. % 导言区 \usepackage{lscape}
  2. \begin{landscape}
  3. \subsection{页面旋转}
  4. ……
  5. \end{landscape}

src/5-2-12.tex

  1. \begin{sidewaysfigure}[p]
  2. \centering
  3. \includegraphics[width=7in]{photo.jpg}
  4. \caption{贵州少数民族地区剪影}
  5. \end{sidewaysfigure}

src/5-3-01.tex

  1. \begin{figure}[htbp] % 允许各个位置
  2. \centering
  3. \includegraphics{lion.eps}
  4. \end{figure}
  5. \begin{table} % 默认在页面顶部或单独一页
  6. \centering
  7. \begin{tabular}{|c|c|}
  8. \hline
  9. 图形 & \verb=figure= 环境 \\
  10. \hline
  11. 表格 & \verb=table= 环境 \\
  12. \hline
  13. \end{tabular}
  14. \end{table}

src/5-3-02.tex

  1. \begin{figure}[htp]
  2. \centering
  3. \includegraphics{lion.eps}
  4. \caption[小狮子]{\TeX{} 系统的吉祥物——小狮子}\label{fig-lion}
  5. % 或作 \caption[小狮子]{\label{fig-lion}\TeX{} 系统的吉祥物——小狮子}
  6. \end{figure}

src/5-3-03.tex

  1. % 放宽浮动体的一些参数
  2. \setcounter{topnumber}{3}
  3. \setcounter{bottomnumber}{2}
  4. \setcounter{totalnumber}{7}
  5. \renewcommand\bottomcaption{0.7}
  6. \renewcommand\textfraction{0.1}
  7. % 严格浮动页的要求
  8. \renewcommand\floatpagefraction{0.7}

src/5-3-04.tex

  1. \usepackage{fixltx2e}

src/5-3-05.tex

  1. \usepackage[font=small,labelfont=bf]{caption}

src/5-3-06.tex

  1. \usepackage{caption}
  2. \captionsetup{font=small,labelfont=bf}

src/5-3-07.tex

  1. \usepackage{caption}
  2. \captionsetup[figure]{font=small,labelfont=bf}

src/5-3-08.tex

  1. \usepackage{caption}
  2. \captionsetup[figure]{font=small,labelfont=bf}

src/5-3-09.tex

  1. \caption{默认居中的短标题}

src/5-3-10.tex

  1. \caption[plain 格式]{plian 格式下,
  2. 如果标题很长,折成几行,就会像普通的
  3. 正文段落一样显示。
  4. 只要设置好前面的短标题,可以把浮动
  5. 标题分成好几段。}

src/5-3-11.tex

  1. \captionsetup{format=hang}
  2. \caption[hang 格式]{hang 格式的效果
  3. 是,对于很长的标题,前面的数字标签会
  4. 进行悬挂缩进,就好像 \LaTeX{} 的列表
  5. 环境一样。}

src/5-3-12.tex

  1. % \captionsetup{labelformat=default}
  2. \caption{默认格式,同 simple}

src/5-3-13.tex

  1. \captionsetup{labelformat=empty}
  2. \caption{空格式}

src/5-3-14.tex

  1. \captionsetup{labelformat=simple}
  2. \caption{简单格式,直接输出}

src/5-3-15.tex

  1. \captionsetup{labelformat=brace}
  2. \caption{数字右括号,无文字}

src/5-3-16.tex

  1. \captionsetup{labelformat=parens}
  2. \caption{带括号数字,无文字}

src/5-3-17.tex

  1. \captionsetup{labelsep=none}
  2. \caption{没间隔}

src/5-3-18.tex

  1. % \captionsetup{labelsep=colon}
  2. \caption{英文分号(默认)}

src/5-3-19.tex

  1. \captionsetup{labelsep=period}
  2. \caption{英文句点}

src/5-3-20.tex

  1. \captionsetup{labelsep=space}
  2. \caption{空格}

src/5-3-21.tex

  1. \captionsetup{labelsep=quad}
  2. \caption{一个 em 的间隔}

src/5-3-22.tex

  1. \captionsetup{labelsep=newline}
  2. \caption{标题会另起一行}

src/5-3-23.tex

  1. \captionsetup{labelsep=endash}
  2. \caption{en dash 连接符}

src/5-3-24.tex

  1. \captionsetup{
  2. justification=raggedleft,
  3. singlelinecheck=false}
  4. \caption{右对齐的标题}

src/5-3-25.tex

  1. \captionsetup{font={small,sf},
  2. labelfont=bf}
  3. \caption{小号加粗无衬线体 Caption}

src/5-3-26.tex

  1. \captionsetup{font=small}
  2. \captionsetup{font+=bf}
  3. \caption{小号加粗字体 Caption}

src/5-3-27.tex

  1. \captionsetup{margin=4em}
  2. \caption{标题距离左右各 4\,em
  3. 的距离。}

src/5-3-28.tex

  1. \captionsetup{width=6em}
  2. \caption{标题最多只有 8\,em 宽。}

src/5-3-29.tex

  1. \captionsetup{skip=0pt}
  2. 浮动体的内容。
  3. \caption{与前面无额外间距。}

src/5-3-30.tex

  1. \begin{figure}
  2. \begin{minipage}[b]{.5\textwidth}
  3. \centering
  4. \includegraphics[width=.4\textwidth]{texlive-lion.pdf}
  5. \caption{\TeX\ Live 吉祥物狮子}
  6. \end{minipage}%
  7. \begin{minipage}[b]{.5\textwidth}
  8. \centering
  9. \begin{tabular}{|*{5}{c|}}
  10. \hline
  11. 1996 & 1998 & 1999 & 2000 & 2001 \\ \hline
  12. 2002 & 2003 & 2004 & 2005 & 2007 \\ \hline
  13. 2008 & 2009 & 2010 & \dots & \\
  14. \hline
  15. \end{tabular}
  16. \captionsetup{type=table}
  17. \caption{\TeX\ Live 的版本}
  18. \end{minipage}
  19. \end{figure}

src/5-3-31.tex

  1. % 导言区
  2. \usepackage{caption}
  3. \captionsetup{figurename=图片}

src/5-3-32.tex

  1. \captionsetup{
  2. type=figure,name=空图片}
  3. \caption{标签名称可以修改}

src/5-3-33.tex

  1. \captionof{figure}{空图片标题}

src/5-3-34.tex

  1. \captionsetup{font=sf}
  2. \caption*{没有编号的标题,只保留格式}

src/5-3-35.tex

  1. \begin{figure}
  2. \ContinuedFloat
  3.  ……
  4. \caption{某图形}
  5. \end{figure}
  6. \begin{figure}
  7. \ContinuedFloat
  8.  ……
  9. \caption{某图形(续)}
  10. \end{figure}

src/5-3-36.tex

  1. % 一般在导言区使用
  2. \DeclareCaptionLabelSeparator{fullcolon}{:} % 声明中文的全角冒号分隔符
  3. \captionsetup{labelsep=fullcolon} % 为中文的标题设置全角冒号分隔符

src/5-3-37.tex

  1. % 中文文档类会设定好标题的第一种语言
  2. \documentclass{ctexart}
  3. \usepackage{bicaption}
  4. % 声明 english 选项重定义第二种语言的标签名,选项没有参数
  5. \DeclareCaptionOption{english}[]{%
  6. \renewcommand\figurename{Figure}%
  7. \renewcommand\tablename{Table}}
  8. \captionsetup[bi-second]{english}

src/5-3-38.tex

  1. \begin{figure}
  2. \centering FIGURE
  3. \bicaption{中文标题}{English Title}
  4. \end{figure}

src/5-3-39.tex

  1. \begin{table}
  2. \centering
  3. \caption{并排的表格}
  4. \begin{tabular}{|c|c|}
  5. \hline & \\ \hline
  6. \end{tabular}%
  7. \qquad
  8. \begin{tabular}{|c|c|}
  9. \hline Figure & Table \\ \hline A & B \\ \hline
  10. \end{tabular}
  11. \end{table}

src/5-3-40.tex

  1. \begin{figure}
  2. \centering
  3. \includegraphics[width=0.4\textwidth]{texlive-lion.pdf}%
  4. \qquad
  5. \parbox[b]{0.4\textwidth}{这只狮子是由画师 Duane Bibby 专门为著名的
  6. \TeX{} 发行版 \TeXLive{} 绘制的作品。狮子是 \TeX{} 系统的吉祥物,
  7. Duane Bibby 创作了大量有关 \TeX{} 狮子的插图,如高德纳的 \textit{The
  8. \TeX{}book} Lamport \textit{\LaTeX: A Document Preparation
  9. System} 两书中的狮子插图,就是由 Duane Bibby 创作的。}
  10. \caption{\TeX{} 狮子}\label{fig:texlivelion}
  11. \end{figure}

src/5-3-41.tex

  1. \begin{figure}
  2. \centering
  3. \begin{varwidth}[t]{\textwidth}
  4. \vspace{0pt}
  5. \includegraphics{lion.eps}
  6. \end{varwidth}%
  7. \qquad
  8. \begin{varwidth}[t]{\textwidth}
  9. \vspace{0pt}
  10. \includegraphics[height=4cm]{texlive-lion.pdf}
  11. \end{varwidth}
  12. \caption{两幅狮子图形的按顶部对齐}
  13. \end{figure}

src/5-3-42.tex

  1. \begin{table}
  2. \parbox[b]{.5\textwidth}{\centering
  3. \caption{文字表格}
  4. \begin{tabular}{|c|c|}
  5. \hline & \\ \hline
  6. \end{tabular}}%
  7. \parbox[b]{.5\textwidth}{\centering
  8. \caption{数学表格}
  9. $\begin{array}{|c|c|}
  10. \hline \sqrt{2} & 1.414\dots \\ \hline
  11. \sqrt{3} & 1.732\dots \\ \hline
  12. \end{array}$}
  13. \end{table}

src/5-3-43.tex

  1. % \usepackage{caption,subcaption}
  2. \begin{table}
  3. \caption{图表的子标题}
  4. \parbox[b]{.5\textwidth}{\centering
  5. \begin{tabular}{|c|c|}
  6. \hline & \\ \hline
  7. \end{tabular}
  8. \subcaption{文字表格}}%
  9. \parbox[b]{.5\textwidth}{\centering
  10. $\begin{array}{|c|c|}
  11. \hline \sqrt{2} & 1.414\dots \\ \hline
  12. \sqrt{3} & 1.732\dots \\ \hline
  13. \end{array}$
  14. \subcaption{数学表格}}
  15. \end{table}

src/5-3-44.tex

  1. % \usepackage{caption,subcaption}
  2. \begin{table}
  3. \caption{子图表环境}
  4. \begin{subtable}[b]{.5\textwidth}
  5. \centering
  6. \begin{tabular}{|c|c|} \hline & \\ \hline \end{tabular}
  7. \caption{文字表格}
  8. \end{subtable}%
  9. \begin{subtable}[b]{.5\textwidth}
  10. \centering
  11. $\begin{array}{|c|c|}
  12. \hline \sqrt{2} & 1.414\dots \\ \hline
  13. \sqrt{3} & 1.732\dots \\ \hline
  14. \end{array}$
  15. \caption{数学表格}
  16. \end{subtable}
  17. \end{table}

src/5-3-45.tex

  1. % \usepackage{caption,subcaption}
  2. \begin{table}
  3. \caption{子图表盒子}
  4. \centering
  5. \subcaptionbox{文字表格\label{subtab:test}}[6em]{%
  6. \begin{tabular}{|c|c|} \hline & \\ \hline \end{tabular}}\qquad
  7. \subcaptionbox{数学表格}{%
  8. $\begin{array}{|c|c|}
  9. \hline \sqrt{2} & 1.414\dots \\ \hline
  10. \sqrt{3} & 1.732\dots \\ \hline
  11. \end{array}$}
  12. \end{table}

src/5-3-46.tex

  1. \usepackage{caption}
  2. \usepackage{subcaption}
  3. \captionsetup[sub]{font={small,it}} % 设置所有子标题
  4. \captionsetup[subtable]{labelformat=simple,labelsep=colon} % 设置子表格

src/5-3-47.tex

  1. % \usepackage{float}
  2. \begin{figure}[H]
  3. \centering
  4. \includegraphics[height=1cm]{lion.eps}
  5. \caption{不浮动的图表}
  6. \end{figure}

src/5-3-48.tex

  1. % 导言区
  2. % \usepackage{float}
  3. \newfloat{flowchart}{htbp}{loflow}[chapter]
  4. \floatname{flowchart}{流程图}
  5. % 正文
  6. \begin{flowchart}
  7. \centering
  8. \includegraphics{turing-reverse.pdf}
  9. \caption{求逆字符串的图灵机}
  10. \end{flowchart}

src/5-3-49.tex

  1. \floatstyle{ruled}
  2. \restylefloat{flowchart}
  3. % 正文
  4. \begin{flowchart}
  5. \fbox{A} $\longrightarrow$ \fbox{B} \\
  6. \fbox{C} $\longrightarrow$ \fbox{D}
  7. \caption{基本流程图}
  8. \end{flowchart}

src/5-3-50.tex

  1. \floatplacement{figure}{htbp}
  2. \floatplacement{table}{htbp}

src/5-3-51.tex

  1. \listof{flowchart}{流程图目录}

src/5-3-52.tex

  1. % \usepackage{afterpage}
  2. \afterpage{\begin{figure}[H]
  3. ...
  4. \end{figure}}

src/5-3-53.tex

  1. % \usepackage{afterpage}
  2. \afterpage{\clearpge}

src/5-3-54.tex

  1. % \usepackage{picinpar}
  2. \begin{figwindow}[2,c,% 跨过段落的前两行,中间位置
  3. \includegraphics{lion.eps},Lion\label{fig:wraplion}]
  4. \lipsum*[1] % 足够长的文本段落
  5. \end{figwindow}

src/5-3-55.tex

  1. % \usepackage{wrapfig}
  2. \begin{wraptable}[4]{r}[1.5cm]{4.5cm}
  3. \centering
  4. \begin{tabular}{|c|c|c|c|}
  5. \hline & & & \\ \hline
  6. \end{tabular}
  7. \caption{向右伸出的绕排表格}\label{tag:wraptable}
  8. \end{wraptable}

src/5-3-56.tex

  1. % \usepackage{shapepar}
  2. % \usepackage{tikz,lipsum}
  3. \cutout{r}(-1cm,1cm)\shapepar[2cm]{\circleshape}%
  4. \begin{tikzpicture}[overlay]
  5. \filldraw[fill=lightgray] (0.5,-0.5) circle (1);
  6. \end{tikzpicture}\par
  7. \small\lipsum[1]

src/5-4-01.tex

  1. % \usepackage{color}
  2. \color{red}红色文字夹杂%
  3. \textcolor{blue}{蓝色}文字

src/5-4-02.tex

  1. \colorbox{yellow}{黄色盒子} \\
  2. \fcolorbox{black}{green}{黑框绿盒子}

src/5-4-03.tex

  1. \textcolor[gray]{0.5}{50\% 灰色} \\
  2. \color[rgb]{0.6,0.6,0}暗黄色

src/5-4-04.tex

  1. % \usepackage[dvipsnames]{color}
  2. \textcolor{Purple}{紫色文字}

src/5-4-05.tex

  1. \definecolor{Purple}{cmyk}{0.45,0.86,0,0}

src/5-4-06.tex

  1. % 将所有色彩转换为 CMYK 模型
  2. \usepackage[cmyk]{xcolor}

src/5-4-07.tex

  1. \textcolor{purple!70}{淡紫色}
  2. {\color{blue!60!black}60\% 蓝与 40\% 黑混合的深蓝色}
  3. \colorbox{-red}{青色与红色互补}

src/5-4-08.tex

  1. \colorlet{darkred}{red!50!black}
  2. \textcolor{darkred}{定义暗红色}

src/5-4-09.tex

  1. % \usepackage{colortbl}
  2. % \usepackage{xcolor}
  3. \begin{tabular}{>{\columncolor{gray}}c >{\columncolor{lightgray}}c}
  4. & \\
  5. darker & lighter \\
  6. \end{tabular}

src/5-4-10.tex

  1. \begin{tabular}{|c|@{}>{\columncolor{lightgray}[0pt][\tabcolsep]}c|}
  2. 表列 & 左紧右松 \\
  3. \end{tabular}

src/5-4-11.tex

  1. \begin{tabular}{|ccc|}
  2. \hline \rowcolor{lightgray} A & B & C \\
  3. & & \\\hline % 保持白色
  4. \end{tabular}

src/5-4-12.tex

  1. \begin{tabular}{cccc}
  2. No & No & \cellcolor{lightgray}Yes & No \\
  3. \cellcolor{lightgray}Yes & No & No & No \\
  4. \end{tabular}

src/5-4-13.tex

  1. % \usepackage{xcolor, colortbl}
  2. \arrayrulecolor{gray}
  3. \doublerulesepcolor{lightgray}
  4. \begin{tabular}{|c|c|}
  5. \hline\hline 灰色表线 & 浅灰色间隙 \\
  6. \arrayrulecolor{black}\hline
  7. 以下为原色 & 表线 \\
  8. \doublerulesepcolor{white}\hline\hline
  9. \end{tabular}
  10. \arrayrulecolor{black} % 恢复默认值

src/5-4-14.tex

  1. % \usepackage[table]{xcolor}
  2. \begin{table}[htbp]
  3. \centering
  4. \rowcolors{2}{black!20}{black!10} % 交错的表行
  5. \begin{tabular}{crrr}
  6. \rowcolor{black!30} % 第一行的表头单独设置背景色
  7. 项目 & 数值 & 数值 & 数值 \\
  8. A & 10 & 20 & 30 \\
  9. B & 20 & 15 & 40 \\
  10. C & 15 & 25 & 37
  11. \end{tabular}
  12. \end{table}

src/5-4-15.tex

  1. % \usepackage[table]{xcolor} % 将调入 colortbl
  2. % \usepackage{arydshln} % colortbl 后面使用
  3. \rowcolors*[\hline]{1}{black!20}{black!10}
  4. \begin{tabular}{|c:r|}
  5. A & 10 \\
  6. B & 20 \\
  7. \hiderowcolors
  8. \end{tabular}

src/5-4-16.tex

  1. \begin{tabular}{|cc|} \hline
  2. & foo \\
  3. \rowcolor{lightgray}
  4. \multirow{-2}*{Test} & bar \\\hline
  5. \end{tabular}

src/5-5-01.tex

  1. \xymatrix{
  2. a & b & a+b \\
  3. 1 & 2 & 3 \\
  4. }

src/5-5-02.tex

  1. \xymatrix{
  2. a & b\ar[rd] & a+b \\ % 指向右下方
  3. 1 & 2 & 3\ar"1,1" % 指向 (1,1)
  4. \ar"1,1";"2,2" % 直接从 (1,1) (2,2)
  5. }

src/5-5-03.tex

  1. \xymatrix{
  2. A\ar[r]^{\alpha} & B\ar[d]_{\beta} \\
  3. C\ar[ur]|{\Sigma} & D \\
  4. }

src/5-5-04.tex

  1. \xymatrix{
  2. A\ar[rd]|\hole & B \\
  3. C\ar[ru] & D
  4. }

src/5-5-05.tex

  1. \xymatrix{
  2. A \ar[r]^>{f} & B \\
  3. C \ar[r]^>>{g} & D \\
  4. E \ar[r]^(0.6){h} & F
  5. }

src/5-5-06.tex

  1. \xymatrix{
  2. A \ar[drr]|!{[d];[r]}\hole & B & \\
  3. C \ar[ur] & & D
  4. }

src/5-5-07.tex

  1. \begin{equation}
  2. \begin{gathered} \xymatrix{
  3. S\ar[r]^{f_s} \ar[d]_{\lambda}
  4. & T\ar[d]^{\bar\lambda} \\
  5. S' \ar[r]_{f_{s'}} & T' \\
  6. } \end{gathered}
  7. \end{equation}

src/5-5-08.tex

  1. 映射 $\xymatrix@1{A\ar[r]^{f} & B}$
  2. 是同态。

src/5-5-09.tex

  1. \[ \xymatrix{
  2. A \ar@/^/[r]^{\phi} & B \ar@/^/[l]^{\psi}
  3. } \]

src/5-5-10.tex

  1. \[ \xymatrix{
  2. A \ar[r] & B \ar@(ur,dr)
  3. } \]

src/5-5-11.tex

  1. \[ \xymatrix{
  2. A \ar@<.5ex>[r]^f &
  3. \ar@<.5ex>[l]^g B
  4. } \]

src/5-5-12.tex

  1. \[ \xymatrix@=2cm{
  2. *[F]{A} \ar[r]^*+[F=]{k} & *+[o][F]{B}
  3. } \]

src/5-5-13.tex

  1. \xymatrix{
  2. *++=[o][F]\txt{猫猫} \ar@{<->}[r] &
  3. *+[F]\txt{狗\\狗}
  4. }

src/5-5-14.tex

  1. \xymatrix{
  2. *+[F.]{\composite{*+[o][F]{a\quad} * *+[F]{\quad b}}} \ar[r]
  3. & *+[F]{c}
  4. }

src/5-5-15.tex

  1. \xymatrix@R=2ex{
  2. A \ar[drr]& B & C \\
  3. D & E & F
  4. }

src/5-5-16.tex

  1. \xymatrix@ru{
  2. A \ar[r] & B \ar[d] \\
  3. C \ar[u] & D \ar[l]
  4. }

src/5-5-17.tex

  1. \usepackage{pst-plot,pst-node}

src/5-5-18.tex

  1. \usepackage{pstricks-add} % 同时载入内核与常用的功能模块

src/5-5-19.tex

  1. 直线
  2. \psline(0,0)(1,1em)(1.5,0)
  3. 直线

src/5-5-20.tex

  1. 直线
  2. \begin{pspicture}(1.5,1em)
  3. \psline(0,0)(1,1em)(1.5,0)
  4. \end{pspicture}
  5. 直线

src/5-5-21.tex

  1. \begin{pspicture}(-1.2,-1.2)(1.2,1.2)
  2. \psaxes(0,0)(-1.2,-1.2)(1.2,1.2)
  3. \pscircle(0,0){1}
  4. \end{pspicture}

src/5-5-22.tex

  1. \psset{linewidth=0.4pt}
  2. \begin{pspicture}(-1.2,-1.2)(1.2,1.2)
  3. \psaxes[labels=none,ticks=none]
  4. {->}(0,0)(-1.2,-1.2)(1.2,1.2)
  5. \pscircle[linewidth=0.8pt](0,0){1}
  6. \end{pspicture}

src/5-5-23.tex

  1. \begin{pspicture}(-0.5,0)(1,1)
  2. \pswedge(0,0){1}{0}{120}
  3. \end{pspicture}

src/5-5-24.tex

  1. \begin{pspicture}(-0.5,0)(1.2,1.2)
  2. \psaxes[labels=none,ticks=none]{->}(1.2,1.2)
  3. \pswedge[fillstyle=solid,fillcolor=gray,
  4. opacity=0.2](0,0){1}{0}{120}
  5. \end{pspicture}

src/5-5-25.tex

  1. \uput[120](1;120){$P$}

src/5-5-26.tex

  1. \pnode(1;120){P}
  2. \uput[120](P){$P$}

src/5-5-27.tex

  1. \pnode(1;120){P}
  2. \pnode(P|0,0){P0}

src/5-5-28.tex

  1. \pnode(1;120){P}
  2. \pnode(P|0,0){P0}
  3. \ncline{-}{P}{P0} % 等价于 \psline(P)(P0)

src/5-5-29.tex

  1. \psset{linewidth=0.4pt}
  2. \begin{pspicture}(-1.2,-1.2)(1.2,1.2)
  3. \psaxes[labels=none,ticks=none]{->}(0,0)(-1.2,-1.2)(1.2,1.2)
  4. \pscircle[linewidth=0.8pt](0,0){1}
  5. \pswedge[fillstyle=solid,fillcolor=gray,opacity=0.2]
  6. (0,0){1}{0}{120}
  7. \pswedge[fillstyle=solid,fillcolor=gray,opacity=0.5]
  8. (0,0){0.3}{0}{120}
  9. \uput[60](0.3;60){$120^\circ$} % 在扇形中间标注角度
  10. \pnode(1;120){P}
  11. \pnode(P|0,0){P0}
  12. \ncline{-}{P}{P0} % 正弦线
  13. \uput[120](P){$P$}
  14. \uput[d](P0){$P_0$}
  15. \end{pspicture}

src/5-5-30.tex

  1. \begin{pspicture}(-1,-1.2)(3.5,1.2)
  2. \psaxes{->}(0,0)(0,-1.2)(3.5,1.2)
  3. \psplot{0}{3.5}{x 180 Pi div mul sin} % 三角函数单位是度
  4. \end{pspicture}

src/5-5-31.tex

  1. \psset{algebraic=true}
  2. \begin{pspicture}(-1,-1.2)(3.5,1.2)
  3. \psaxes{->}(0,0)(0,-1.2)(3.5,1.2)
  4. \psplot{0}{3.5}{sin(x)} % 三角函数单位是弧度
  5. \end{pspicture}

src/5-5-32.tex

  1. \psset{algebraic=true}
  2. \begin{pspicture}(0,-1.2)(3.5,1.2)
  3. \psaxes[labels=none,dx=1.57]
  4. {->}(0,0)(0,-1.2)(3.5,1.2)
  5. \psplot{0}{3.5}{sin(x)}
  6. \uput*[d](0,0){$0^\circ$}
  7. \uput*[d](1.57,0){$90^\circ$}
  8. \uput*[d](3.14,0){$180^\circ$}
  9. \end{pspicture}

src/5-5-33.tex

  1. \multido{\n=0+1.57,\i=0+90}{3}{
  2. \uput*[d](\n,0){$\i^\circ$}
  3. }

src/5-5-34.tex

  1. \pnode(!120 Pi mul 180 div 120 sin){Q}
  2. \pnode(Q|0,0){Q0}

src/5-5-35.tex

  1. \uput[r](*{3.5} {sin(x)}){$\sin x$}

src/5-5-36.tex

  1. \begin{pspicture}(-1.5,-0.5)(1.5,0.5)
  2. \pscircle*(0,0){0.5}
  3. \rput(-1,0){
  4. \pscircle(0,0){0.5}
  5. }
  6. \rput(1,0){
  7. \pscircle(0,0){0.5}
  8. }
  9. \end{pspicture}

src/5-5-37.tex

  1. % \newcommand\iangle{120}
  2. \pnode(!\iangle\space Pi mul 180 div \iangle\space sin){Q}

src/5-5-38.tex

  1. % \usepackage{pstricks-add}
  2. % \usepackage{siunitx}
  3. \begin{figure}
  4. \centering
  5. \newcommand\iangle{120}
  6. \psset{unit=1.5cm,linewidth=0.4pt,algebraic=true}
  7. \begin{pspicture}(-3.5,-1.5)(4.5,1.5)
  8. \rput(-2,0){
  9. \psaxes[labels=none,ticks=none]{->}(0,0)(-1.2,-1.2)(1.2,1.2)
  10. \pscircle[linewidth=0.8pt](0,0){1}
  11. \pswedge[fillstyle=solid,fillcolor=gray,opacity=0.2]
  12. (0,0){1}{0}{\iangle}
  13. \pswedge[fillstyle=solid,fillcolor=gray,opacity=0.5]
  14. (0,0){0.3}{0}{\iangle}
  15. \uput[!\iangle\space 2 div]
  16. (0.3;!\iangle\space 2 div) {\ang{\iangle}}
  17. \pnode(1;\iangle){P}
  18. \pnode(P|0,0){P0}
  19. \ncline{-}{P}{P0}
  20. \uput[\iangle](P){$P$}
  21. \uput[d](P0){$P_0$}
  22. }
  23. \psaxes[labels=none,dx=1.57]
  24. {->}(0,0)(0,-1.2)(3.5,1.2)
  25. \psplot[linewidth=0.8pt]{0}{3.5}{sin(x)}
  26. \multido{\n=0+1.57,\i=0+90}{3}{
  27. \uput*[d](\n,0){\small\ang{\i}}
  28. }
  29. \uput[r](*{3.5} {sin(x)}){$\sin x$}
  30. \pnode(!\iangle\space Pi mul 180 div \iangle\space sin){Q}
  31. \pnode(Q|0,0){Q0}
  32. \uput[u](Q){$Q$}
  33. \uput[d](Q0){$Q_0$}
  34. \ncline{-}{Q}{Q0}
  35. \psline[linestyle=dashed](P)(Q)
  36. \end{pspicture}
  37. \caption{正弦函数与单位圆(\textsf{PSTricks} 实现)}
  38. \label{fig:pstsine}
  39. \end{figure}

src/5-5-39.tex

  1. \usepackage{tikz}

src/5-5-40.tex

  1. % 使用 latex + dvipdfmx 编译时
  2. \usepackage[dvipdfmx]{graphicx}
  3. \usepackage{tikz}

src/5-5-41.tex

  1. \begin{tikzpicture}
  2. \draw (0,0) circle (1ex);
  3. \end{tikzpicture}

src/5-5-42.tex

  1. 圆形
  2. \tikz \draw (0,0) circle (1ex);

src/5-5-43.tex

  1. \tikz \fill (0,0) circle (1ex);

src/5-5-44.tex

  1. \tikz \filldraw[thick,fill=gray]
  2. (0,0) circle (0.5cm);

src/5-5-45.tex

  1. \begin{tikzpicture}
  2. \draw[->] (-1.2,0) -- (1.2,0);
  3. \draw[->] (0,-1.2) -- (0,1.2);
  4. \draw[thick] (0,0) circle (1);
  5. \end{tikzpicture}

src/5-5-46.tex

  1. \tikz\draw (30:0.5) arc (30:150:0.5);

src/5-5-47.tex

  1. \begin{tikzpicture}
  2. \draw[thick] (0,0) circle (1);
  3. \fill[fill=gray, fill opacity=0.3]
  4. (0,0) -- (0:1) arc (0:120:1) -- cycle;
  5. \filldraw[fill=gray,fill opacity=0.5]
  6. (0,0) -- (0:0.3) arc (0:120:0.3) -- cycle;
  7. \end{tikzpicture}

src/5-5-48.tex

  1. \begin{tikzpicture}
  2. \draw (0,0) circle (1);
  3. \fill (120:1) circle (2pt);
  4. \node[above left] (P) at (120:1) {$P$};
  5. \end{tikzpicture}

src/5-5-49.tex

  1. \begin{tikzpicture}
  2. \draw (0,0) circle (1);
  3. \coordinate[label=120:$P$] (P) at (120:1);
  4. \draw (0,0) -- (P);
  5. \end{tikzpicture}

src/5-5-50.tex

  1. \coordinate[label=below:$P_0$] (P0) at (P |- 0,0);

src/5-5-51.tex

  1. % \usepackage{siunitx}
  2. \begin{tikzpicture}
  3. \newcommand\iangle{120}
  4. \draw[->] (-1.2,0) -- (1.2,0);
  5. \draw[->] (0,-1.2) -- (0,1.2);
  6. \draw[thick] (0,0) circle (1);
  7. \coordinate[label=\iangle:$P$] (P) at (\iangle:1);
  8. \coordinate[label=below:$P_0$] (P0) at (P |- 0,0);
  9. \draw (0,0) -- (P);
  10. \draw (P) -- (P0);
  11. \fill[fill=gray,fill opacity=0.2]
  12. (0,0) -- (0:1) arc (0:\iangle:1) -- cycle;
  13. \filldraw[fill=gray,fill opacity=0.5]
  14. (0,0) -- (0:0.3) arc (0:\iangle:0.3) -- cycle;
  15. \node[right] at (\iangle/2:0.3) {\ang{\iangle}};
  16. \end{tikzpicture}

src/5-5-52.tex

  1. \begin{tikzpicture}
  2. % 0 度到 360 度的正弦函数曲线,rad 函数和单位 r 把度转换为弧度
  3. \draw[domain=0:rad(360)] plot (\x, {sin(\x r)});
  4. \end{tikzpicture}

src/5-5-53.tex

  1. \begin{tikzpicture}
  2. \draw (0,0) -- (2,0) node[right] {右};
  3. \draw (0,-1) -- node[above] {连线} (2,-1);
  4. \end{tikzpicture}

src/5-5-54.tex

  1. \begin{tikzpicture}
  2. % 坐标轴
  3. \draw[->] (0,0) -- ({rad(210)}, 0);
  4. \draw[->] (0,-1.2) -- (0,1.2);
  5. % 文字标签与刻度
  6. \foreach \t in {0, 90, 180} { % 遍历三个角度
  7. \draw ({rad(\t)}, -0.05) -- ({rad(\t)}, 0.05); % 画刻度线
  8. \node[below, outer sep=2pt, fill=white, font=\small] % 标注横轴角度
  9. at ({rad(\t)}, 0) {\ang{\t}};
  10. }
  11. \foreach \y in {-1,1} {\draw (-0.05,\y) -- (0.05,\y);} % 纵轴刻度
  12. \end{tikzpicture}

src/5-5-55.tex

  1. \begin{tikzpicture}[fill=lightgray] % 全局选项
  2. \begin{scope}[thick,->,fill=gray,xshift=-3cm] % 区块内整体向左平移
  3. \filldraw (0,0) circle (1);
  4. \draw (-1.2,0) -- (1.2,0);
  5. \draw (0,-1.2) -- (0,1.2);
  6. \end{scope}
  7. \filldraw (0,0) circle (1); % 原位置
  8. \end{tikzpicture}

src/5-5-56.tex

  1. \begin{figure}
  2. \centering
  3. % \usepackage{siunitx}
  4. \begin{tikzpicture}[scale=1.5] % 整体放大坐标,但不影响字号
  5. \newcommand\iangle{120}
  6. % 左边的单位圆
  7. \begin{scope}[xshift=-2cm]
  8. \draw[->] (-1.2,0) -- (1.2,0);
  9. \draw[->] (0,-1.2) -- (0,1.2);
  10. \draw[thick] (0,0) circle (1);
  11. \coordinate[label=\iangle:$P$] (P) at (\iangle:1);
  12. \coordinate[label=below:$P_0$] (P0) at (P |- 0,0);
  13. \draw (0,0) -- (P);
  14. \draw (P) -- (P0);
  15. \fill[fill=gray,fill opacity=0.2]
  16. (0,0) -- (0:1) arc (0:\iangle:1) -- cycle;
  17. \filldraw[fill=gray,fill opacity=0.5]
  18. (0,0) -- (0:0.3) arc (0:\iangle:0.3) -- cycle;
  19. \node[right] at (\iangle/2:0.3) {\ang{\iangle}};
  20. \end{scope}
  21. % 右边的函数图
  22. \draw[->] (0,0) -- ({rad(210)}, 0);
  23. \draw[->] (0,-1.2) -- (0,1.2);
  24. \draw[thick, domain=0:rad(210)] plot (\x, {sin(\x r)})
  25. node[right] {$\sin x$};
  26. \foreach \t in {0, 90, 180} {
  27. \draw ({rad(\t)}, -0.05) -- ({rad(\t)}, 0.05);
  28. \node[below, outer sep=2pt, fill=white, font=\small]
  29. at ({rad(\t)}, 0) {\ang{\t}};
  30. }
  31. \foreach \y in {-1,1} {\draw (-0.05,\y) -- (0.05,\y);}
  32. \coordinate[label=above:$Q$] (Q) at ({rad(\iangle)}, {sin(\iangle)});
  33. \coordinate[label=below:$Q_0$] (Q0) at (Q |- 0,0);
  34. \draw (Q) -- (Q0);
  35. \draw[dashed] (P) -- (Q);
  36. \end{tikzpicture}
  37. \caption{正弦函数与单位圆(\textsf{TikZ} 实现)}
  38. \label{fig:tikzsine}
  39. \end{figure}

src/5-5-57.tex

  1. \setlength\unitlength{1cm}
  2. \begin{picture}(1,1)
  3. \put(0,0) {左下} \put(1,1) {右上}
  4. \end{picture}

src/5-5-58.mp

  1. % 主要代码片断
  2. draw (0,0) .. tension 2 .. (1cm,1cm){right} .. (2cm,0){right}
  3. .. (5cm,1cm);

src/5-5-59.mp

  1. % 主要代码片断
  2. z1 = (0,0); z2 = (2cm,0); z3 = (0,1cm); z4 = (3cm,1.5cm);
  3. dotlabel.lft(btex $z_1$ etex, z1); dotlabel.rt(btex $z_2$ etex, z2);
  4. dotlabel.lft(btex $z_3$ etex, z3); dotlabel.rt(btex $z_4$ etex, z4);
  5. draw z1 -- z4; draw z2 -- z3;
  6. z5 = whatever[z1, z4] = whatever[z2, z3]; % 计算交点
  7. dotlabel.bot(btex $z_5$ etex, z5);

src/5-5-60.mp

  1. input metaobj;
  2. beginfig(1);
  3. x = new_Tree( new_Box(btex root etex) )
  4. ( new_Circle(btex child etex),
  5. new_Circle(btex child etex));
  6. Obj(x).c=origin;
  7. draw_Obj(x);
  8. endfig;
  9. end.

src/5-5-61.mp

  1. prologues := 3;

src/5-5-62.tex

  1. % pdfTeX,设置插入 MetaPost 图形
  2. \DeclareGraphicsRule{*}{mps}{*}{}

src/5-5-63.tex

  1. % XeTeX,设置插入 MetaPost 图形
  2. \DeclareGraphicsRule{*}{eps}{*}{}

src/5-5-64.mp

  1. outputtemplate := "%j-%c.mps";

src/5-5-65.tex

  1. % XeTeX,设置插入 MetaPost 图形
  2. \DeclareGraphicsRule{.mps}{eps}{.mps}{}

src/5-5-66.mp

  1. % 带有 LaTeX 标签的 MetaPost 文件
  2. % 需要使用 mpost -tex=latex mptopdf --latex 命令编译
  3. verbatimtex
  4. \documentclass{article}
  5. \usepackage{amssymb}
  6. \begin{document}% 后面可以省去 \end{document}
  7. etex
  8. beginfig(1);
  9. draw fullcircle scaled 2cm;
  10. label.rt(btex $\Lleftarrow$ unit circle etex, (1cm,0));
  11. endfig;
  12. end.

src/5-5-67.mp

  1. % 带有 LaTeX 标签的 MetaPost 文件
  2. % 需要使用 mpost mptopdf 命令编译两遍
  3. input latexmp;
  4. setupLaTeXMP(packages="amssymb");
  5. beginfig(1);
  6. draw fullcircle scaled 2cm;
  7. label.rt(textext("$\Lleftarrow$ unit circle"), (1cm,0));
  8. endfig;
  9. end.

src/5-5-68.mp

  1. % 带有中文 LaTeX 标签的 MetaPost 文件
  2. % 需要使用 mpost mptopdf 命令编译两遍
  3. input latexmp;
  4. setupLaTeXMP(
  5. packages="amssymb,CJK",
  6. preamble=("\AtBeginDocument{\begin{CJK}{UTF8}{gbsn}}" &
  7. "\AtEndDocument{\end{CJK}}"));
  8. beginfig(1);
  9. draw fullcircle scaled 2cm;
  10. label.rt(textext("$\Lleftarrow$ 单位圆"), (1cm,0));
  11. endfig;
  12. end.

src/5-5-69.tex

  1. % \usepackage[shellescape]{gmp}
  2. % 使用 xelatex -shell-escape 命令编译
  3. \begin{mpost}
  4. draw ((0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0)
  5. -- (0,2) -- (2,2) -- (0,0) -- (2,0)) scaled 1cm;
  6. \end{mpost}

src/5-5-70.tex

  1. % 导言区使用
  2. \usepackage[shellescape,latex]{gmp}
  3. \usempxpackage{CJKutf8}
  4. \mpxcommands{
  5. \AtBeginDocument{\begin{CJK*}{UTF8}{gbsn}}
  6. \AtEndDocument{\clearpage\end{CJK*}}
  7. }

src/5-5-71.tex

  1. \begin{mpost*}[mpsettings={u:=\mpdim{0.4\linewidth};}]
  2. fill (0,0) -- (u, 1pt) -- (2u, 0) -- (u, -1pt) -- cycle;
  3. label.top(btex 示例 etex, (u, 1pt));
  4. label.bot(btex \textit{Example} etex, (u, -1pt));
  5. \end{mpost*}

src/5-5-72.asy

  1. draw((0,0) .. tension 2 .. (1cm,1cm){right} .. (2cm,0){right}
  2. .. (5cm,1cm));

src/5-5-73.asy

  1. guide star(int n = 5, real r0 = 1)
  2. {
  3. guide unitstar;
  4. if (n < 5) return nullpath;
  5. real theta = 180/n;
  6. real r = Cos(2theta) / Cos(theta);
  7. for (int k = 0; k < n; ++k)
  8. unitstar = unitstar -- dir(90+2k*theta)
  9. -- r * dir(90+(2k+1)*theta);
  10. unitstar = unitstar -- cycle;
  11. return scale(r0) * unitstar;
  12. }
  13. for (int i = 5; i <= 8; ++i)
  14. filldraw(shift(i*2cm,0) * star(i,1cm), lightgray, gray+1mm);

src/5-5-74.asy

  1. import binarytree;
  2. binarytree bt=searchtree(4,2,1,3,5,6);
  3. draw(bt);

src/5-5-75.asy

  1. import solids;
  2. size(4cm);
  3. currentprojection = orthographic(1, 1, 1);
  4. real a = 4;
  5. real h = 2.2a;
  6. draw(scale3(a) * unitsphere, white);
  7. draw(shift((a/2,0,-h/2)) * scale(a/2,a/2,h) * unitcylinder, gray);

src/5-5-76.tex

  1. % \usepackage{asymptote}
  2. \begin{asy}
  3. real r = 0.8cm;
  4. for (int i = 0; i < 360; i+=10)
  5. draw(circle(dir(i)*r, r));
  6. \end{asy}

src/5-5-77.tex

  1. \usepackage{asymptote}
  2. \begin{asydef}
  3. import graph;
  4. unitsize(1cm);
  5. \end{asydef}

src/6-1-01.tex

  1. \documentclass{beamer}
  2. \usepackage[UTF8,noindent]{ctexcap}
  3. \begin{document}
  4. % ...
  5. \end{document}

src/6-1-02.tex

  1. \makeatletter
  2. \def\beamer@linkspace#1{%
  3. \begin{pgfpicture}{0pt}{-1.5pt}{#1}{5.5pt}
  4. \pgfsetfillopacity{0}
  5. \pgftext[x=0pt,y=-1.5pt]{.}
  6. \pgftext[x=#1,y=5.5pt]{.}
  7. \end{pgfpicture}}
  8. \makeatother

src/6-1-03.tex

  1. \begin{frame}
  2. 这是简单的一帧。
  3. 帧里的内容是垂直居中的。
  4. \end{frame}

src/6-1-04.tex

  1. \begin{frame}
  2. \frametitle{标题}
  3. \framesubtitle{小标题}
  4. 这是简单的一帧。
  5. \end{frame}

src/6-1-05.tex

  1. \begin{frame}{标题}{小标题}
  2. 这是简单的一帧。
  3. \end{frame}

src/6-1-06.tex

  1. \begin{frame}{古中国数学}{定理发现}
  2. 中国在 3000 多年前就知道勾股数的概念,比古希腊更早一些。
  3. 《周髀算经》的记载:
  4. \begin{itemize}
  5. \item 公元前 11 世纪,商高答周公问:
  6. \begin{quote}
  7. 勾广三,股修四,径隅五。
  8. \end{quote}
  9. \item 又载公元前 7--6 世纪陈子答荣方问,表述了勾股定理的一般形式:
  10. \begin{quote}
  11. 若求邪至日者,以日下为勾,日高为股,勾股各自乘,并而开方除之,得邪至日。
  12. \end{quote}
  13. \end{itemize}
  14. \end{frame}

src/6-1-07.tex

  1. % beamer 导言区
  2. \title{杂谈勾股定理}
  3. \subtitle{数学史讲座之一}
  4. \institute{九章学堂}
  5. \author{张三}
  6. \date{\today}
  7. \subject{勾股定理}
  8. \keywords{勾股定理, 历史}

src/6-1-08.tex

  1. \part{引言}
  2. \begin{frame}
  3. \partpage
  4. \end{frame}

src/6-1-09.tex

  1. \lecture{杂谈勾股定理}{gougu} % 讲座标题和讲座标签

src/6-1-10.tex

  1. % 导言区
  2. \AtBeginLecture{
  3. \begin{frame}
  4. \Large
  5. 本周论题:\insertlecture
  6. \end{frame}
  7. }

src/6-1-11.tex

  1. % 导言区
  2. \AtBeginSection[]{ % 空的可选项表示 \section* 前不加目录
  3. \begin{frame}{本节提要}
  4. \tableofcontents[currentsection]
  5. \end{frame}
  6. }

src/6-1-12.tex

  1. \begin{frame}{参考文献}
  2. \nocite{Shiye}
  3. \bibliography{math}
  4. \end{frame}

src/6-1-13.tex

  1. % 提供简单的作者年代引用格式
  2. \bibliographystyle{apalike}

src/6-1-14.tex

  1. \newtheorem{thm}{定理}

src/6-1-15.tex

  1. \renewcommand\proofname{证明}

src/6-1-16.tex

  1. \begin{frame}{现代叙述}
  2. \begin{thm}[勾股定理]
  3. 直角三角形斜边的平方等于两直角边的平方和。
  4. \end{thm}
  5. \end{frame}

src/6-1-17.tex

  1. \begin{frame}
  2. \begin{block}{块标题}
  3. 这是一个区块
  4. \end{block}
  5. \begin{block}{}% 无标题
  6. 这是另一个区块
  7. \end{block}
  8. \end{frame}

src/6-1-18.tex

  1. \begin{frame}{古中国数学}{定理证明}
  2. 有论者认为早在公元前 11 世纪商高即已证明勾股定理\cite{quanjing}。
  3. 完整的证明见于三国时(公元 3 世纪)赵爽对《周髀算经》的注释。
  4. \begin{figure}
  5. \centering
  6. \includegraphics[height=0.4\textheight]{xiantu.pdf}
  7. \caption{赵爽的弦图可给出勾股定理的一个富于对称美的证明}
  8. \end{figure}
  9. \end{frame}

src/6-1-19.tex

  1. \logo{\includegraphics{logo.pdf}}

src/6-1-20.tex

  1. % thm 环境最后:
  2. \begin{center}
  3. \begin{tikzpicture}[scale=0.5,font=\small]
  4. \draw[thick] (0,0) node[left] {$A$}
  5. -- (4,0) node[right] {$C$}
  6. -- (4,3) node[above right] {$B$} -- cycle;
  7. \draw (3.5,0) |- (4,0.5);
  8. \end{tikzpicture}
  9. \end{center}

src/6-1-21.tex

  1. \documentclass[xcolor=table]{beamer}

src/6-1-22.tex

  1. % 颜色 craneorange 是在 crane 色彩主题中定义的
  2. \rowcolors{2}{craneorange!25}{craneorange!50}
  3. \begin{tabular}{rrr}
  4. \rowcolor{craneorange}直角边 $a$ & 直角边 $b$ & 斜边 $c$\\
  5. 3 & 4 & 5 \\
  6. 5 & 12 & 13 \\
  7. 7 & 24 & 25 \\
  8. 8 & 15 & 17 \\
  9. \end{tabular}

src/6-2-01.tex

  1. \usetheme{PaloAlto}

src/6-2-02.tex

  1. \usecolortheme{crane}

src/6-2-03.tex

  1. \usebeamerfonttheme{professionalfonts}
  2. \usepackage{arev}

src/6-2-04.tex

  1. % XeLaTeX 编译
  2. \usepackage[noindent,UTF8]{ctexcap}
  3. \setCJKsansfont[ItalicFont={华文新魏}]{黑体}
  4. \renewcommand\CJKfamilydefault{\CJKsfdefault}

src/6-2-05.tex

  1. \documentclass[no-math]{beamer}
  2. \usepackage[noindent,UTF8]{ctexcap}
  3. \setCJKsansfont[ItalicFont={华文新魏}]{黑体}
  4. \renewcommand\CJKfamilydefault{\CJKsfdefault}

src/6-2-06.tex

  1. \setbeamertemplate{itemize items}[circle]
  2. \setbeamercolor{itemize item}[fg=black]
  3. \setbeamercolor{itemize/enumerate body}{fg=gray}
  4. \setbeamerfont{itemize/enumerate body}{family=\rmfamily}

src/6-3-01.tex

  1. \begin{frame}
  2. \onslide<1>{只有第 1 步}
  3. \onslide<2->{第 2 步之后}
  4. \onslide<1,3>{第 1, 3 两步}
  5. \end{frame}

src/6-3-02.tex

  1. \begin{frame}
  2. 计数:\only<1>{1}\only<2>{2}\only<3>{3}\only<4->{4}
  3. \onslide<5> 数完了。
  4. \end{frame}

src/6-3-03.tex

  1. \begin{frame}
  2. \textbf<3>{只在第 3 步加粗}
  3. \end{frame}

src/6-3-04.tex

  1. \begin{frame}
  2. \begin{theorem}<2->
  3. 2 步以后显示的定理
  4. \end{theorem}
  5. \end{frame}

src/6-3-05.tex

  1. \begin{frame}
  2. \begin{itemize}
  3. \item<1-> 开始显示
  4. \item<3-> 最后显示
  5. \item<2-> 然后显示
  6. \end{itemize}
  7. \end{frame}

src/6-3-06.tex

  1. \begin{frame}
  2. \begin{itemize}[<+->]
  3. \item 开始显示
  4. \item 其次显示
  5. \item 最后显示
  6. \end{itemize}
  7. \end{frame}

src/6-3-07.tex

  1. \alert<2>{在第 2 步强调重要的内容}

src/6-3-08.tex

  1. \begin{itemize}
  2. \item<+-| alert@+>
  3. 公元前 6 世纪,毕达哥拉斯学派发现一个法则,可以构造直角三角形的边长;
  4. \item<+-| alert@+>
  5. 公元前 3 世纪,欧几里德《几何原本》使用面积法证明勾股定理。
  6. \end{itemize}

src/6-3-09.tex

  1. \newdimen\xoffset
  2. \begin{frame}
  3. % 第一步是静止的,之后自动运动
  4. \animate<2-10>
  5. \animatevalue<1-10>{\xoffset}{0cm}{5cm}
  6. \hspace{\xoffset}从左到右
  7. \end{frame}

src/6-3-10.tex

  1. % \usepackage{multimedia}
  2. \begin{frame}{AVI movie}
  3. \movie[width=4cm,height=3cm]{Click to play}{foo.avi}
  4. \end{frame}

src/6-3-11.tex

  1. % \usepackage{multimedia}
  2. \begin{frame}{Music}
  3. % 自动播放,无显示内容
  4. \sound[autostart]{}{foo.au}
  5. \end{frame}

src/6-3-12.tex

  1. % \usepackage{tdclock}
  2. \begin{frame}
  3. 当前时间:\tdtime;已经过去时间:\crono
  4. \end{frame}

src/6-3-13.tex

  1. % \usepackage{ocgtools}
  2. \begin{frame}
  3. % 点击公式会显示定理名称
  4. \ocgminitext{$a^2+b^2=c^2$}{Pythagoras Theorem}
  5. \end{frame}

src/7-1-01.tex

  1. \documentclass{article} % 包含错误的文档
  2. \begin{document}
  3. \secton{Start}
  4. A simple equation
  5. \begin{equation}
  6. x = \overline{a+b
  7. \end{equation}
  8. \end{document}

src/7-1-02.tex

  1. % 当出现 ! No room for a new ... 的错误时使用
  2. \usepackage{etex}

src/7-1-03.tex

  1. % txfonts 定义的重积分符号定义为 \TXFiint,保留原来 amsmath \iint
  2. \usepackage{savesym}
  3. \usepackage{amsmath}
  4. \savesymbol{iint}
  5. \usepackage{txfonts}
  6. \restoresymbol{TXF}{iint}

src/7-2-01.tex

  1. \newcommand\Emph[1]{\textbf{\textit{#1}}}
  2. \show\Emph

src/7-2-02.tex

  1. \newcommand\Emph[1]{\textbf{\textit{#1}}}
  2. \texttt{\meaning\Emph}

src/7-2-03.tex

  1. 版面宽度是:
  2. \texttt{\the\textwidth}

src/7-2-04.tex

  1. \showhyphens{information technology}

src/7-2-05.tex

  1. \draftmode=1

src/7-2-06.tex

  1. % 导言区 \usepackage{trace}
  2. \newcommand\test[2]{(#1-#2)}
  3. \traceon
  4. \test{a}{b}
  5. \traceoff

src/7-2-07.tex

  1. \usepackage[l2tabu, orthodox]{nag}

src/7-2-08.tex

  1. % \usepackage{lipsum}
  2. \linespread{1}\usefont{T1}{bch}{m}{n}
  3. \lipsum[1-2]

src/7-3-01.tex

  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4. \[
  5. \cases{ a & b \cr
  6. c & d \cr}
  7. \]
  8. \end{document}

src/7-3-02.tex

  1. \documentclass{minimal}
  2. \usepackage{amsmath}
  3. \listfiles
  4. \begin{document}
  5. \[
  6. \cases{ a & b \cr
  7. c & d \cr}
  8. \]
  9. \end{document}

src/8-1-01.tex

  1. \def\testsentence{This is a test.}
  2. \def\Emph#1{\textbf{#1}}

src/8-1-02.tex

  1. \def\exchange(#1,#2){#2 and #1}
  2. \exchange(left,right)

src/8-1-03.tex

  1. \def\multi#1{(#1,#1)}
  2. \edef\multi#1{[\multi{#1}, \multi{#1}]}
  3. \multi{X}

src/8-1-04.tex

  1. \let\oldemph=\emph
  2. \renewcommand\emph[1]{\textbf{#1}}
  3. An \emph{important} command

src/8-1-05.tex

  1. \let\oldemph=\emph
  2. \renewcommand\emph[1]{%
  3. \oldemph{\Large #1}}
  4. An \emph{important} command

src/8-1-06.tex

  1. \ifnum 0=1 \fi 相等,
  2. \ifnum \value{page}>100 大页码
  3. \else 小页码\fi
  4. \ifdim \linewidth<5cm 窄行\else 宽行\fi

src/8-1-07.tex

  1. % \usepackage{changepage}
  2. \def\outside#1{%
  3. \checkoddpage % 设置自动交叉引用
  4. \ifoddpage % 使用交叉引用并检查页码奇偶
  5. {\raggedleft #1$\rightarrow$}% 奇数页右侧
  6. \else
  7. {\raggedright $\leftarrow$#1}% 偶数页左侧
  8. \fi}
  9. \outside{\textsf{向外侧对齐}}

src/8-1-08.tex

  1. \def\bigchinese#1{%
  2. \ifcase\value{#1}%
  3. \or \or \or \or \or \or \or \or \or \else 溢出
  4. \fi}
  5. \renewcommand\theenumi{\bigchinese{enumi}}
  6. \begin{enumerate}\sffamily
  7. \item 1 \item 2 \item 3
  8. \end{enumerate}

src/8-1-09.tex

  1. \ifnum 0=1\relax 0\else 1\fi

src/8-1-10.tex

  1. % 将参数 #2 输出 2^#1 次
  2. \def\recur#1#2{%
  3. \ifnum #1=0\relax%
  4. #2 %
  5. \else
  6. \setcounter{enumi}{#1}%
  7. \addtocounter{enumi}{-1}%
  8. \recur{\value{enumi}}{#2 #2}%
  9. \fi}
  10. \textsf{\recur0a\recur1b\recur2c\recur3d}

src/8-1-11.tex

  1. % \usepackage{etoolbox}
  2. \sffamily
  3. \ifnumcomp{\value{page}+1}>{10*10}{大页码}{小页码},
  4. \ifboolexpr{not test {\ifnumodd{\value{page}}}
  5. and test {\ifdimcomp{\linewidth}>{5cm+20pt/2}}}%
  6. {是}{不是}%
  7. 偶数页宽行。

src/8-1-12.tex

  1. % \usepackage{etoolbox}
  2. \begin{math}
  3. \setcounter{enumi}{1}
  4. \whileboolexpr{not test {\ifnumcomp{\value{enumi}}>{30}}}%
  5. {
  6. \mathsf{\theenumi}\rightarrow
  7. \stepcounter{enumi}
  8. }
  9. \cdots
  10. \end{math}

src/8-1-13.tex

  1. \catcode`\"=\active
  2. \def"#1"{\textbf{#1}}
  3. An "important" usage.

src/8-1-14.tex

  1. \makeatletter
  2. \setlength\@fpsep{1cm}% 浮动页中不同浮动体间距
  3. \makeatother

src/8-1-15.tex

  1. % boldmath.sty
  2. \ProvidesPackage{boldmath}[2010/10/10 v1.0 emphasis using bold font]
  3. \newcommand\Emph[1]{\textbf{#1}}

src/8-1-16.tex

  1. % myarticle.cls
  2. \ProvidesClass{myarticle}[2010/10/10 v1.0]
  3. \LoadClass[a4paper,11pt]{article}
  4. \RequirePackage{boldemph}[2010/10/10]

src/8-1-17.tex

  1. \DeclareOption{hyperref}{%
  2. \RequirePackage{hyperref}%
  3. }

src/8-1-18.tex

  1. \AtEndDocument{%
  2. \begin{center}
  3. \includegraphics{logo.pdf}
  4. \end{center}}

src/8-1-19.tex

  1. % boldemph.sty 中,给 emph 增加加粗的功能
  2. \let\boldmath@oldemph\emph
  3. \def\emph#1{\textbf{\boldemph@oldemph{#1}}}

src/8-1-20.tex

  1. % 通常是在某 .sty .cls
  2. % \RequirePackage{keyval}
  3. % 定义 text 族的 emph 选项,控制 \emph 命令的定义
  4. \let\text@emph=\emph
  5. \define@key{text}{emph}[\text@emph]{%
  6. \let\emph=#1}
  7. \newcommand\settext[1]{%
  8. \setkeys{text}{#1}}
  9. % .tex 文件中使用
  10. \begin{quotation}
  11. \settext{emph=\textbf} % 粗体
  12. An \emph{important} example.
  13. \settext{emph} % 默认的格式
  14. An \emph{important} example.
  15. \end{quotation}

src/8-1.tex

  1. \begin{codebox}
  2. \Procname{$\proc{BinSearch}(A, x, L, H)$}
  3. \li \While $L\le H$ \RComment $L$ $H$ 是左右分点
  4. \li \Do $M \gets \lfloor(L+H)/2\rfloor$ \RComment $M$ 是中间分点
  5. \li \If $x > A[M]$
  6. \li \Then $H \gets M-1$
  7. \li \ElseIf $x < A[M]$
  8. \li \Then $H \gets M+1$
  9. \li \ElseNoIf \RComment 找到 $x$,返回位置
  10. \li $j \gets M$
  11. \li \Return $j$
  12. \End
  13. \End
  14. \li $j \gets 0$
  15. \li \Return $j$
  16. \end{codebox}

src/8-2-01.plt

  1. set terminal epslatex size 8cm,4cm
  2. set output 'sine-epslatex.tex'
  3. set size 1,1
  4. set xlabel '$x$'
  5. set ylabel '$y$'
  6. set xtics ('$-\pi$' -pi, '$-\frac12\pi$' -pi/2, 0, \
  7. '$\frac12\pi$' pi/2, '$\pi$' pi)
  8. set ytics (-1, 0, 1)
  9. set format y "$%g$"
  10. plot [-pi:pi] [-1:1] sin(x) title '$\sin x$'

src/8-2-02.tex

  1. % \usepackage{pgfplotstable}
  2. \pgfplotstabletypeset{
  3. Input Output
  4. -1 10
  5. 0 1500
  6. 1 1235.7
  7. 2 1.53e6
  8. }

src/8-2-03.tex

  1. % \usepackage{pgfplotstable,booktabs}
  2. \pgfplotstableset{
  3. every head row/.style={
  4. before row=\toprule,after row=\midrule},
  5. every last row/.style={
  6. after row=\bottomrule},
  7. column type=r, col sep=comma}
  8. \pgfplotstabletypeset{temperature.csv}

src/8-2-04.markdown

  1. C 语言的循环语句
  2. ================
  3. C 语言可以使用 `for` 循环语句,例如计算 $s = \sum_k k^2$
  4. int s = 0;
  5. for (int k = 1; k < 10; ++k)
  6. s += k * k;

src/temperature.csv

  1. 华式,摄式,开尔文
  2. 1,-17.22222222,255.9277778
  3. 20,-6.666666667,266.4833333
  4. 40,4.444444444,277.5944444
  5. 60,15.55555556,288.7055556
  6. 80,26.66666667,299.8166667
  7. 100,37.77777778,310.9277778
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注