Biblatex を使用して章ごとの参考文献に番号なしの章を含める適切な方法

Biblatex を使用して章ごとの参考文献に番号なしの章を含める適切な方法

私は論文の最後に章ごとの参考文献を生成するために、ドキュメント3.11.4の例を使用biblatexしています。序論を番号なしの章にしようとするまではうまく機能していました。すると、序論が参考文献に表示されなくなりました。これが MWE です:

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}

\cite{A01}

\chapter{Chapter 1}

\cite{A01,B02}

\backmatter

\printbibheading
\bibbysegment[heading = bibintoc]

\end{document}

番号なしの「はじめに」の参照セクションを使用する回避策を見つけました。回避策の MWE は次のとおりです。

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for the \nameref{refsection:\therefsection}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}
\begin{refsection}
\cite{A01}
\end{refsection}
\chapter{Chapter 1}

\cite{A01,B02}

\backmatter

\printbibheading
\printbibliography[section=1,heading=bibintoc2]
\bibbysegment[heading = bibintoc]

\end{document}

番号なしの結論と引用を追加するまでは、これで満足していました。その後、コードが壊れてエラーbiblatexが返されますnested refsections。その場合の MWE は次のとおりです。

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for the \nameref{refsection:\therefsection}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}
\begin{refsection}
\cite{A01}
\end{refsection}
\chapter{Chapter 1}

\cite{A01,B02}

\chapter*{Conclusion}
\begin{refsection}
\cite{C03}
\end{refsection}

\backmatter

\printbibheading
\printbibliography[section=1,heading=bibintoc2]
\bibbysegment[heading = bibintoc]

\end{document}

これを解決するアイデアはありますか? あるいは、ドキュメントの\chapter*例を使用して適切に実装する方法があればもっと良いでしょうか?3.11.4biblatex

ご協力ありがとうございます!

答え1

番号のない章では\newrefsegment、 と を手動で呼び出すことができます。\citereset

\chapter*{Introduction}
\newrefsegment
\citereset

しかし、参考文献セグメントのタイトルは一貫してフォーマットできません。これを回避する方法はいくつかあります。ここでは、\chapterとの両方にパッチを適用してすべてを処理します\chapter*

\documentclass{book}
\usepackage[sorting=none,refsegment=chapter,citereset=chapter]{biblatex}
\usepackage{nameref}

\makeatletter
% Extend biblatex's \chapter patch to \chapter* and save data for titles
\def\blx@refpatch@chapter#1{%
  \ifundef\chapter
    {\blx@err@nodocdiv{chapter}}
    {\pretocmd\@makechapterhead
       {#1%
        \csdef{subbib:\therefsection\therefsegment}{%
          Chapter~\ref{refsegment:\therefsection\therefsegment}}}
       {}{\blx@err@patch{\string\@makechapterhead}}%
     \pretocmd\@makeschapterhead
       {#1%
        \csdef{subbib:\therefsection\therefsegment}{%
          \nameref{refsegment:\therefsection\therefsegment}}}
       {}{\blx@err@patch{\string\@makeschapterhead}}}}
\makeatother
\defbibheading{subbibliography}{%
  \section*{References for \csuse{subbib:\therefsection\therefsegment}}}

\addbibresource{biblatex-examples.bib}
\begin{document}
\tableofcontents
\chapter*{Introduction}
\cite{reese}
\chapter{First chapter}
\cite{companion}
\chapter*{Unnumbered chapter}
\cite{glashow,weinberg}
\chapter{Second chapter}
\cite{glashow}
\chapter*{Conclusion}
\cite{reese}
\printbibheading[heading=bibintoc]
\bibbysegment[heading=subbibliography]
\end{document}

ここに画像の説明を入力してください

このアプローチは、章ごとの参照セクションにも適用できます。

\documentclass{book}
\usepackage[sorting=none,refsection=chapter]{biblatex}
\usepackage{nameref}

