目錄編輯

目錄編輯

這是我在網站上的第一個問題,我想讓「章節」一詞全部大寫,並在章節標題前面加上「:」。我使用了報告文檔類,目錄的唯一包是\usepackage[toc,page] 、 \usepackage[nottoc,notlof,notlot]{tocbibind} 我不知道它們是否用於修改......我真的只是一個Latex 用戶,這是我第一次嘗試寫論文

   \documentclass[12pt,a4paper]{report} 
   \usepackage{amsmath,amssymb,amsthm,amsfonts,mathrsfs} 
   \usepackage{graphicx,epsfig,subfig}                 
   \usepackage{geometry}                               
   \usepackage{setspace}                                 
   \usepackage{array}                                
   \usepackage[toc,page]{appendix}               
   \usepackage[labelfont=bf]{caption}                  
   \usepackage{xpatch}                              
   \usepackage{fmtcount}                       
   \renewcommand{\thechapter}{\NUMBERstring{chapter}} 
   \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}  
   \renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}  
   \makeatletter
   \input{fc-british.def}
   \xpatchcmd{\@chapter}% <cmd>
   {\numberline{\thechapter}}% <search>
   {\@chapapp~\thechapter\quad}% <replace>
   {}{}% <success><failure>
   \makeatother
   \newcolumntype{L}[1]{>
   {\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
   \newcolumntype{C}[1]{>
  {\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
   \newcolumntype{R}[1]{>
   {\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
    \usepackage{caption}
    \usepackage[pagestyles]{titlesec}
    \titleformat{\chapter}[display]
   {\normalfont\LARGE\bfseries\centering}
   {\centering\MakeUppercase{\chaptertitlename}\ \thechapter}{20pt}{\Large}
    \titlespacing*{\chapter}
    {0pt}{50pt}{40pt}
    \geometry{verbose,a4paper,tmargin=30mm,bmargin=25mm,
     lmargin=30mm,rmargin=25mm}
    \renewcommand{\baselinestretch}{1.65}
    \usepackage{fancyhdr}
    \usepackage{psfrag}
    \usepackage{array}
    \usepackage{booktabs}
    \usepackage{float}
    \usepackage{caption}
    \usepackage{multirow}
    \usepackage[shortlabels]{enumitem}
    \usepackage[monochrome]{xcolor}
    \usepackage{pdflscape}
    \usepackage[toc,page]{appendix}
    \usepackage{titlesec}
    \usepackage{amsmath}
    \usepackage[nottoc,notlof,notlot]{tocbibind} 
    \renewcommand\bibname{References}
    \makeatletter
    \newcommand*{\rom}[1]{\expandafter\@slowromancap\romannumeral #1@}
    \makeatother
    \setcounter{secnumdepth}{5} 
    \setcounter{tocdepth}{5}    
    \newtheorem{theorem}{Theorem}
    \newtheorem{acknowledgement}{Acknowledgement}
    \newtheorem{algorithm}{Algorithm}
    \newtheorem{axiom}{Axiom}
    \newtheorem{case}{Case}
    \newtheorem{claim}{Claim}
    \newtheorem{conclusion}{Conclusion}
    \newtheorem{condition}{Condition}
    \newtheorem{conjecture}{Conjecture}
    \newtheorem{corollary}{Corollary}
    \newtheorem{criterion}{Criterion}
    \newtheorem{definition}{Definition}
    \newtheorem{example}{Example}
    \newtheorem{exercise}{Exercise}
    \newtheorem{lemma}{Lemma}
    \newtheorem{notation}{Notation}
    \newtheorem{problem}{Problem}
    \newtheorem{proposition}{Proposition}
    \newtheorem{remark}{Remark}
    \newtheorem{solution}{Solution}
    \newtheorem{summary}{Summary}
    \numberwithin{equation}{chapter}
    \numberwithin{theorem}{chapter}
    \fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields 
    \fancyfoot[C]{\bfseries\large\thepage} % except the center
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}}

    \begin{document}

    \addcontentsline{toc}{chapter}{Contents}
    \tableofcontents 

    \chapter{General Introduction}\label{chapter:Intro} 
    \section{Introduction}
    Composite steel-concrete construction

    \end{document}  

在此輸入影像描述

答案1

我首先將您的程式碼簡化為更簡單的工作範例。儘管您顯然不想在真實文件中這樣做,但您應該修剪和組織你的序言。您多次載入包,有時使用不同的選項,並加載衝突的包或與傳遞給其他包的選項衝突的包。例如,pagestyles傳遞給titlesec將載入該套件的頁尾/頁首表兄弟。然後,那個表弟將與您競爭fancyhdr文件佈局的這方面的控制權。挑選。一個,另一個,或者都不是。但不是兩者兼具。您也可以titlesec在沒有此選項的情況下進行加載,如果您碰巧沒有遇到不會觸發錯誤的訂單,這也會產生潛在的衝突。

然後,我調整了\xpatch命令,將“章節”設定為“CHAPTER”,並在數字字後面停止。我知道您要求使用冒號,但坦白說,我認為這看起來很奇怪。但是,如果您確實喜歡(或需要使用)此格式,則可以輕鬆地將 替換.為 a 。:

\documentclass{report} 
\usepackage[toc,page]{appendix}               
\usepackage{xpatch}                              
\usepackage[british]{fmtcount}% set dialect in a standard way the package recommends                
% \usepackage[pagestyles]{titlesec}% use of pagestyles conflicts with use of fancyhdr
\usepackage{titlesec}% use of pagestyles conflicts with use of fancyhdr
\usepackage{fancyhdr}
\usepackage[nottoc,notlof,notlot]{tocbibind} 

\renewcommand{\thechapter}{\NUMBERstring{chapter}} 
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}  
\makeatletter
\xpatchcmd{\@chapter}% <cmd>
{\numberline{\thechapter}}% <search>
{\MakeUppercase{\@chapapp}~\thechapter.\quad}% <replace>% <= \MakeUppercase for the capitalisation; added . for dot
{}{}% <success><failure>
\makeatother
\titleformat{\chapter}[display]
{\normalfont\LARGE\bfseries\centering}
{\centering\MakeUppercase{\chaptertitlename}\ \thechapter}{20pt}{\Large}
\titlespacing*{\chapter}
{0pt}{50pt}{40pt}
\setcounter{tocdepth}{5}    
\fancypagestyle{plain}{%
  \fancyhf{}% clear all header and footer fields 
  \fancyfoot[C]{\bfseries\large\thepage}% except the center
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}}

\begin{document}

\addcontentsline{toc}{chapter}{Contents}
\tableofcontents 

\chapter{General Introduction}\label{chapter:Intro} 
\section{Introduction}
Composite steel-concrete construction

\end{document} 

調整了章節的目錄行

相關內容