Bibtex 內部結構

Bibtex 內部結構

我想修改我的 bibtex 標題,這可以透過修改 \bibname 來完成。但是,當談到減少標題「參考書目」和下面的條目之間的空間量時,我想知道首先要放多少空間。

更一般地說,我很好奇 bibtex 的內部結構是如何運作的。我似乎找不到任何關於此的文檔。所以我的問題是:

  1. 在哪裡可以找到有關 bibtex 如何格式化參考書目頁面的資訊?
  2. 更具體地說,是什麼決定了標題和下面條目之間的間距?

答案1

BibTeX 的輸出是.bbl一個包含thebibliography環境的檔案。定義這個環境是文檔類別的職責。

通常是這樣的

\section*{\refname}
\begin{list}{<code>}
<bib items>
\end{list}

對於沒有章節的課程和

\chapter*{\bibname}
\begin{list}{<code>}
<bib items>
\end{list}

這可能會根據加載的包而有所不同;例如natbib對此進行幹預,但它使用的\bibsection巨集本質上相當於上述情況下的\section*或。\chapter*

texdef您可以從命令列找到定義。例如,命令列

texdef -t latex -c article -s thebibliography

將輸出

% article.cls, line 570:
\newenvironment{thebibliography}[1]
     {\section*{\refname}%
      \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}

修改它需要\makeatletter\makeatother.

請注意,在使用 case(或其他包,可能)的情況下可能很難追蹤實際定義natbib,因為它在開始文件中重新定義了環境。然而,查看包代碼就會發現

\renewenvironment{thebibliography}[1]{%
 \bibsection
 \parindent\z@
 \bibpreamble
 \bibfont
 \list{\@biblabel{\the\c@NAT@ctr}}{\@bibsetup{#1}\global\c@NAT@ctr\z@}%
 \ifNAT@openbib
   \renewcommand\newblock{\par}%
 \else
   \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}%
 \fi
 \sloppy\clubpenalty4000\widowpenalty4000
 \sfcode`\.\@m
 \let\NAT@bibitem@first@sw\@firstoftwo
    \let\citeN\cite \let\shortcite\cite
    \let\citeasnoun\cite
}{%
 \bibitem@fin
 \bibpostamble
 \def\@noitemerr{%
  \PackageWarning{natbib}{Empty `thebibliography' environment}%
 }%
 \endlist
 \bibcleanup
}%

在這兩種情況下,更改標題和第一項之間的間距只是\vspace在 之前插入適當的命令\list

相關內容