Я использовал пример 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}
Я нашел обходной путь, используя refsection для ненумерованного Introduction. Вот 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}
Редактировать: Проблема с refsegment для заключения заключается не в том, что есть второй refsegment, а в том, что с опцией refsegment=chapter
a \chapter
команда вставляет \begin{refsegment}
(или что-то аналогичное), и это не закрывается `\chapter*.
Вы можете остановить этот сегмент до заключения:
\endrefsegment
\chapter*{Conclusion}
(Лучшим решением было бы \chapter*
также установить патч).