\makeatletter
% Extend biblatex's \chapter patch to \chapter*, save data for titles
\def\blx@refpatch@chapter#1{%
  \ifundef\chapter
    {\blx@err@nodocdiv{chapter}}
    {\pretocmd\@makechapterhead
       {#1\csdef{subbib:\therefsection}{Chapter~\ref{refsection:\therefsection}}}
       {}{\blx@err@patch{\string\@makechapterhead}}%
     \pretocmd\@makeschapterhead
       {#1\csdef{subbib:\therefsection}{\nameref{refsection:\therefsection}}}
       {}{\blx@err@patch{\string\@makeschapterhead}}}}
\makeatother
\defbibheading{subbibliography}{\section*{References for \csuse{subbib:\therefsection}}}

\addbibresource{biblatex-examples.bib}
\begin{document}
...
\printbibheading[heading=bibintoc]
\bibbysection[heading=subbibliography]
\end{document}

答え2

\endrefsegment番号なしの「結論」章の前の最後のセグメントを手動で終了するには、を使用する必要があります。

\documentclass{book}

\usepackage[sorting = none, style = numeric, refsegment = chapter, cite reset = chapter]{bib latex}
\usepackage{nameref}

\defbibheading{bibintoc}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for Chapter \ref{refsegment:\therefsection\therefsegment} - \nameref{refsegment:\therefsection\therefsegment}}}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\bibname}%
  \section*{References for the \nameref{refsection:\therefsection}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}
\begin{refsection}
\cite{A01}
\end{refsection}
\chapter{Chapter 1}

\cite{A01,B02}

\endrefsegment

\chapter*{Conclusion}
\begin{refsection}
\cite{C03}
\end{refsection}

\backmatter

\printbibheading
\printbibliography[section=1,heading=bibintoc2]
\bibbysegment[heading = bibintoc]
\printbibliography[section=2,heading=bibintoc2]

\end{document}

ここに画像の説明を入力してください

これで当面の問題は解決しますが、refsection導入と結論に s を使用する回避策では、これらの章の参考文献ラベルが完全に独立します (結論で C. Cuthor の著作にラベル「1」が割り当てられていることに注意してください)。次の解決策はrefsegments でのみ機能します (これにより、ドキュメント全体で一意のラベルが実現されます)。

  • 星付きバージョンは使用しないで\chapter*ください\chapter また序論と結論については、 を使用します。この方法では、refsegmentこれらの章に (正の) 番号が割り当てられ、それぞれの参照を を使用して印刷できます\bibbysegment

  • \frontmatter\mainmatterおよびを使用して\backmatter、序論と結論に番号なしの章を作成します。(実際には、ローマ字のページ番号への切り替えを回避するために、\boolfalse{@mainmatter}の代わりにを使用します。)\frontmatter

  • \therefsegment前文と本文の後のそれぞれの値を格納するための新しいカウンターを宣言し、bibintoc2見出しの新しい定義でこれらのカウンターを使用して、前文/本文/後文の参照に異なる形式を実現します。


\documentclass{book}

\usepackage[sorting=none,style =numeric,refsegment=chapter,citereset=chapter]{biblatex}
\usepackage{nameref}

\newcounter{segmentendfront}
\newcounter{segmentendmain}

\defbibheading{bibintoc2}{%
  \addcontentsline{toc}{chapter}{\refname}%
  \section*{\refname\ for
    \ifnumgreater{\therefsegment}{\value{segmentendfront}}{%
      \ifnumgreater{\therefsegment}{\value{segmentendmain}}{%
        the
      }{%
        Chapter~\ref{refsegment:\therefsection\therefsegment} --
      }%
    }{%
      the
    }%
    \nameref{refsegment:\therefsection\therefsegment}%
  }%
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\boolfalse{@mainmatter}% instead of \frontmatter, which would also switch
    %to Roman page numbering

\chapter{Introduction}

\cite{A01}

\mainmatter
\setcounter{segmentendfront}{\therefsection\therefsegment}

\chapter{First chapter}

\cite{A01,B02}

\chapter{Second chapter}

\cite{B02}

\backmatter
\setcounter{segmentendmain}{\therefsection\therefsegment}

\chapter{Conclusion}

\cite{C03}

\printbibheading
\bibbysegment[heading=bibintoc2]

\end{document}

ここに画像の説明を入力してください

答え3

こうすればできると思います:

\chapter*{Introduction}
\begin{refsegment}
\cite{A01}
\end{refsegment}

編集: 結論の参照セグメントに関する問題は、2 番目の参照セグメントがあることではなく、オプション コマンドによってrefsegment=chapter(または類似のもの)\chapterが挿入され\begin{refsegment}、これが `\chapter* によって閉じられないことです。

このセグメントを結論の前で停止することもできます。

\endrefsegment

\chapter*{Conclusion}

(より良い解決策としては、パッチを適用すること\chapter*も挙げられます)。

関連情報