LoginSignup
3
2

More than 5 years have passed since last update.

BibTeX使用時に「参考文献」を目次に出力する

Last updated at Posted at 2015-01-16

LaTeX+BibTeXで文章を書いていて、「参考文献」が目次に表示されていないことに気が付きました。解決までに少しつまづいたので、経緯と解決法を書いてみます。

経緯

検索して調べた結果、 thebibliography 環境の中に

\addcontentsline{toc}{chapter}{\bibname}

を追加して、再定義してやることで対応できるようでした。そこで、使用中の jsbook で該当する箇所を見てみたところ

jsbook.cls
\newenvironment{thebibliography}[1]{%
  \global\let\presectionname\relax
  \global\let\postsectionname\relax
  \chapter*{\bibname}\@mkboth{\bibname}{}%
  \addcontentsline{toc}{chapter}{\bibname}%  <-書いてある
   \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}

問題の記述が元から書いてありました。

気を取り直して、利用していたパッケージを調べていったところ、 natbib で原因を発見します。

natbib.sty
\renewenvironment{thebibliography}[1]{%
 \bibsection\parindent \z@\bibpreamble\bibfont\list
   {\@biblabel{\arabic{NAT@ctr}}}{\@bibsetup{#1}%
    \setcounter{NAT@ctr}{0}}%
    \ifNAT@openbib
      \renewcommand\newblock{\par}
    \else
      \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}%
    \fi
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax
    \let\citeN\cite \let\shortcite\cite
    \let\citeasnoun\cite
 }{\def\@noitemerr{%
  \PackageWarning{natbib}
     {Empty `thebibliography' environment}}%
  \endlist\vskip-\lastskip}
 \let\bibfont\relax

このソースを使って、プリアンブルで thebibliography 環境を再定義することで「参考文献」を目次に表示することが出来ました。

解決法

プリアンブルの中、 \usepackage{natbib} の後ろに、

\makeatletter
\renewenvironment{thebibliography}[1]{%
 \bibsection\parindent \z@\bibpreamble\bibfont\list
   {\@biblabel{\arabic{NAT@ctr}}}{\@bibsetup{#1}%
   \addcontentsline{toc}{chapter}{\bibname}%
    \setcounter{NAT@ctr}{0}}%
    \ifNAT@openbib
      \renewcommand\newblock{\par}
    \else
      \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}%
    \fi
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax
    \let\citeN\cite \let\shortcite\cite
    \let\citeasnoun\cite
 }{\def\@noitemerr{%
  \PackageWarning{natbib}
     {Empty `thebibliography' environment}}%
  \endlist\vskip-\lastskip}
 \let\bibfont\relax
\makeatother

を書きます。

定義の中で@が登場するので、 \makeatletter\makeatother で包んでいます。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2