LaTeX 字体
原 文:Font typefaces
译 者:Xovee
翻译时间:2022年11月15日
介绍
LaTeX默认使用Computer Modern
字体家族。本文介绍如何在LaTeX中使用其他类型的字体。
改变文档的默认字体
做到这一点非常简单,例如,简单地在文档的preamble中使用\usepackage{tgbonum}
命令,LaTeX就会使用TEX Gyre Bonum
字体:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tgbonum}
\begin{document}
This document is a sample document to test font
families and font typefaces.
This text uses a different font typeface
\end{document}
部分改变字体
你也可以对文档中的一部分文字使用不一样的字体。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tgbonum}
\begin{document}
This document is a sample document to
test font families and font typefaces.
{\fontfamily{qcr}\selectfont
This text uses a different font typeface
}
\end{document}
命令\fontfamily{qcr}\selectfont
指定了gyre cursor
字体,字体的代码是qcr
。这个命令将大括号中的文字字体更改为所指定的字体。文末列出了更多的LaTeX字体供参考。
流行的LaTeX字体一般起源于四个字体家族:
Computer Modern
,LaTeX中的默认字体:CM Roman, CM Sans Serif, CM TypewriterLatin Modern
:LM Roman, LM Sans Serif, LM Typewriter, LM DunhillPost Script Fonts
:Times, Utopia/Fourier, Palatino, Bookman, Helvetica, CourierTeX Gyre
参考指南
Roman, Sans Serif 和 Typewriter 字体
字体 | 包名 | 字体代码 | 示例 |
---|---|---|---|
Computer Modern Roman | cmr | ![]() | |
Latin Modern Roman | lmodern | lmr | ![]() |
Latin Modern Dunhill | lmodern | lmdh | ![]() |
TeX Gyre Termes | tgtermes | qtm | ![]() |
TeX Gyre Pagella | tgpagella | qpl | ![]() |
TeX Gyre Bonum | tgbonum | qbk | ![]() |
TeX Gyre Schola | tgschola | qcs | ![]() |
Times | mathptmx | ptm | ![]() |
Utopia / Fourier | utopia /fourier | put | ![]() |
Palatino | palatino | ppl | ![]() |
Bookman | bookman | pbk | ![]() |
Charter | charter | bch | ![]() |
Computer Modern Sans Serif | cmss | ![]() | |
Latin Modern Sans Serif | lmodern | lmss | ![]() |
TeX Gyre Adventor | tgadventor | qag | ![]() |
TeX Gyre Heros | tgheros | qhv | ![]() |
Helvetica | helvet | phv | ![]() |
Computer Modern Sans Typewriter | cmtt | ![]() | |
Latin Modern Sans Typewriter | lmodern | lmtt | ![]() |
TeX Gyre Cursor | tgcursor | qcr | ![]() |
Courier | courier | pcr | ![]() |
还有很多其他类型的字体,请参考The TeX Font Catalogue 字体目录。因为目录中有些字体并不是免费分发的,所以你可能不能在Overleaf上使用这些字体。
举个例子,如果你想使用Open sans 字体,打开这个网站:
找到Open Sans:
里面介绍了具体的使用范例:
\usepackage[default,oldstyle,scale=0.95]{opensans}
\usepackage[T1]{fontenc}
关于该字体的某些特定设置你可以在CTAN中查看,比如字宽和某些具体的样式选择: