如何获取此格式:
和这个
\documentclass[12pt,a4paper,openany]{book}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{titleps}
\usepackage{pifont}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{geometry}
%%%%%%%%%%%%%%%%%%%
\usetikzlibrary{arrows}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\usetikzlibrary{patterns,shapes.geometric}
\linespread{1.5}
\usetikzlibrary{calc, hobby}
%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheoremstyle{break}% name
{}% Space above, empty = `usual value'
{}% Space below
{\itshape}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{.}% Punctuation after thm head
{\newline}% Space after thm head: \newline = linebreak
{}% Thm head spec
\theoremstyle{break}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem{theo}{نظرية}[section]
\newtheorem{theorem}{مبرهنة}[section]
\newtheorem{corollary}{نتيجة}[section]
\newtheorem{definition}{تعريف}[section]
\newtheorem{prop}{قضية}[section]
\newtheorem{proposition}{لازمة}[section]
\newtheorem{lemma}{توطئة}[section]
\newtheorem{remark}{ملاحظة}[section]
\newtheorem{example}{مثال}[section]
\newtheorem{exercise}{تمرين}[section]
\renewenvironment{proof}{{\bfseries برهان: $~~$\\}{}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.1,AutoFakeSlant=-0.03]{Amiri}
\setsansfont[Script=Arabic,Scale=1.1]{Amiri}
\makeatletter
\pretocmd{\@chapter}{\begingroup \renewcommand{\thechapter}{{\words{chapter}}}}{}{}
\apptocmd{\@chapter}{\endgroup}{}{}
\makeatother
\titlecontents{lsection}
[2.3em]{\LARGE}{\contentslabel{2.3em}}
{\hspace*{-3em}}
{}
\titlecontents{lsubsection}
[4.6em]{\LARGE}{\contentslabel{2.3em}}
{\hspace*{-3em}}
{}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \words{chapter}}{20pt}{\Huge}
\titlespacing{\chapter}
{0pt}{40pt}{-10pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MACRO FOR LITERAL NUMBERING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
الخامس\or
السادس\or
السابع\or
الثامن\or
التاسع\or
العاشر\or
الحادي عشر\or
الثاني عشر\or
الثالث عشر\or
الرابع عشر\or
الخامس عشر\or
السادس عشر\or
السابع عشر\or
الثامن عشر\or
التاسع عشر\or
العشرون\or
\else
I need more words\fi}
\makeatletter
%\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother
\renewcommand{\baselinestretch}{1.1}%المسافة بين الأسطر
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END MACRO FOR LITERAL NUMBERING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% REDEFINING NAMES IN ARABIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gappto\captionsarabic{\renewcommand{\contentsname}{المحتويات}}
\gappto\captionsarabic{\renewcommand{\chaptername}{الفصل}}
\gappto\captionsarabic{\def\figurename{رسم}}
\gappto\captionsarabic{\renewcommand{\tablename}{جدول}}
\gappto\captionsarabic{\renewcommand{\indexname}{\textbf{الثبت}}}
\gappto\captionsarabic{\renewcommand{\appendixname}{\textbf{الملحق}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MACRO FOR PARTIAL CONTENTS %%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END MACRO FOR PARTIAL CONTENTS %%%%%%%%%%%%%%%%%%%%%%%
\setcounter{secnumdepth}{5}%pour la numérotation dans le corps du document
%\setcounter{tocdepth}{5} %pour l'apparition dans la table des matières
%%%%%%%%%%%%%%%%%% REDEFINES \THECHAPTER IN CONTENTS
\makeatletter
\pretocmd{\@chapter}{\begingroup \renewcommand{\thechapter}{{\words{chapter}}}}{}{}
\apptocmd{\@chapter}{\endgroup}{}{}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{titletoc}%
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\bfseries\vspace*{10pt}}% <above-code>
{\normalsize\chaptername\ \thecontentslabel.\;}% <numbered-entry-format>
{}% <numberless-entry-format>
{\normalsize\hfill\contentspage}% <filler-page-format>
\usepackage[Glenn]{fncychap}
\ChNumVar{\Large}% Dimension of the number of the chapter in the first page... instead of the default...\ChNumVar{\Huge}
\renewcommand{\thesection}{\arabic{section}}
\parindent=0mm
\begin{document}
\setnonlatin
\chapter{مقدمة }
\end{document}
答案1
这是一个解决方案。使用 etoc 的软件包似乎更简单。
\documentclass[12pt,a4paper,openany]{book}
%-------------------------------------------------------
\usepackage{etoc}
\usepackage{tikz}
\usetikzlibrary{shadows}
%-------------------------------------------------------
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.1,AutoFakeSlant=-0.03]{Amiri}
\setsansfont[Script=Arabic,Scale=1.1]{Amiri}
%-------------------------------------------------------
\definecolor{myblue}{rgb}{0, .55, .7}
\newcommand*{\CircleNum}[1]{%
\tikz[baseline={([yshift=-.5ex]current bounding box.center)}]
\node[fill=myblue,circle,text=white] {#1};}
\newcommand*{\tocframe}[1]{%
\hspace{.45\textwidth}\tikz\node[color=white, fill=myblue, drop shadow={opacity=.3},
inner sep=5mm, rounded corners, font=\small]{%
\parbox{.65\textwidth}{#1}};}
\newcommand*{\chapternumberbox}[1]{%
\tikz\node[color=white, fill=blue!50!black, draw=black,
rounded corners, inner sep=4pt, minimum height=2cm, font=\bfseries]{%
\parbox{.18\textwidth}{\begin{Arabic}#1\end{Arabic}}};}
\newcommand{\chapternamebox}[1]{%
\tikz\node[color=white, left color=blue!20!white, right color=blue, draw=gray,
rounded corners, inner sep=4pt, minimum height=2cm, font=\bfseries]{%
\parbox{.8\textwidth}{\begin{Arabic}#1\end{Arabic}}};}
\newcommand*{\chaptertoc}{%
\begingroup
\etocsettocstyle{}{}
\etocsetstyle{section}{}{}
{\etocsavedsectiontocline{\hskip-.5cm\numberline{\etocnumber}\etocname}{\textcolor{white}{\etocpage}}}{}%
\etocsetstyle{subsection}{}{}
{\etocsavedsubsectiontocline{\hskip-.5cm\numberline{\etocnumber}\etocname}{\textcolor{white}{\etocpage}}}{}%
\etocsetstyle{subsubsection}{}{}
{\etocsavedsubsubsectiontocline{\hskip-.5cm\numberline{\etocnumber}\etocname}{\textcolor{white}{\etocpage}}}{}%
\tocframe{\localtableofcontents}
\endgroup}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedleft \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\hfill\huge\bfseries\color{myblue} \@chapapp\space \CircleNum{\thechapter}
\par\nobreak
\vskip 5\p@\rule{\textwidth}{1pt}\vskip 5\p@
\fi
\fi
\interlinepenalty\@M
\huge \bfseries #1\par\nobreak
\vskip 15\p@ }
\chaptertoc \vskip 10\p@}
\newcommand*{\mytableofcontents}{%
\etocstandarddisplaystyle
\etocsetstyle{part}{}{}
{\etocsavedparttocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
\etocsetstyle{chapter}{}{\addvspace{10pt}\leftskip-5pt}
{\leavevmode\chapternumberbox{\@chapapp\space\etocnumber}%
\chapternamebox{\etocname\hfill\makebox[-20pt]{\etocpage}}}{}%
\etocsetstyle{section}{}{}
{\etocsavedsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
\etocsetstyle{subsection}{}{}
{\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
\etocsetstyle{subsubsection}{}{}
{\etocsavedsubsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
\tableofcontents}
\makeatother
\renewcommand{\thesection}{\arabic{section}}
\setcounter{secnumdepth}{5}
%\setcounter{tocdepth}{5}
%-------------------------------------------------------
% REDEFINING NAMES IN ARABIC %
%-------------------------------------------------------
\gappto\captionsarabic{%
\renewcommand{\contentsname}{المحتويات}
\renewcommand{\chaptername}{الفصل}
\def\figurename{رسم}
\renewcommand{\tablename}{جدول}
\renewcommand{\indexname}{\textbf{الثبت}}
\renewcommand{\appendixname}{\textbf{الملحق}}}
%-------------------------------------------------------
\newtheorem{theo}{نظرية}[section]
\newtheorem{theorem}{مبرهنة}[section]
\newtheorem{corollary}{نتيجة}[section]
\newtheorem{definition}{تعريف}[section]
\newtheorem{prop}{قضية}[section]
\newtheorem{proposition}{لازمة}[section]
\newtheorem{lemma}{توطئة}[section]
\newtheorem{remark}{ملاحظة}[section]
\newtheorem{example}{مثال}[section]
\newtheorem{exercise}{تمرين}[section]
%\renewenvironment{proof}{{\bfseries برهان:} \par\noindent}{}
%-------------------------------------------------------
\setlength{\parindent}{0mm}
\linespread{1.5}
%-------------------------------------------------------
\begin{document}
\mytableofcontents
\chapter{مقدمة في الحساب}
\section{مدخل لعلم العدد}
\end{document}