Skip to content

Commit

Permalink
[chap.04, 05] 整理数学字体有关内容
Browse files Browse the repository at this point in the history
- 重写「加粗的数学符号」一节,不再介绍 \boldmath 命令
- 补充 unicode-math 宏包的介绍
- Close #46.
  • Loading branch information
stone-zeng committed May 7, 2021
1 parent 4f73d8a commit 656e074
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
58 changes: 28 additions & 30 deletions src/chap/chap.04.math.tex
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ \section{公式中的间距}\label{sec:math-space}
\end{tabularx}
\end{center}

一个常见的用途是修正积分的被积函数$f(x)$和微元$\mathrm{d}x$之间的距离。注意微元里的$\mathrm{d}$用的是直立体:
一个常见的用途是修正积分的被积函数 $f(x)$ 和微元 $\mathrm{d}x$ 之间的距离。
注意微元里的 $\mathrm{d}$ 用的是直立体:
\begin{example}
\[
\int_a^b f(x)\mathrm{d}x
Expand All @@ -636,8 +637,9 @@ \section{公式中的间距}\label{sec:math-space}
\]
\end{example}

另一个用途是生成多重积分号。如果我们直接连写两个 \cmd{int},之间的间距将会过宽,此时可以使用负间距 \cmd{!} 修正之。
不过 \pkg{amsmath} 提供了更方便的多重积分号,如二重积分 \amscmd{iint}、三重积分 \amscmd{iiint} 等。
另一个用途是生成多重积分号。如果我们直接连写两个 \cmd{int},之间的间距将会过宽,此时可以使用负间距
\cmd{!} 修正之。不过 \pkg{amsmath} 提供了更方便的多重积分号,如二重积分 \amscmd{iint}、三重积分
\amscmd{iiint} 等。
\begin{example}
\newcommand\diff{\,\mathrm{d}}
\begin{gather*}
Expand Down Expand Up @@ -692,9 +694,32 @@ \subsection{数学字母字体}\label{subsec:math-alpha}
\end{tabular}
\end{table}

一般来说,不同的数学字体往往带有不同的语义,如矩阵、向量等常会使用粗体或粗斜体,而数集常会使用 \cmd{mathbb} 表示。出于内容与格式分离以及方便书写的考虑,可以为它们定义新的命令。具体方法详见 \ref{subsec:newcmd} 小节。

\pkgindex{unicode-math}
如果需要为所有的数学符号切换字体,则需要直接调用数学字体宏包(见 \ref{subsec:font-pkgs} 小节)。在 \texttt{xelatex} 或者 \texttt{lualatex} 编译命令下,还可以使用基于 \pkg{fontspec} 宏包的 \pkg{unicode-math} 宏包配置 Unicode 数学字体,详见 \ref{subsec:unicode-math} 小节。

\subsection{加粗的数学符号}\label{subsec:math-bold}

\cmdindex[amsmath]{boldsymbol}
\ref{tbl:math-fonts} 中的 \cmd{mathbf} 命令只能获得直立、加粗的字母。如果想得到粗斜体%
\footnote{国内使用粗斜体符号表示矢量,见 GB 3102.11--93。},可以使用 \pkg{amsmath} 宏包提供的
\amscmd{boldsymbol} 命令:
\begin{example}
$\mu, M \qquad
\boldsymbol{\mu}, \boldsymbol{M}$
\end{example}

\pkgindex{bm}
\cmdindex[bm]{bm}
也可以使用 \pkg{bm} 宏包提供的 \cmd{bm} 命令:
\begin{example}
% \usepackage{bm}
$\mu, M \qquad \bm{\mu}, \bm{M}$
\end{example}
\LaTeX{} 默认的数学字体中,一些符号本身并没有粗体版本,使用 \amscmd{boldsymbol} 也得不到粗体。
此时 \cmd{bm} 命令会生成“伪粗体”,尽管效果比较粗糙,但在某些时候也不失为一种解决方案。

\subsection{数学符号的尺寸}\label{subsec:math-styles}

\mathindex{displaystyle,textstyle,scriptstyle,scriptscriptstyle}
Expand Down Expand Up @@ -727,33 +752,6 @@ \subsection{数学符号的尺寸}\label{subsec:math-styles}
\]
\end{example}

\subsection{加粗的数学符号}\label{subsec:math-bold}

