如何将文档正文设置为 Times New Roman 并将章节标题设置为 Arial?

如何将文档正文设置为 Times New Roman 并将章节标题设置为 Arial?

可能重复:
更改部分字体

对于大学作业,我被赋予了一些“内部风格”规则,所有文档都必须遵守这些规则。这些规则是:

正文:Times New Roman,12pt

标题 1:Arial,16pt

标题 2:Arial,14pt

标题 3:Arial,12pt

我知道我需要使用 XeLaTeX 才能使用系统字体,但是,无论我怎么尝试,我都无法正确显示文档。

关于如何实现这一点,Tex 有什么想法吗?

答案1

修改答案这里对于您需要的尺寸,这应该非常简单:

% Compile with XeLaTeX or LuaLaTeX
\documentclass[12pt]{article}
\usepackage[tmargin=1in,bmargin=1in,lmargin=1.25in,rmargin=1.25in]{geometry}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{titlesec}
\defaultfontfeatures{Ligatures=TeX}
% Set sans serif font to Arial
\setsansfont{Arial}
% Set serifed font to Times New Roman
\setmainfont{Times New Roman}
% Set formats for each heading level
\titleformat*{\section}{\fontsize{16}{18}\bfseries\sffamily}
\titleformat*{\subsection}{\fontsize{14}{16}\bfseries\sffamily}
\titleformat*{\subsubsection}{\fontsize{12}{14}\bfseries\sffamily}

\begin{document}
\section{A section}
This is some text.
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}

代码输出

相关内容