其他章节目录:
https://blog.csdn.net/Vissence/article/details/105237257
本章内容:字体
LaTeX有三种文字模式:段落模式,LR模式,数学模式。这本书中,段落模式和LR模式有时合称为即文本模式。
- 段落模式
段落模式用于生成普通的文本。该模式下会根据页面大小自动调整字间距、行间距以及分页。 - LR模式
LR模式从左到右处理文本,没有字间距(比如空格)和换行符,例如\ mbox {}或\ fbox {}命令,其参数可能超过页面的指定宽度。 - 数学模式
数学模式用于编写数学表达式。
2.1 Text-Mode Fonts
- LaTeX中的字体类型分为四类-家族(family),系列(series),形状(shape)和大小(size)。
- LaTeX文档的默认字体类型是serif系列,10pt(原文:medium series serif family in upright shape and 10pt size)。
- 字体大小按照格式不同(如标题和段落)进行计算。
- 可以通过\ documentclass [] { }命令更改默认的全局字体。例如,\ documentclass [12 pt] {article}用于生成12 pt字体的文章。当然也可以手动修改单独某个部分的字体。
注意:\textxx{} 和 {\xx }的区别,textxx{ }是段落模式,{\xx }是LR模式(空格不显示)
例子:\textit{\large {Uno Dos Tres Cuotro Cinco}}
结果: Uno Dos Tres Cuotro Cinco \textit{\large {Uno Dos Tres Cuotro Cinco}} Uno Dos Tres Cuotro Cinco
例子:{\large\it {Uno Dos Tres Cuotro Cinco}}
结果: U n o D o s T r e s C u o t r o C i n c o {\large\it {Uno Dos Tres Cuotro Cinco}} UnoDosTresCuotroCinco
-
1. Font Family
-
三种标准字体族:serif (默认), sans serif 和 typewriter fonts。
使用方式:字体族 使用 声明 例子 结果 serif \textrm{ } 或者 {\rm } \rmfamily {\rm Hello} H e l l o {\rm Hello} Hello sans serif \textsf{ } 或者 {\sf} \sffamily {\sf Hello} H e l l o {\sf Hello} Hello typewriter fonts \texttt{ } 或者 {\tt} \ttfamily {\tt Hello} H e l l o {\tt Hello} Hello
2. Font Series
-
两个字体系列:medium-valued width and height (默认),boldface。
使用方式:字体系列 使用 声明 例子 结果 medium \textmd{ } \mdseries \textmd{China} China \textmd{China} China boldface \textbf{ } 或者 {\bf } \bfseries \textbf{China} China \textbf{China} China
3. Font Shape
-
四种形状:upright (默认), italic, slanted, 和caps and small caps。
使用方式:
除了以上四种形状,还可以用 \emph{ } 或者 {\em } 来强调文本。字体形状 使用 声明 例子 结果 upright \textup{ } \upshape \textup{Gracias} Gracias \textup{Gracias} Gracias italic \textit{ } 或者 {\it } \itshape \textit{Gracias} Gracias \textit{Gracias} Gracias slanted \textsl{ } 或者 {\sl } \slshape \textsl{Gracias} CSDN打不出来 caps and small caps \textsc{ } 或者 {\sc } \scshape \textsc{Gracias} CSDN打不出来
4. Font Size
-
字体大小是相对大小,比较对象是最开始的文档设置”\documentclass [ 12 pt ] { } “。
十种字体大小:字体大小 使用 声明 例子 结果 微小 {\tiny } \tiny \tiny Hola! H o l a ! \tiny Hola! Hola! 角标 {\scriptsize } \scriptsize \scriptsize Hola! H o l a ! \scriptsize Hola! Hola! 脚注 {\footnotesize } \footnotesize \footnotesize Hola! H o l a ! \footnotesize Hola! Hola! 小 {\small } \small \small Hola! H o l a ! \small Hola! Hola! 正常 {\normalsize } \normalsize \normalsize Hola! H o l a ! \normalsize Hola! Hola! 微大 {\large } \large \large Hola! H o l a ! \large Hola! Hola! 较大 {\Large } \Large \Large Hola! H o l a ! \Large Hola! Hola! 大 {\LARGE } \LARGE {\LARGE Hola!} H o l a ! {\LARGE Hola!} Hola! 巨大 {\huge } \huge {\huge Hola!} H o l a ! {\huge Hola!} Hola! 超级大 {\Huge } \Huge {\Huge Hola!} H o l a ! {\Huge Hola!} Hola!
-
字体组合
例子:{\large {\textit {italic large fonts}}}
结果: italic large fonts {\large {\textit {italic large fonts}}} italic large fonts
例子:{\large {\it italic large fonts}}
结果: i t a l i c l a r g e f o n t s {\large {\it italic large fonts}} italiclargefonts -
调整一小部分可以用:\textbf{text}
-
而大面积调整有两种方法。
- 不带参数的命令:先用\bfseries调整后面一部分字体,再用\normalfont返回正常字体。
- 利用环境:\ begin {bfseries} 和 \ end {bfseries}
例子:
结果:
2.2 Math-Mode Fonts
数学模式下的字体和文本模式一样,可以用不同的字体,但对应命令有点稍微不一样,实际如下图。
重点:
- 文本模式下使用数学模式
(这翻译可能有点不理解,简单说就是在一个段落里打公式)。
这种情况需用一对$把代码夹起来。
例子:$\mathbf{abc}$
结果: a b c \mathbf{abc} abc
特例:\boldmath{}有点不同,它是把参数用$扩起来,即:\boldmath{$abc$}
结果:CSDN打不出来。。 - \mathcal{ },\mathbb{}和 \Bbb{ }命令对小写字母不起作用。
例子:$\mathcal{A\ a\ B\ b\ C\ c\ D\ d}$
结果: A a B b C c D d \mathcal{A\ a\ B\ b\ C\ c\ D\ d} A a B b C c D d - 数学模式下的空格会被省略,需要用反斜杠()或者波浪号(~)来显示空格。当然,如果还用了文本模式下类似于\textbf{}这种,还是会显示空格的。
例子:$\mathbb{ A\ B ~~ C}$
结果: A B C \mathbb{ A\ B ~~ C} A B C
2.3 Emphasized Fonts
-
重要的字体一般要强调!
作用 使用 例子 结果 加粗 {\bf }或\textbf{ } {\bf important} i m p o r t a n t {\bf important} important 斜体 {\it }或\textit{}或\emph{ } \textit{Very Important} Very Important \textit{Very Important} Very Important 加粗加斜体 {\bf\em },或\textbf{\emph{}} {\bf\em Significantly Important} Significantly Important {\bf\textit {Significantly Important}} Significantly Important 下划线 \underline \underline{important} i m p o r t a n t ‾ \underline{important} important 【注】:\underline的参数不能越线,否则可能会下划线可能会超过边界。遇到这个问题需要引入( ulem )包。
-
ulem包
ulem包重定义了{\em} 和\emph{}命令,用\ULforem 和\normalem来打开和关闭ulem包的作用。
此外,还有一些其他命令:{\em},\emph{},\uwave{},\sout{},\xout{}。
直接看图。
2.4 Colored Fonts
给字体上色要用到color包,这个包有三种颜色组合:
原文 | 中文 |
---|---|
black and white (gray) | 黑白色(灰度) |
additive primaries(rgb) | 叠加三原色(RGB) |
subtractive primaries(cmyk) | 消减三原色(CMYK) |
-
自定义颜色
用\definecolor{}{}{}命令可以自定义颜色,下图是具体使用方法,其中,cname是用户自定义的颜色名字,比如:\definecolor{bluesky}{rgb}{0.1, 0.2, 0.5}.
-
预先定义的颜色
有些颜色已经定义好了,不需要再定义,这些颜色有:
灰度模式下:黑色
RGB模式下:红绿蓝黑白
CMYK模式:黄黑白,蓝绿色(cyan),品红(magenta)
-
使用
定义好之后就可以用啦,使用方法:\textcolor{cname}{atext}
例子:\textcolor{blue}{this~is~in~blue}
结果: t h i s i s i n b l u e \textcolor{blue}{this~is~in~blue} this is in blue
例子:\textcolor{magenta}{this~is~in~magenta.}
结果: t h i s i s i n m a g e n t a . \textcolor{magenta}{this~is~in~magenta.} this is in magenta.
例子:\textcolor{magenta}{\textsf {\Large Large Sans serif in magenta}}
结果: Large Sans serif in magenta \textcolor{magenta}{\textsf {\Large Large Sans serif in magenta}} Large Sans serif in magenta -
记得先引用color包!