因此我发现您可以在任何通用 LaTeX 文档中通过添加以下行来使用 Open Sans:
\usepackage[default,scale=0.9]{opensans}
\usepackage[T1]{fontenc}
现在,我想要改用较浅的字体变体 Open Sans Light 作为整个文档的默认字体。我该怎么做?
答案1
您可以将其与通用字体切换命令( 、 等)一起使用,但\usefont{T1}{fos}{l}{n}
定义快捷方式更简单。我为非标准粗细( 、 和 )提供了light
快捷方式:light-condensed
semibold
extrabold
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[defaultsans]{opensans}
\DeclareRobustCommand\ebseries{\fontseries{eb}\selectfont}
\DeclareRobustCommand\sbseries{\fontseries{sb}\selectfont}
\DeclareRobustCommand\ltseries{\fontseries{l}\selectfont}
\DeclareRobustCommand\clseries{\fontseries{cl}\selectfont}
\DeclareTextFontCommand{\texteb}{\ebseries}
\DeclareTextFontCommand{\textsb}{\sbseries}
\DeclareTextFontCommand{\textlt}{\ltseries}
\DeclareTextFontCommand{\textcl}{\clseries}
\begin{document}
\sffamily
{\ebseries
This line is extrabold \textsc{text text text text}.}
{\sbseries
This line is semibold \textsc{text text text text}.}
A normal text \textsc{text text text text}.
\textcl{A condensed light text.}
\ltseries
A light text text text text
\textsc{A light smallcaps text}
\itshape A light italic text
\scshape A light small caps italic text.
\end{document}
答案2
使用xelatex
而不是 然后pdflatex
您可以轻松定义所有字体:
\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\setmainfont[%
BoldFont =Open Sans Bold,
ItalicFont =Open Sans Italic,
BoldItalicFont=Open Sans Bold Italic]{Open Sans Regular}
\newfontfamily\light[%
BoldFont =Open Sans Semibold,
ItalicFont =Open Sans Light Italic,
BoldItalicFont=Open Sans Semibold Italic]{Open Sans Light}
\newfontfamily\condlight[%
ItalicFont =Open Sans Cond Light Italic]{Open Sans Cond Light}
\begin{document}
text text text text\par
{\bfseries Text text text text}\par
{\itshape Text text text text}\par
{\itshape\bfseries text text text text}
\light
text text text text\par
{\bfseries Text text text text}\par
{\itshape Text text text text}\par
{\itshape\bfseries text text text text}
\condlight
text text text text\par
{\itshape Text text text text}
\end{document}