![Maneira correta de incluir capítulos não numerados em uma bibliografia por capítulo usando biblatex](https://rvso.com/image/254690/Maneira%20correta%20de%20incluir%20cap%C3%ADtulos%20n%C3%A3o%20numerados%20em%20uma%20bibliografia%20por%20cap%C3%ADtulo%20usando%20biblatex.png)
Tenho usado exemplos 3.11.4
de biblatex
documentação para gerar uma bibliografia por capítulo no final da minha tese. Funciona muito bem, até que tento fazer minha introdução em um capítulo sem número. Então, a introdução não aparece na bibliografia. Aqui está um 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}
Encontrei uma solução alternativa, usando uma seção de referência para a introdução não numerada. Aqui está um MWE da solução alternativa:
\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}
Fiquei satisfeito com isso até adicionar uma conclusão sem número com citações. Então o código quebra e biblatex
retorna um nested refsections
erro. Aqui está o MWE para isso:
\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}
Alguma idéia de como resolver isso? Ou, melhor ainda, como implementar corretamente \chapter*
com o exemplo 3.11.4
do biblatex
documento?
Obrigado antecipadamente pela ajuda!
Responder1
Você pode invocar \newrefsegment
e \citereset
manualmente nos capítulos não numerados:
\chapter*{Introduction}
\newrefsegment
\citereset
mas os títulos dos segmentos bibliográficos não podem ser formatados de forma consistente. Existem várias maneiras de contornar isso. Aqui tratamos de tudo com patches para ambos \chapter
e \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}
Essa abordagem também funciona para seções de referência por capítulo.
\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}
Responder2
Você deve usar \endrefsegment
para finalizar manualmente o último segmento antes do capítulo "Conclusão" não numerado.
\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}
Embora isso resolva seu problema imediato, sua solução alternativa de usar refsection
s para a Introdução e a Conclusão resulta em rótulos bibliográficos completamente independentes para esses capítulos (observe como o trabalho de C. Cuthor recebe o rótulo "1" na Conclusão). A solução a seguir funciona apenas com refsegment
s (e obtém rótulos exclusivos para todo o documento):
Não use a versão com estrela
\chapter*
, mas\chapter
tambémpara a Introdução e Conclusão. Desta forma,refsegment
será atribuído um número (positivo) a estes capítulos, e suas respectivas referências poderão ser impressas utilizando\bibbysegment
.Use
\frontmatter
,\mainmatter
e\backmatter
para tornar os capítulos de Introdução e Conclusão não numerados. (Na verdade, use\boolfalse{@mainmatter}
em vez de\frontmatter
para evitar a mudança para numeração de páginas romana.)Declare novos contadores para armazenar o valor
\therefsegment
após o front- resp. o assunto principal e use esses contadores em uma nova definição dobibintoc2
título para obter o formato diferente para referências de front-/main-/backmatter.
\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}
Responder3
Eu acho que você pode fazer isso:
\chapter*{Introduction}
\begin{refsegment}
\cite{A01}
\end{refsegment}
Editar: O problema com o refsegment para a conclusão não é que exista um segundo refsegment, mas que com a opção refsegment=chapter
a \chapter
comando insere um \begin{refsegment}
(ou algo analógico) e isso não é fechado pelo `\chapter*.
Você poderia parar este segmento antes da conclusão:
\endrefsegment
\chapter*{Conclusion}
(Uma solução melhor seria corrigir \chapter*
também).