![Biblatex を使用して章ごとの参考文献に番号なしの章を含める適切な方法](https://rvso.com/image/254690/Biblatex%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E7%AB%A0%E3%81%94%E3%81%A8%E3%81%AE%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE%E3%81%AB%E7%95%AA%E5%8F%B7%E3%81%AA%E3%81%97%E3%81%AE%E7%AB%A0%E3%82%92%E5%90%AB%E3%82%81%E3%82%8B%E9%81%A9%E5%88%87%E3%81%AA%E6%96%B9%E6%B3%95.png)
私は論文の最後に章ごとの参考文献を生成するために、ドキュメント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.4
biblatex
ご協力ありがとうございます!
答え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」が割り当てられていることに注意してください)。次の解決策はrefsegment
s でのみ機能します (これにより、ドキュメント全体で一意のラベルが実現されます)。
星付きバージョンは使用しないで
\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*
も挙げられます)。