1.titleformat宏包命令詳解
LaTeX中可以用titlesec宏包中的titleformat命令來改變標題形式:
導入宏包:
\usepackage{titlesec}
改變標題的代碼如下:
\titleformat{command}[shape]{format}{label}{sep}{before}[after]
不要看暈了,改變章節號的形式,主要修改label參數
各個參數含義如下:
command 是要重新定義的各種標題命令,比如 \part,\chapter,\section,\s section,\s s section,\paragraph,\subparagraph等;
shape 是用來設定段落形狀的,可選的參數有hang、block、display等,詳見 titlesec 文檔;
format 用於定義標題外觀,比如使標題居中、字體加粗等;
label 用於定義定義標題的標簽,就是標題內容前面的標號;
sep 定義標題的標簽與標題內容之間的間隔距離;
before 用於在標題內容前再加些內容;
after 用於在標題內容后再加些內容。
舉個例子
\titleformat{\chapter}{\centering\Huge\bfseries}{第\,\thechapter\,章}{1em}{}
format參數將章標題設置為居中(\centering)顯示、字號為 \Huge,字體被加粗顯示\bfseries ; label 參數將標題的標簽設置為 “第 xxx 章”格式;sep 參數設置標簽與標題內容之間以一個字(1em)的寬度為間隔。
以上設置的章標題效果如下圖所示:
2.修改編號的方法
剛才我們已經知道,編號的樣式可以由label參數修改。
現在進一步講,怎樣把章節編號修改成下面那樣:
其他的編號形式如下:
\arabic (1, 2, 3, ...) \alph (a, b, c, ...) \Alph (A, B, C, ...) \roman (i, ii, iii, ...) \Roman (I, II, III, ...) \fnsymbol (∗, †, ‡, §, ¶, ...)
其實,默認的編號\thesubsection有點類似下面的代碼:
\renewcommand\thesection{\arabic{section}} \renewcommand\thesubsection{\thesection.\arabic{subsection}}
也就是說1.1這樣的編號相當於把label修改成\arabic{section}.\arabic{subsection}
如果我們要把標題的編號改成圖中的形式,就可以這么寫:
\titleformat{\section}[block]{\LARGE\bfseries}{第 \arabic{section} 章}{1em}{} \titleformat{\subsection}[block]{\Large\bfseries}{ \Roman{subsection}}{1em}{} \titleformat{\subsubsection}[block]{\large\bfseries}{\Roman{subsection}-\alph{subsubsection}}{1em}{} \titleformat{\paragraph}[block]{\normalsize\bfseries}{[\arabic{paragraph}]}{1em}{}
溫馨提示,章節號從paragraph開始就沒有記了
可以用以下命令設置計數層次
\setcounter{secnumdepth}{數字}
比如想讓paragraph計數,就設置為
\setcounter{secnumdepth}{4}
參考連接:
LaTex中titlesec宏包的使用:http://www.cnblogs.com/aoublog/p/4430313.html
paragraph如何讓標題后內容換行:http://bbs.ctex.org/forum.php?mod=viewthread&tid=48274