格式調整
\section{格式調整}
\subsection{各種長度單位}
字體使用
\subsection{字體使用}
在LaTeX中,一個字體有5種屬性:編碼(encoding)、族名(family),系列(series)、形狀(shape)和大小(size)。
字體編碼
\subsubsection{字體編碼}
字體的編碼根據其中包含的字符種類以及各字符的編號來劃分。常見的正文字體的編碼有 OT1、T1 和 EU1 等,而數學字體的編碼有 OML、OMS 和 OMX 等。
字體族名
\subsubsection{字體族名}
字體的族名有許多種,一般把它們分爲三大類:
\begin{itemize}
\item 羅馬字體:又稱襯線字體,字符筆畫的起始處有裝飾;例如 cmr、ecr 和 lmr 字體。
\item 無襯線字體:又稱等線字體,字符筆畫的起始處無裝飾;例如 cmss、ecss 和 lmss 字體。
\item 打字機字體:又稱等寬字體,每個字符的寬度都相同;例如 cmtt、ectt 和 lmtt 字體。
\end{itemize}
我們可以用下面的命令方式來改變字體的族名:
\noindent \textrm{Roman Family} \\
\textsf{Sans Serif Family} \\
\texttt{Typewriter Family}
或者用下面的聲明方式來改變字體的族名:
\noindent {\rmfamily Roman Family} \\
{\sffamily Sans Serif Family} \\
{\ttfamily Typewriter Family}
字體系列
\subsubsection{字體系列}
字體系列根據字體的粗細和寬度來劃分。經常用到的如下這兩種( 正常和粗體):
\noindent \textmd{Medium Series} \\
\textbf{Boldface Series} \\
\\
{\mdseries Medium Series} \\
{\bfseries Boldface Series}
\subsubsection{字體形狀}
字體形狀主要有這些:直立,斜體,僞斜體和小型大寫。可以用下面的命令或聲明來改變:
\noindent \textup{Upright Shape} \\
\textit{Italic Shape} \\
\textsl{Slanted Shape} \\
\textsc{Small Caps Shape} \\
\\
{\upshape Upright Shape} \\
{\itshape Italic Shape}\\
{\slshape Slanted Shape} \\
{\scshape Small Caps Shape}
對字體的族名、系列和形狀這三種樣式作了修改之後,可以用 \textnormal
命令或者 \normalfont
聲明來使用默認字體樣式。例如:
\noindent \textit{\textbf{\textsf{Fancy Text}}}\\
\textnormal{Normal Text} \\
\\
{\itshape\bfseries\sffamily Fancy Text}\\
{\normalfont Normal Text}\\
字體大小
\subsubsection{字體大小}
在 LaTeX 中可以用各種命令來改變文本字體的大小,它的實際大小和文檔類的正常字體大小(即 \normalsize
的大小)設置有關,詳細情形下表
段落對齊
居中對齊
\subsection{段落對齊}
\subsubsection{居中對齊}
在 LaTeX 中,可以用 \verb||center 環境得到居中的文本段落,其中可以用雙斜槓換行。例如:
\noindent This is the first normal paragraph. This is the first normal paragraph.
\begin{center}
Hi, the center. Hi, the center. Hi, the center. \\
Hi, the center. Hi, the center. Hi, the center.
\end{center}
This is another normal paragraph. This is another normal paragraph.
如果居中段落在一行放不下,只會在最後一行是居中的,其它行都填滿頁面寬度。在一個環境內部,也可以用命令 centering來使得後面的文本都居中放置。
單側對齊
\subsubsection{單側對齊}
類似地,可以用 \verb||flushleft 和 \verb||flushright 環境分別得到向左對齊和向右對齊的文本段落。例如:
\noindent This is the first normal paragraph. This is the first normal paragraph.
\begin{flushleft}
Hi, the left. Hi, the left. Hi, the left. Hi, the left. \\
Hi, the left. Hi, the left. Hi, the left. Hi, the left.
\end{flushleft}
\begin{flushright}
Hi, the right. Hi, the right. Hi, the right. Hi, the right. \\
Hi, the right. Hi, the right. Hi, the right. Hi, the right.
\end{flushright}
This is another normal paragraph. This is another normal paragraph.
同樣地,在環境內部也可以分別用\raggedleft
和\raggedright
聲明達到
\flushleft
和 \flushright
的效果。
頁面大小布局
\subsection{頁面大小布局}
前面已經說明,直接在文檔類中設定頁面大小時,紙張大小不會隨着變化。
因此我們推薦用 geometry 宏包來設定頁面大小,比如 B5 頁面大小是這樣設置的:
\usepackage[b5paper]{geometry}
接着我們來說說如何定製頁面的佈局,比如正文區域的寬度和高度,和各個邊距的大小。LATEX 中提供了各種命令來定製頁面佈局,但是非常難用。
因此,我們同樣推薦用 geometry 宏包來調整頁面佈局。例如本文的頁面佈局就是用如下的代碼設定的:
\usepackage[b5paper,text={125mm,195mm},centering]{geometry}
如果你想直觀地觀察設置好的頁面佈局,可以在 geometry 宏包的選項中再加上 showframe 一項。這樣 geometry 宏包將在文檔的第一頁畫出頁面的佈局。
目錄頁格式
\subsection{目錄頁格式}
要調整章節標題在目錄頁中的格式,可以用 titletoc 宏包。該宏包的基本
命令參數如下:
\titlecontents{標題層次}[左間距]{整體格式}{標題序號}{標題內容}{指引線和頁碼}[下間距]
其中“標題層次”參數可以取爲 part、chapter、section 等標題名以及 figure和 table 浮動圖表名。“左間距”指的是“標題內容與頁芯左側的距離。因爲“標題序號”一般在“標題內容”的左側,所以除非標題居中放置或者標題無序號,“左間距”一般需要取大於 0 的值。實際上,該參數總是不可省略的。
我們通過例子來看看其它參數的使用。比如我們要將章(chapter)標題用大號粗體居中放置,同時要保留序號,則可以用下面的命令達到:
\titlecontents{chapter}
[0em]
{\filcenter\Large\bfseries}
{\contentslabel{3em}}
{}
{}
其中“標題序號”參數的 \contentslabel
命令指代該部分的序號內容,如果不寫上就沒有序號。
而後面的 3em 表示“標題序號”左側和“標題內容”左側的距離,這個長度值一般要大於 0,否則兩者就重合了。
接下來看看,假如我們需要將節(section)標題去掉序號,在離頁芯左側4em 處對齊,並且用居中的點(\cdot
)來畫出指引線,可以用下面的命令達到:
\titlecontents{section}
[4em]
{}
{}
{}
{\titlerule*[1em]{$\cdot$}\contentspage}
其中 \titlerule*
命令用於畫指引線,1em 表明指引線的各個點的距離。而 \contentpage
命令表示頁碼。
如果用 ctex 宏包來撰寫中文文檔,需要先載入 titletoc 宏包在載入 ctex 宏包,否則中文設置將會覆蓋掉。正確的例子如下:
\documentclass{article}
\usepackage{titletoc}
\usepackage{ctexcap}
\begin{document}
...
\end{document}