所有章节标题均使用无衬线字体

所有章节标题均使用无衬线字体

我正在使用 overleaf,并尝试让正文使用 Alegreya 的衬线版本,但标题和标题使用无衬线版本。关于这一点有很多问题,但没有找到解决方案。查看了但那里的答案没有帮助。最终的结果是,在标题中我现在得到的是 Computer Modern 的 Sans。我在哪里指定 Alegreya Sans 是\sffamily-packagesectsty应该使用的?或者还有其他方法可以实现我的目标吗?

\documentclass{book}
\usepackage[utf8]{inputenc}


\title{test}
\author{name}
\date{now}

\usepackage{sectsty}

\usepackage[T1]{fontenc}
\usepackage{Alegreya} %% Option 'black' gives heavier bold face
\renewcommand*\oldstylenums[1]{{\AlegreyaOsF #1}}

\allsectionsfont{\normalfont\sffamily\bfseries}

\begin{document}

\chapter*{This is not Alegregya Sans!}
So here, the body text is in the font is what I would like it to be, namely Alegreya. I got there through using the fontenc package. Then I tried to use the sectsty package and the allsectionsfont command to specify that the sffamily of the font should be used. But it seems it defaulted to the Computer Modern Sans font instead...


\end{document}

无衬线字体问题

答案1

在此处输入图片描述

您需要与 Sans Serif 字体匹配的包。

\documentclass{book}
\usepackage[utf8]{inputenc}


\title{test}
\author{name}
\date{now}


\usepackage{sectsty}

\usepackage[T1]{fontenc}
\usepackage{Alegreya,AlegreyaSans} %% Option 'black' gives heavier bold face
\renewcommand*\oldstylenums[1]{{\AlegreyaOsF #1}}

\allsectionsfont{\normalfont\sffamily\bfseries}

\begin{document}

\chapter*{This is not Alegregya Sans!}
So here, the body text is in the font is what I would like it to be, namely Alegreya. I got there through using the fontenc package. Then I tried to use the sectsty package and the allsectionsfont command to specify that the sffamily of the font should be used. But it seems it defaulted to the Computer Modern Sans font instead...


\end{document}

相关内容