在 XeLatex 中将章节标题居中对齐

在 XeLatex 中将章节标题居中对齐

我正在使用以下软件包来获取 Times New Roman 字体:

\documentclass[12pt, a4paper, oneside]{book}
\usepackage{ifxetex,ifluatex} %compile with XeLatex
\ifluatex                    %or LuaLatex
\usepackage{unicode-math}
\setmainfont{Times New Roman} % text font
\setmathfont{XITS Math} % Times Roman math font
\else\ifxetex
\usepackage{fontspec}
\setmainfont{Times New Roman}
% possibly need to choose a suitable math font in my thesis:
\else
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newtxtext,newtxmath}
\fi\fi 

我无法将章节标题居中对齐。我使用过不同的软件包,但都没有用。到目前为止,我使用了

\usepackage{xpatch}

\makeatletter

\xpatchcmd{\@makeschapterhead}{%
  \Huge \bfseries  #1\par\nobreak%
}{%
  \Huge \bfseries\centering #1\par\nobreak%
}{\typeout{Patched makeschapterhead}}{\typeout{patching of @makeschapterhead failed}}


\xpatchcmd{\@makechapterhead}{%
  \huge\bfseries \@chapapp\space \thechapter
}{%
  \huge\bfseries\centering \@chapapp\space \thechapter
}{\typeout{Patched @makechapterhead}}{\typeout{Patching of @makechapterhead failed}}

\makeatother 

还,

 \chapter{\centering Chapter Title}

\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}

答案1

实际上,问题是由于“ sectsty”包添加

\chapterfont{\fontsize{14}{17}\selectfont\centering}

'之后\include{chapter tilte}问题解决了。

相关内容