页面

网页浏览总次数

2011年2月21日星期一

The B to X of BibTEX 第一章 LaTeX 参考文献基础

第一章 LaTeX 参考文献基础

目录
------------------------------------
1 “thebibliography” 环境
2 \bibitem 命令
3 \cite 命令
4 一些小技巧
 4.1 \DeclareRobustCommand是什么?
 4.2 改变参考文献名称
 4.3 在第一条文献前添加文本
 4.4 重定义 \bibitem
 4.5 将方括号改委圆括号
 4.6 其它。。。
 4.7 $符号可以在内部键中用吗?
------------------------------------

BibTEX以及LaTeX中有关参考文献的命令常常被认为很神奇。很多人拷贝一些

经典的例子而不加以思考去理解它们究竟是怎么工作的。实际上,LaTeX中的

参考文献就只是一个列了一些参考文献条目的文档罢了。如果不知道“thebibliography”
环境,而不得不顺手用一下的话。就像下面这样用:
This is the main matter of the document, mentioning


This is the main matter of the document, mentioning
[\ref{doc1}] and [\ref{doc2}], for instance.
\section*{References}
\begin{enumerate}
\renewcommand\labelenumi{[\theenumi]} %% numbers are surrounded with brackets
\item \label{doc1} Michel Goossens, Franck Mittelbach and Alexander
Samarin, \emph{The \LaTeX{} Companion}, Addison Wesley, 1993.
\item \label{doc2} Leslie Lamport, \emph{\LaTeX: A Document Preparation
System}, Addison Wesley, 1997.
\end{enumerate}



经过编译,结果输出为:

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
This is the main matter of the document, mentioning [1] and [2], for instance.


References
[1] Michel Goossens, Franck Mittelbach and Alexander Samarin, The LATEX Companion, 
    Addison Wesley, 1993.
[2] Leslie Lamport, LATEX: A Document Preparation System, Addison Wesley, 1997.
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



“thebibilography”环境大概就是这个样子(它从一个list环境开始,类似于计数enumerate),\bibitem对应于\item命令。主要不同在于,相对于命令\item和\label来说,\bibitem允许更多的一般的交叉索引(例如,可以引用[GSM93])。
这一部分主要任务就是“不用BibTEX编写参考文献目录。”这个不是本文主要目标,但是却是理解后文的奠基石。

1 “thebibilography”环境
“thebibilography”环境不是LaTeX本身定义(当然也不是TeX所定义1)。它需要文档中的类文件来定义(例如:article.cls或book.cls)。如前所述,它是一个新的\section下(或者是\chapter,这基于不同文档类别)的list类环境。必须稳妥的建立这个list,以便避免缩排的问题的产生。比如,如果我们讲“alphanumerical”标签放在上文的例子中。就会得到:

为了避免这个问题,thebibliography 有一个强制变量,它是list中最大标签。这将使得页面排列比较合理。
下面让我们看看如何精确定义thebibliography(就想定义article.cls类一样):
1 newenvironment{thebibliography}[1]
2      {\section*{\rfname
3          \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}}%
  As mentioned earlier, thebibliography starts a new section3. The environment also the pageheaders4.
4        \list{\@biblabel{@arabi\c@enumiv}}%
5             {\settowwidth\labelwidth{\@biblabel{#1}}%
这没什么可吃惊的,我们开启了一个新的list环境5。 它有两个强制变量:

第一个(\@biblabel{...})定义主要命令格式以产生标签。这里它带有枚举计数,使用\@biblabel6。这样就会有[1],[2],...既然\bibitem是\item的一种,它就有可选参数用于修正主要标签;

第二个变量(上文第5行到下文第11行)是个命令集,运行在环境最开始处。它们设定list环境的不同长度值以及参数。我们用这个(thebibliography环境中设定的)最长的标签去识别整个list。有人常常写为\begin{thebibliograpphy}{99},但是这仅在参考文献数量在10到99之间时是正确的(假定所有字符长度相同,即用cmr字体)。

下面关于thebliography的定义包含list环境以及枚举计数的一些边界定义:

\@openbib@code,默认是空白,以允许必要时修正一些惨呼。典可选的openbib格式文件使用这个命令重设一些参数。第九行设定了行数。

最后,在参考文献中,使用了空格格式以及一些特殊penaties(咋翻译呢?)


这是这个环境的起始项。Thebibliography的结束则相对容易。没有参考文献的话,仅仅回应个警告即可。这样这个list环境就结束了。



2 \bibitem命令
上面的list环境中,我们必须插入命令\items。这是一个特殊的\item,这样可以正确的解释每一个bibilography项目。合乎需要的命令即是\bibitem,它有下面两个任务:在list中引入新的条目,同时定义该条目被引用时的使用的交叉项,通常的格式是\@biblabel{@arabic\c@enumiv}。结果显示为[1],当然也可以修改成这种形式。即[GMS94],即使用一个可选参数,同\item一样。下面是\bibitem的精确定义。
如果有可选参数则\bibitem变成\@lbibitem,不然就是\@bibitem。这些辅助命令的定义如下


下面我们举个小例子看看这个命令是怎么作用的:比方我们  Page5 





注释
-------------------------------------------------------------------------------------------------------------
1BibTEX may be used with plain TEX, you’ll simply have to input the btxmac.tex package
2This is the reason why thebibliography has to be defined in the class files. The other bibliographic commands are
defined in the standard LATEX format.
3It is in fact a \section*, so that it won’t appear in the table of contents. In order to cleanly insert the bibliography
in your table of contents, use the tocbibind.sty package. Other methods you can think of will probably lead to wrong
page numbers.
4The standard apalike.sty package hard-codes the headers to “REFERENCES” or “BIBLIOGRAPHY”, depending
on the class file. But another package (with the same name, unfortunately) correctly sets the headers to \refname or
\bibname. Simply check in the sources if you have problems for redefining the headers with that package.
5The \list command is equivalent to a \begin{list}, and has to be followed with a \endlist.
6\@biblabel is defined in LATEX. It outputs its argument surrounded with brackets. The precise definition is:
\def\@biblabel#1{[#1]}.

没有评论:

发表评论