![Forma correcta de incluir capítulos no numerados en una bibliografía por capítulo usando biblatex](https://rvso.com/image/254690/Forma%20correcta%20de%20incluir%20cap%C3%ADtulos%20no%20numerados%20en%20una%20bibliograf%C3%ADa%20por%20cap%C3%ADtulo%20usando%20biblatex.png)
He estado usando ejemplos 3.11.4
de la biblatex
documentación para generar una bibliografía por capítulo al final de mi tesis. Funciona muy bien, hasta que intento hacer mi introducción en un capítulo sin numerar. Entonces, la introducción no aparece en la bibliografía. Aquí hay un 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}
Encontré una solución alternativa utilizando una sección de referencia para la Introducción sin numerar. Aquí hay un MWE de la solución 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}
Estaba contento con esto hasta que agregué una Conclusión sin numerar con citas. Luego, el código se descompone y biblatex
devuelve un nested refsections
error. Aquí está el MWE para eso:
\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}
¿Alguna idea de como resolver esto? O, mejor aún, ¿cómo implementarlo correctamente \chapter*
con el ejemplo 3.11.4
del biblatex
documento?
¡Gracias de antemano por la ayuda!
Respuesta1
Puedes invocar \newrefsegment
y \citereset
manualmente en los capítulos no numerados:
\chapter*{Introduction}
\newrefsegment
\citereset
pero los títulos de los segmentos de bibliografía no se pueden formatear de forma coherente. Hay varias formas de solucionar esto. Aquí manejamos todo con parches tanto para como \chapter
para \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}
Este enfoque también funciona para secciones de referencia 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}
Respuesta2
Debe utilizar \endrefsegment
para terminar manualmente el último segmento antes del capítulo "Conclusión" sin numerar.
\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}
Si bien esto resuelve su problema inmediato, su solución alternativa de usar refsection
s para la Introducción y la Conclusión da como resultado etiquetas de bibliografía completamente independientes para estos capítulos (observe cómo al trabajo de C. Cuthor se le asigna la etiqueta "1" en la Conclusión). La siguiente solución funciona solo con refsegment
s (y de este modo logra etiquetas únicas para todo el documento):
No uses la versión destacada
\chapter*
pero\chapter
tambiénpara la Introducción y Conclusión. De esta manera,refsegment
se asignará un número (positivo) a estos capítulos y sus respectivas referencias se podrán imprimir usando\bibbysegment
.Utilice
\frontmatter
y para que los capítulos Introducción y Conclusión no\mainmatter
estén\backmatter
numerados. (En realidad, utilice\boolfalse{@mainmatter}
en lugar de\frontmatter
para evitar cambiar a la numeración de páginas romana).Declare nuevos contadores para almacenar el valor
\therefsegment
después del front-resp. el tema principal, y use estos contadores en una nueva definición delbibintoc2
encabezado para lograr el formato diferente para las referencias al frente/principal/trasfondo.
\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}
Respuesta3
Creo que puedes hacer esto:
\chapter*{Introduction}
\begin{refsegment}
\cite{A01}
\end{refsegment}
Editar: El problema con el refsegmento para la conclusión no es que haya un segundo refsegmento sino que con la opción refsegment=chapter
un \chapter
comando inserta un \begin{refsegment}
(o algo análogo) y esto no está cerrado por el `\capítulo*.
Podrías detener este segmento antes de la conclusión:
\endrefsegment
\chapter*{Conclusion}
(Una mejor solución sería parchear \chapter*
también).