你能帮我修改这个 tex 文件吗?“关于章节格式”

你能帮我修改这个 tex 文件吗?“关于章节格式”
\documentclass[12pt,a4paper]{report}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fontspec}
\usepackage{pgfplots,tikz,enumerate,array,fancyhdr,enumitem,fancybox,graphicx,amsfonts,amsmath,amssymb,amsthm,mathrsfs}
\usepackage{titlesec}
\usepackage[arabic]{minitoc}
\usepackage{fancybox}
%======================================================== 
% languages & fonts===========================================
\usepackage[numbers]{natbib}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\setcounter{minitocdepth}{1}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Amiri}
\newfontfamily\arabicfontsf[Script=Arabic,Scale=1.2]{Andalus}
%%
%=========================================================
\addto\captionsarabic{%
  \renewcommand{\chaptername}{\sffamily الفصل}%
}
\addto\captionsarabic{\renewcommand{\chaptername}{\sffamily الفصل }}
%===============================================================



\pagestyle{fancy}
\parindent=0pt

\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or الأول
\or الثاني 
\or الثالث 
\or الرابع
\or الخامس
\else
I need more words\fi}
%=======================================
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother
%=============================================


\titleformat{\chapter}
{\bfseries\large}
{}
{0pt}
{\titlerule{3pt}~\raisebox{-3.5pt}
{\sc{\chaptername}~
\thechapter}~\Huge\titlerule{3pt}\\
\vspace{1.05cm}\titlerule{}\\
\filcenter #1\\
\vspace{1.25cm}\titlerule}



\begin{document}

\chapter{الرياضيات}

\end{document}

答案1

这是一个解决方案。

首先你需要加载标题带有选项的包明确的IE \usepackage[explicit]{titlesec}

第二,该命令\titlerule有一个选修的参数,所以需要输入\titlerule[3pt]

对于问题,请添加评论。应该使用numberless变体来定义章节格式或类似格式。

\titleformat{name=\chapter}...用于编号章节。

\titleformat{name=\chapter, numberless}... 对于未编号的章节。

\documentclass[12pt,a4paper]{report}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fontspec}
\usepackage{pgfplots,tikz,enumerate,array,fancyhdr,enumitem,fancybox,graphicx,amsfonts,amsmath,amssymb,amsthm,mathrsfs}
\usepackage[explicit]{titlesec}
\usepackage[arabic]{minitoc}
\usepackage{fancybox}
%======================================================== 
% languages & fonts===========================================
\usepackage[numbers]{natbib}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\setcounter{minitocdepth}{1}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Amiri}
\newfontfamily\arabicfontsf[Script=Arabic,Scale=1.2]{Andalus}
%%
%=========================================================
\addto\captionsarabic{%
  \renewcommand{\chaptername}{\sffamily الفصل}%
}
\addto\captionsarabic{\renewcommand{\chaptername}{\sffamily الفصل }}
%===============================================================



\pagestyle{fancy}
\parindent=0pt

\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or الأول
\or الثاني 
\or الثالث 
\or الرابع
\or الخامس
\else
I need more words\fi}
%=======================================
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother
%=============================================


\titleformat{name=\chapter}
{\bfseries\large}
{}
{0pt}
{\titlerule[3pt]~\raisebox{-3.5pt}
{\sc{\chaptername}~
\thechapter}~\Huge\titlerule[3pt]\\
\vspace{1.05cm}\titlerule\\
\filcenter #1\\
\vspace{1.25cm}\titlerule}


\titleformat{name=\chapter, numberless}
{\bfseries\large}
{}
{0pt}
{%
%\titlerule[3pt]\\ %comment or uncomment this
\Huge
%\titlerule[3pt]\\ %comment or uncomment this
\vspace{1.05cm}\titlerule\\
\filcenter #1\\
\vspace{1.25cm}\titlerule}



\begin{document}
\tableofcontents

\chapter{الرياضيات}

\end{document}

相关内容