我正在尝试更改章节标题和小节的字体,但网上的所有示例都无法正常工作。这是我当前的代码及其生成的排版。如何更改标题和小节的字体?例如,我想将标题和小节的字体设置为 Arial,以将正文字体保留为 Palatino。
\documentclass[12pt]{memoir}
\usepackage{fontspec}\setmainfont{Palatino}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{csquotes}
\usepackage{endnotes}
\usepackage{imakeidx}\makeindex[columns=3, title=Alphabetical Index]
\usepackage[
backend=biber,
style=authortitle,
citestyle=authortitle
]{biblatex}\addbibresource{sample.bib}
\usepackage[explicit]{titlesec}
\titleformat{\chapter}[display]{\bfseries\centering}{\huge\thechapter}{1em}{\Huge #1}
\begin{document}
\setlength{\bibhang}{0pt}
\setlength\bibitemsep{\baselineskip}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
\include{./TeX_files/introduction}
\include{./TeX_files/chapter01}
\theendnotes
\printbibliography
\backmatter
\printindex
\end{document}
答案1
titlesec
我已通过和包将章节和小节标题更改为 Arial fontspec
。我还注释掉了一些代码,以便代码可以在我的机器上运行。
\documentclass[12pt]{memoir}
\usepackage{blindtext}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}%I don't have Palatino.
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{csquotes}
%\usepackage{endnotes}
\usepackage{imakeidx}\makeindex[columns=3, title=Alphabetical Index]
\usepackage[
backend=biber,
style=authortitle,
citestyle=authortitle
]{biblatex}\addbibresource{sample.bib}
\usepackage[explicit]{titlesec}
\newfontfamily{\arialfont}{Arial Nova}
\titleformat{\chapter}%
[display]%
{%
\bfseries%
\centering%
\arialfont%
}%
{\huge\thechapter}%
{1em}%
{\Huge #1}
\titleformat{\subsection}
[display]
{%
\bfseries%
\arialfont%
}
{\thesubsubsection}
{}
{#1}
\title{Title}
\author{Author}
\begin{document}
\setlength{\bibhang}{0pt}
\setlength\bibitemsep{\baselineskip}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
%\include{./TeX_files/introduction}
%\include{./TeX_files/chapter01}
\blinddocument
%\theendnotes
%\printbibliography
\backmatter
\printindex
\end{document}