\LaTeX{} 中为符号切换数学字体并不十分自由,只能通过 \cmd{mathbf} 等有限的命令切换字体。比如想得到粗斜体的符号,就没有现成的命令%
\footnote{国内使用粗斜体符号表示矢量,见 GB 3102.11--93。};再比如 \cmd{mathbf} 只能改变拉丁字母和大写希腊字母,小写希腊字母就没有用。

\cmdindex{boldmath}
\LaTeX{} 提供了一个命令 \cmd{boldmath} 令用户可以将整套数学字体切换为粗体版本(前提是数学字体宏包本身支持粗体符号)。但这个命令\textbf{只能在公式外使用}:
\begin{example}
$\mu, M \qquad
\mathbf{\mu}, \mathbf{M}$
\qquad {\boldmath$\mu, M$}
\end{example}

\cmdindex[amsmath]{boldsymbol}
\pkg{amsmath} 提供了一个 \amscmd{boldsymbol} 命令(由调用的 \pkg{amsbsy} 宏包提供),用于打破 \cmd{boldmath} 的限制,
在公式内部将一部分符号切换为粗体。
\begin{example}
$\mu, M \qquad
\boldsymbol{\mu}, \boldsymbol{M}$
\end{example}

\pkgindex{bm}
\cmdindex[bm]{bm}
然而在许多数学字体宏包中,定界符、巨算符等一些符号本身没有粗体版本,\amscmd{boldsymbol} 也得不到粗体。
\LaTeX{} 工具宏集之一的 \pkg{bm} 宏包可以用 \cmd{bm} 命令生成“伪粗体”,作为粗体符号的一个解决方案。这里不做过多介绍,
详情请参考 \pkg{bm} 宏包的帮助文档。

\section{定理环境}\label{sec:theorems}

\subsection{\LaTeX{} 原始的定理环境}\label{subsec:latex-theorems}
Expand Down
36 changes: 19 additions & 17 deletions src/chap/chap.05.style.tex
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ \subsection{字体编码}\label{subsec:font-encs}
\pkg{newpxtext},\pkg{newpxmath} & \pkg{pxfonts} 的改进版本,分别设置文本和数学字体 \\
\pkg{mathptmx} & \pkg{psnfss} 字体宏集之一,Times 风格,较为陈旧,不推荐使用 \\
\pkg{mathpazo} & \pkg{psnfss} 字体宏集之一,Palatino 风格,较为陈旧,不推荐使用 \\
\pkg{fourier} & fourier 风格数学字体,配合 Utopia 正文字体 \\
\pkg{fouriernc} & fourier 风格数学字体,配合 New Century Schoolbook 正文字体 \\
\pkg{fourier} & Fourier 风格数学字体,配合 Utopia 正文字体 \\
\pkg{fouriernc} & Fourier 风格数学字体,配合 New Century Schoolbook 正文字体 \\
\pkg{arev} & Arev 无衬线字体宏包,Vera Sans 风格 \\
\pkg{mathdesign} & 配合 Charter / Garamond / Utopia 正文字体的数学字体宏包 \\
\hline
Expand Down Expand Up @@ -219,7 +219,7 @@ \subsection{使用 \pkg{fontspec} 宏包更改字体}\label{subsec:fontspec}
\end{verbatim}
\Arg{font features} 还能配置字体本身的各种特性,这里不再赘述,感兴趣的读者请参考 \pkg{fontspec} 宏包的帮助文档。

需要注意的是\pkg{fontspec} 宏包会覆盖数学字体设置。需要调用表 \ref{tbl:font-pkgs} 中列出的一些数学字体宏包时,
需要注意的是\pkg{fontspec} 宏包会覆盖数学字体设置。需要调用表 \ref{tbl:font-pkgs} 中列出的一些数学字体宏包时,
应当在调用 \pkg{fontspec} 宏包时指定 \texttt{no-math} 选项。\pkg{fontspec} 宏包可能被其它宏包或文档类(如 \pkg{ctex} 文档类)自动调用时,
则在文档开头的 \cmd{document\-class} 命令里指定 \texttt{no-math} 选项。

