LaTeX/腳註和邊注
腳註是提供額外資訊給讀者的一種非常有用的方式。通常,它是次要資訊,可以放在頁面底部。這使正文保持簡潔。
腳註功能易於使用。您需要的命令是:\footnote{文字}。在命令和您希望腳註標記出現的單詞之間不要留空格,否則 LaTeX 會處理該空格,並且輸出結果不會像預期的那樣。
Creating a footnote is easy.\footnote{An example footnote.}
|
LaTeX 顯然會處理頁面底部的腳註排版。每個腳註按順序編號 - 就像您現在應該猜到的那樣,此過程會自動為您完成。
如果您希望腳註位於頁面底部(而不是預設的“貼上”在文字下方的位置),請考慮使用
\usepackage[bottom]{footmisc}
|
您也可以選擇手動放置腳註文字。在這種情況下,我們使用 \footnotemark-\footnotetext 組合
\footnotemark
% ...
Somewhere else\footnotetext{This is my footnote!}
|
腳註編號也可以明確指定。
\footnotemark[17]
% ...
Somewhere else\footnotetext[17]{This is my footnote!}
|
- 列舉/計數器樣式
可以自定義腳註標記。預設情況下,它們按順序編號(阿拉伯數字)。但是,在這一點上,無需過多地深入瞭解 LaTeX 的機制,可以使用以下命令來更改它(該命令需要放在文件開頭,或者至少在發出第一個腳註命令之前)。
\renewcommand{\thefootnote}{\arabic{footnote}}
|
阿拉伯數字,例如,1、2、3… |
\renewcommand{\thefootnote}{\roman{footnote}}
|
羅馬數字(小寫),例如,i、ii、iii… |
\renewcommand{\thefootnote}{\Roman{footnote}}
|
羅馬數字(大寫),例如,I、II、III… |
\renewcommand{\thefootnote}{\alph{footnote}}
|
字母(小寫),例如,a、b、c… |
\renewcommand{\thefootnote}{\Alph{footnote}}
|
字母(大寫),例如,A、B、C… |
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
|
一系列九個符號,試試看! |
要建立沒有編號標記的腳註,請使用此宣告
\let\thefootnote\relax\footnote{There is no number in this footnote}
|
這樣,編號在全域性範圍內被關閉。要只有一個沒有編號標記的腳註,上述命令必須放在 {} 內。但是,在這種情況下,當前腳註計數器仍然遞增,因此例如您將得到腳註 1、未編號和 3。一個更好的解決方案[1] 是在序言中定義以下宏,並使用它
\makeatletter
\def\blfootnote{\xdef\@thefnmark{}\@footnotetext}
\makeatother
|
footmisc 包提供了許多自定義腳註外觀的可能性。例如,它可用於在腳註中使用不同的字型。
- 每個部分
\makeatletter
\@addtoreset{footnote}{section}
\makeatother
|
- 每一頁
(這可能需要執行兩次 LaTeX)
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
|
可以透過在腳註末尾放置 \label{標籤名稱} 並使用 \ref{標籤名稱} 來引用腳註來完成。
- 腳註不適用於表格,因為它被認為是不好的做法。您可以透過多種技術克服此限制:您可以在表格中使用
\footnotemark[123],並在頁面上的某個位置使用\footnotetext[123]{HelloWorld!}。引用也是如此:在頁面上的某個位置使用\footnote{HelloWorld!\label{fnote}},並在表格中使用\textsuperscript{\ref{fnote}}。或者,您可以將\usepackage{footnotehyper}和\makesavenoteenv{tabular}新增到序言中,並將您的 table 環境放在\begin{savenotes}環境中。後者不適用於 color 或 colortbl 包。有關其他方法(例如使用 threeparttable 的 tablenotes),請參閱 此常見問題解答頁面。
- 腳註也不適用於 minipage 環境。(實際上,幾個環境會破壞腳註支援。
\makesavenoteenv{環境名稱}命令腳註包可能會修復大多數。)minipage 包含它自己的腳註,獨立於文件的腳註。 mpfnmark 包允許更靈活地管理這兩組腳註。
- 如果腳註中的文字是URL(使用
\url或\href命令)並且包含特殊字元,則無法編譯。您必須使用前導反斜槓跳脫字元,或使用其他命令。
- 如果腳註中的文字很長,LaTeX 可能會將腳註拆分到多個頁面上。您可以透過增加此類操作的懲罰來阻止 LaTeX 執行此操作。為此,請將以下行插入文件的序言中
\interfootnotelinepenalty=10000
|
或在腳註命令後設置 \samepage
\footnote{ \samepage 腳註文字如下 }
- 要對同一腳註進行多次引用,您可以使用以下語法
Text that has a footnote\footnote{This is the footnote} looks like this. Later text referring to the same footnote\footnotemark[\value{footnote}] uses the other command.
|
如果您需要 hyperref 支援,請改用
Text that has a footnote\footnote{This is the footnote}\addtocounter{footnote}{-1}\addtocounter{Hfootnote}{-1} looks like this. Later text referring to the same footnote\footnotemark uses the other command.
|
如果在第一個引用和後續的“重複”引用之間存在其他腳註,則這些方法將不起作用。有關更通用的解決方案,請參閱此處和此處。
- 如果打算將腳註新增到章節標題、節標題或類似內容中,可以使用兩種方法。
- 編寫
\section[title] {title\footnote{I'm a footnote referred to the section} },其中title 是節的標題。 - 使用footmisc 包,並使用包選項stable,然後只需將腳註新增到節標題即可。

邊注在編輯過程中非常有用,作者之間可以互相交流意見。要插入邊注,請使用\marginpar{margin text}。對於單面佈局(單面),文字將放置在右側邊距,從定義它的行開始。對於雙面佈局(雙面),它將放置在外邊距,對於雙欄佈局,它將放置在最近的邊距。
要交換預設邊,請使用\reversemarginpar,然後邊注將放置在另一側,對於雙面佈局,這將是內邊距。
如果您的 marginpar 的文字取決於它放置在哪個邊距(例如,它包含指向文字的箭頭或引用方向,如“如左側所示...”),您可以使用\marginpar[left text]{right text} 來指定變體。
要在 \marginpar 無法處理的區域(例如腳註或公式環境)中插入邊注,請使用marginnote包。
另一個以花哨的方式新增彩色邊注的選項是使用todonotes 包,透過使用\todo{todo note}。它使用pgf 包,該包用於設計和繪製,並擁有龐大的工具資料庫。
如果本機\marginpar 命令無法滿足您的需求,則可以使用mparhack 和marginnote 包。

marginnote 和 geometry 包可以如下設定邊距和邊注的寬度。
在序言中插入
\usepackage{marginnote}
|
並使用 geometry 包設定自定義大小
\usepackage[top=Bcm, bottom=Hcm, outer=Ccm, inner=Acm, heightrounded, marginparwidth=Ecm, marginparsep=Dcm]{geometry}
|
其中 A、B、C、D、E、F、G、H 都是以釐米為單位的數字(當然可以使用釐米以外的其他單位)。
在正文中,根據以下內容使用 marginnote 包
\marginnote{typeset text here...}[Fcm]
|
具體來說,
- marginparwidth (E) 是邊注的寬度,
- marginparsep (D) 是段落和邊注之間的間距,
- F 是從編寫邊注的第一行開始的向下垂直偏移量(F 的負值將邊注向上移動),以及
- 值G = C − (D + E) 是邊注邊緣和邊緣之間的間距。
右側的示例由以下內容排版
\documentclass[a4paper,twoside,english]{article}
\usepackage{lmodern}
\renewcommand{\sfdefault}{lmss}
\usepackage[T1]{fontenc}
\makeatletter
\special{papersize=\the\paperwidth,\the\paperheight}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage[top=1.5cm, bottom=1.5cm, outer=5cm, inner=2cm, heightrounded, marginparwidth=2.5cm, marginparsep=2cm]{geometry}
\makeatother
\usepackage{babel}
\begin{document}
\section{Margin notes}
\marginnote{This is a margin note using the geometry package, set at 0cm vertical offset to the first line it is typeset.}[0cm]
\marginnote{This is a margin note using the geometry package, set at 5cm vertical offset to the first line it is typeset.}[5cm]
\lipsum[1-10]
\end{document}
|
此外,可以使用\marginparpush調整邊注之間的最小垂直間隙,例如使用\setlength{\marginparpush}{0pt}。
- ↑ "LaTeX 腳註". 檢索於 2016-01-14.
此頁面使用 Andy Roberts 的LaTeX 入門中的材料,經作者許可。

