我正在使用一些代码这里这使得我可以使用阿拉伯语序数词作为章节标题。
我也想更改标题间距。我对 不太熟悉titlesec
。该\titlespacing
命令需要较早的设置\titleformat
(titlesec
文档第 5 页),但我不知道如何在格式命令patchcmd
中的 MWE 中 合并\titleformat
。
我该如何使用titlesec
阿拉伯序数词?MWE 中注释掉的行是我想要的标题间距设置。
\documentclass[12pt,oneside]{report}
\usepackage{titlesec}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}
\gappto\captionsarabic{\renewcommand{\chaptername}{الباب}}
\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
الخامس\or
\else
you need to supply additional numbers \fi}
%next three lines is to make chapter naming use the above wordings (literal numbering in Arabic words)
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother
% \titlespacing{\chapter}{0pt}{0ex plus 9ex minus 9ex}{0ex plus 9ex minus 9ex}
\begin{document}
\chapter{ددد}
\end{document}
答案1
这里有两个解决方案,带和不带titlesec
包
第一的(titlesec
)
\documentclass[12pt,oneside]{report}
\usepackage{titlesec}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}
\gappto\captionsarabic{\renewcommand{\chaptername}{الباب}}
\def\xwords#1{\ifcase\value{#1}\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
الخامس\or
\else
you need to supply additional numbers \fi}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \xwords{chapter}}{20pt}{\Huge}
\titlespacing{\chapter}{0pt}{0ex plus 9ex minus 9ex}{0ex plus 9ex minus 9ex}
\begin{document}
\chapter{ددد}
\end{document}
第二
\documentclass[12pt,oneside]{report}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}
\gappto\captionsarabic{\renewcommand{\chaptername}{الباب}}
\def\xwords#1{\ifcase\value{#1}\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
الخامس\or
\else
you need to supply additional numbers \fi}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\xwords{chapter}}{}{}
\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{\vspace*{0ex plus 9ex minus 9ex}}{}{}
\patchcmd{\@makechapterhead}{\vskip 40\p@}{\vspace*{0ex plus 9ex minus 9ex}}{}{}
\makeatother
\begin{document}
\chapter{ددد}
\end{document}