Forma correcta de incluir capítulos no numerados en una bibliografía por capítulo usando biblatex

Forma correcta de incluir capítulos no numerados en una bibliografía por capítulo usando biblatex

He estado usando ejemplos 3.11.4de la biblatexdocumentació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 biblatexdevuelve un nested refsectionserror. 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.4del biblatexdocumento?

¡Gracias de antemano por la ayuda!

Respuesta1

Puedes invocar \newrefsegmenty \citeresetmanualmente 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 \chapterpara \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}

ingrese la descripción de la imagen aquí

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 \endrefsegmentpara 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}

ingrese la descripción de la imagen aquí

Si bien esto resuelve su problema inmediato, su solución alternativa de usar refsections 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 refsegments (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, refsegmentse asignará un número (positivo) a estos capítulos y sus respectivas referencias se podrán imprimir usando \bibbysegment.

  • Utilice \frontmattery para que los capítulos Introducción y Conclusión no \mainmatterestén \backmatternumerados. (En realidad, utilice \boolfalse{@mainmatter}en lugar de \frontmatterpara evitar cambiar a la numeración de páginas romana).

  • Declare nuevos contadores para almacenar el valor \therefsegmentdespués del front-resp. el tema principal, y use estos contadores en una nueva definición del bibintoc2encabezado 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}

ingrese la descripción de la imagen aquí

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=chapterun \chaptercomando 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).

información relacionada