Expand Down Expand Up @@ -253,37 +253,39 @@ \subsection{使用 \pkg{unicode-math} 宏包配置 Unicode 数学字体}\label{s
\cmd{setmathfont}\marg{font name}\oarg{font features}
\end{command}

绝大多数时候,只需要给定字体名称 \Arg{font name} 即可。由于篇幅所限,在此不介绍可选参数 \Arg{font feature} 涉及的配置,有兴趣的读者请参考宏包的帮助文档。

Unicode 数学字体相比于正文字体的选择余地不多。表 \ref{tbl:uni-math-fonts} 给出了较为常用的 Unicode 数学字体。
绝大多数时候,只需要给定字体名称 \Arg{font name} 即可。由于篇幅所限,在此不介绍可选参数 \Arg{font feature} 涉及的配置,有兴趣的读者请参考宏包的帮助文档。Unicode 数学字体相比于正文字体的选择余地不多。表 \ref{tbl:uni-math-fonts} 给出了较为常用的 Unicode 数学字体。

\begin{table}[htp]
\centering\small
\caption{常用 Unicode 数学字体。}
\label{tbl:uni-math-fonts}
\begin{tabular}{llp{20em}}
\hline
\textbf{数学字体名称} & \textbf{配套正文字体名称} & \textbf{备注}\\
\textbf{数学字体名称} & \textbf{配套正文字体名称} & \textbf{备注} \\
\hline
\multicolumn{3}{c}{开源字体,发布于 CTAN} \\
\hline
\texttt{Latin Modern Math} & \texttt{Latin Modern} & 基于 Computer Modern 风格 \\
\texttt{STIX Math} & \texttt{STIX} & Times 风格 \\
\texttt{XITS Math} & \texttt{XITS} & 基于 STIX,Times 风格,有粗体 XITS Math Bold 可用 \\
\texttt{TeX Gyre Pagella Math} & \texttt{TeX Gyre Pagella} & Palatino 风格 \\
\texttt{TeX Gyre Termes Math} & \texttt{TeX Gyre Termes} & Times 风格 \\
\texttt{Libertinus Math} & \texttt{Libertinus} & Linux Libertine 风格 \\
\texttt{Fira Math} & \texttt{Fira Sans} & 无衬线数学字体 \\
Latin Modern Math & Latin Modern & 基于 Computer Modern 风格 \\
STIX Math & STIX & Times 风格 \\
XITS Math & XITS & 基于 STIX,Times 风格,有粗体 XITS Math Bold 可用 \\
TeX Gyre Pagella Math & TeX Gyre Pagella & Palatino 风格 \\
TeX Gyre Termes Math & TeX Gyre Termes & Times 风格 \\
TeX Gyre DejaVu Math & DejaVu Serif & DejaVu 风格 \\
Libertinus Math & Libertinus & Linux Libertine 风格 \\
Garamond Math & EB Garamond & Garamond 风格 \\
Fira Math & Fira Sans & 无衬线数学字体 \\
\hline
\multicolumn{3}{c}{商业字体} \\
\hline
\texttt{Cambria Math} & \texttt{Cambria} & 较新版本的微软 Office 预装数学字体 \\
\texttt{Lucida Bright Math OT} & \texttt{Lucida Bright OT} & 须购买商业授权 \\
\texttt{Minion Math} & \texttt{Minion Pro} & 须购买商业授权 \\
Cambria Math & Cambria & 微软 Office 预装的数学字体 \\
Lucida Bright Math OT & Lucida Bright OT & 须购买商业授权 \\
Minion Math & Minion Pro & 须购买商业授权 \\
\hline
\end{tabular}
\end{table}

\pkg{unicode-math} 宏包与传统数学字体、符号包并不兼容,但其本身已经提供了大量的符号和字体样式。实际上,\ref{subsec:math-alpha} 和 \ref{subsec:math-bold} 小节中介绍的内容均已被 \pkg{unicode-math} 所涵盖,无需调用其他宏包就可以获得覆盖完整、风格较为统一的字体样式。具体使用方法请参考宏包帮助文档。

\section{文字装饰和强调}\label{sec:emphasize}

强调文字的方法,或者是添加下划线等装饰物,或者是改变文字的字体。
Expand Down
2 changes: 1 addition & 1 deletion src/lshort-zh-cn-style.sty
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%
% 基本工具宏包
%
\RequirePackage{amsmath,amsthm}
\RequirePackage{amsmath,amsthm,bm}
\RequirePackage{hologo,verbatim,fancyvrb,layout,multicol}
\RequirePackage[normalem]{ulem}
\RequirePackage{colortbl,tabularx,multirow,makecell,booktabs}
Expand Down

0 comments on commit 656e074

Please sign in to comment.