Latex 更改section 字体

问题

在使用Texmaker自动生成的 xelatex 模板排版中文报告时。由于将主字体设置为楷体

\setmainfont[BoldFont=SimHei]{STKaiti}

导致 section 使用英文时,默认字体非常的丑陋,效果如下:

Latex 更改section 字体_第1张图片

解决

在Google latex section font 后意外的发现了下面的问答,完美的解决了我想要更换 section 字体的问题,附带还学到了控制 xelatex 产生类似 MS word 文档的标题效果。

The best way to have total control over the sectioning is the titlesec package. Here’s a quick version of the standard MSWord sectioning for the first three levels. To control colours, you need the xcolor package.

If you are using different fonts for different section levels (not recommended) you should use fontspec’s \newfontfamily command to define the font first, then use that in the redefinition of the title format, as in the subsubsection example.

This document can be compiled with either XeLaTeX or LuaLaTeX.

% 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 Calibri
\setsansfont{Calibri}
% Set serifed font to Cambria
\setmainfont{Cambria}
% Define light and dark Microsoft blue colours
\definecolor{MSBlue}{rgb}{.204,.353,.541}
\definecolor{MSLightBlue}{rgb}{.31,.506,.741}
% Define a new fontfamily for the subsubsection font
% Don't use \fontspec directly to change the font
\newfontfamily\subsubsectionfont[Color=MSLightBlue]{Times New Roman}
% Set formats for each heading level
\titleformat*{\section}{\Large\bfseries\sffamily\color{MSBlue}}
\titleformat*{\subsection}{\large\bfseries\sffamily\color{MSLightBlue}}
\titleformat*{\subsubsection}{\itshape\subsubsectionfont}

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

效果如下:

Latex 更改section 字体_第2张图片

参考

http://tex.stackexchange.com/questions/10138/change-section-fonts

你可能感兴趣的:(11,Latex)