05 LaTeX 的文檔元素

GitHub資源:https://github.com/qinnian/LaTeX

微信公衆號【欽念博客】:LaTeX 教程資源彙總(推薦)

一、章節

  • article 文檔類帶編號的層級爲 \section / \subsection / \subsubsection 三級;

  • report/book 文檔類帶編號的層級爲 \chapter / \section / \subsection 三級。

\documentclass[UTF8]{ctexart} 

\begin{document} 
	\section{第一章節}
	 
	Hello World 
	
	\subsection{小標題} 
	Hello World 
	
	\section{第二章節} 
	Hello World 

\end{document}

默認情況下,第⼀級章節標題是居中顯⽰的(注意,上圖預覽視圖的第⼀⾏是⻚眉),顯然這不符合⼤多數需要,爲此需要在導⾔區添加⼀些設置章節格式的代碼

\documentclass[UTF8]{ctexart} 
\CTEXsetup[name={第,章}]{section}
\CTEXsetup[format={\zihao{-3}\raggedright\bfseries}]{section}

\begin{document} 
	\section{第一章節}
	 
	Hello World 
	
	\subsection{小標題} 
	Hello World 
	
	\section{第二章節} 
	Hello World 

\end{document}

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-vnTsQjLb-1582895561492)(https://raw.githubusercontent.com/qinnian/FigureBed/master/20200216205325.png)]

二、目錄

在 LATEX 中生成目錄非常容易,只需在合適的地方使用命令:

\tableofcontents

這個命令會生成單獨的一章(book / report)或一節(article),標題默認爲 “Contents”。

有時我們使用了 \chapter* 或 \section* 這樣不生成目錄項的章節標題命令,而又想手動生成該章節的目錄項,可以在標題命令後面使用:

\addcontentsline{toc}{⟨level⟩}{⟨title⟩}

其中 ⟨level⟩ 爲章節層次 chapter 或 section 等,⟨title⟩ 爲出現於目錄項的章節標題。

三、標題頁

LATEX 支持生成簡單的標題頁。首先需要給定標題和作者等信息:

\title{⟨title⟩} 
\author{⟨author⟩}
\date{⟨date⟩}`

其中前兩個命令是必須的(不用 \title 會報錯;不用 \author 會警告),\date 命令可選。LATEX 還提供了一個 \today 命令自動生成當前日期,\date 默認使用 \today。在 \title\author等命令內可以使用 \thanks 命令生成標題頁的腳註,用 \and 隔開多個人名。

在信息給定後,就可以使用 \maketitle 命令生成一個簡單的標題頁了。

四、特殊環境

1、列表環境

LATEX 提供了基本的有序和無序列表環境 enumerate 和 itemize,兩者的用法很類似,都用 \item 標明每個列表項。enumerate 環境會自動對列表項編號。

其中 \item 可帶一個可選參數,將有序列表的計數或者無序列表的符號替換成自定義的符號。列表可以嵌套使用,最多嵌套四層。

\documentclass[UTF8]{ctexart} 

\begin{document} 

\begin{enumerate}
	\item An item.
	\begin{enumerate}
		\item A nested item.\label{itref}
		\item[*] A starred item.
	\end{enumerate}
	\item Reference(\ref{itref}).
\end{enumerate}

\end{document}

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-us2090mR-1582895561493)(https://raw.githubusercontent.com/qinnian/FigureBed/master/20200220145657.png)]

2、對齊環境

\centering\raggedright\raggedleft命令直接改變文字的對齊方式

\documentclass[UTF8]{ctexart} 

\begin{document} 

\centering
Centered text paragraph.

\raggedright
Left-aligned text paragraph.

\raggedleft
Right-aligned text paragraph.

\end{document}

五、圖片

LATEX 本身不支持插圖功能,需要由 graphicx 宏包輔助支持。在調用了 graphicx 宏包以後,就可以使用 \includegraphics 命令加載圖片了:

\includegraphics[⟨options⟩]{⟨filename⟩}

其中 ⟨filename⟩ 爲圖片文件名,與使用 \include 命令類似,文件名有時需要使用相對路徑或絕對路徑。圖片文件的擴展名可寫可不寫。

另外 graphicx 宏包還提供了 \graphicspath 命令,用於聲明一個或多個圖片文件存放的目錄,使用這些目錄裏的圖片時可不用寫路徑。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章