章節的「字面」和數字編號

章節的「字面」和數字編號

我問與此相關的另一個問題 章節的「字面」編號,但內容不編號 這不是「精確」......這個問題是準確的,有一個例子......

這個例子在章節的第一頁給了我章節“一”和“二”(這就是我想要的),以及內容“1”和“二”(這不是我想要的..) 。我想在文本中獲得相同的東西,但是在內容中,“1”和“2”..然後如何將章節標題更改為數字..我希望第1節的“1.1”而不是“一” .1 " 就像我的例子。

我編寫了所有的包來防止最終的衝突,因為我在我的書中使用了所有這些包(阿拉伯語的機率)...

    \documentclass[14pt,a4paper]{extbook}%{article}%

    \usepackage{titletoc}
    \usepackage{etoolbox}
    \usepackage{multicol}
    \usepackage{amsmath,amssymb}
    \usepackage[most]{tcolorbox}
    \usepackage{boxedminipage}
    \usepackage{slashbox}
    \usepackage{titlesec}
    \usepackage{enumitem}
    \usepackage{minitoc}
    \usepackage{rotating}
    \usepackage{fmultico}
    \setlength{\columnseprule}{0.1pt}
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \usepackage{pdflscape}
    \usepackage{array}

    \usepackage{polyglossia}
    \setmainlanguage{english}
    \setotherlanguage[numerals=maghrib]{arabic}

    \makeatletter
    \let\old@makechapterhead\@makechapterhead
    \def\@makechapterhead{\def\thechapter{\words{chapter}}\old@makechapterhead}
    \makeatother

    \newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
    \def\xwords#1{\ifcase#1\or
    one\or          
    two\or          
    three\or            
        \else
        I need more words\fi}


    \begin{document}
    \tableofcontents
    \chapter{Simulation}
    \section{Introduction 1} 
    Simulation
    \section{Introduction 2} 
    \chapter{Simulation}
      Simulation
     \end{document}

答案1

\thechapter而不是修改所使用的宏裡面\@makechapterhead,人們可以\@makechapterhead直接修補以使其使用,\words{chapter}而不是\thechapter在排版章節「編號」的表示時。 (修補可以透過\patchcmd指令完成。因為看起來您正在加載電子工具箱無論如何,您都可以存取\patchcmd。 )透過不觸及 的定義\thechapter,不會導致下游複雜性導致使用\thechapter,例如建立目錄。

總結一下,我建議不要

\makeatletter
\let\old@makechapterhead\@makechapterhead
\def\@makechapterhead{\def\thechapter{\words{chapter}}\old@makechapterhead}
\makeatother

你執行

% \usepackage{etoolbox} %% uncomment if 'etoolbox' isn't already being loaded
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother

在旁邊:為了讓您的程式碼在我的系統(MacOSX 10.9.2,TeXLive2104/pre,所有軟體包都是最新的)上編譯,我必須註解掉\usepackage{titletoc}您序言中的指令。看起來像是嘗試直接或透過輔助包titletoc載入該套件。inputenc在 XeLaTeX 下編譯文件時(這裡似乎是這種情況,因為您也在載入polyglossiainputenc套件應該不是被加載。 XeLaTeX(就此而言,LuaLaTeX 也是如此)只能處理一種輸入編碼系統:UTF8。我認為直到最近,如果您(或您指定的套件之一)加載了,只會發出警告訊息inputenc;使用 TeXLive 的最新更新會產生徹底的錯誤訊息並且編譯掛起。我們都希望該titletoc軟體包能夠盡快升級,不再加載inputenc(尤其是在 XeLaTeX 或 LuaLaTeX 下運行時)。

相關內容