2

This is a follow-up question.

@moewe's brilliant solution works. But, when I try to get the Bibliography in trad-alpha style, then the citation keys are not shown in Chapter references (notice the red dots before the items):

The final Bibliography is perfect (notice the yellow highlights):

How should I modify the MWE to fix this problem?

% https://tex.stackexchange.com/a/372872/38244
\documentclass{book}
\usepackage{filecontents}
\begin{filecontents}{chapterref.dbx}
\DeclareDatamodelFields[type=field,datatype=literal]{
  shortdesc,
}
\DeclareDatamodelEntryfields{shortdesc}
\end{filecontents}

\usepackage[backref, refsegment=chapter, datamodel=chapterref, 
style=trad-alpha % https://tex.stackexchange.com/a/69706/38244
]{biblatex}
\usepackage[colorlinks]{hyperref}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author    = {Author, A. and Duthor, D.},
  year      = {2001},
  title     = {Alpha},
  shortdesc = {Conference1},
}
@misc{B02,
  author    = {Buthor, B. and Euther, E. and Futher F.},
  year      = {2002},
  title     = {Bravo},
  shortdesc = {Journal2},
}
@misc{C03,
  author    = {Cuthor, C.},
  year      = {2003},
  title     = {Charlie},
  shortdesc = {Workshop},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\makeatletter
\defbibenvironment{chapterref}
  {\list
     {\printtext[labelnumberwidth]{%
      \printfield{labelprefix}%
      \printfield{labelnumber}}}
     {\let\blx@anchor\relax
      \setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}
\makeatother

\DeclareFieldFormat{shortyear}{\mkbibshortyear#1}
\def\mkbibshortyear#1#2#3#4{#3#4}

\DeclareBibliographyDriver{chapterref}{%
  \usebibmacro{begentry}%
  \renewcommand*{\finalnamedelim}{\multinamedelim}%
  \DeclareNameAlias{author}{labelname}%
  \DeclareNameAlias{editor}{labelname}%
  \DeclareNameAlias{translator}{labelname}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\addcolon\space}%
  \printfield{shortdesc}%
  \setunit{'}%
  \printfield[shortyear]{year}%
  \usebibmacro{finentry}}

\defbibheading{chapterref}[References]{% 
  \section*{#1}% 
  \markboth{#1}{#1}%
}

\defbibheading{bibliography}[Complete Bibliography]{% 
  \chapter*{#1}%
  \addcontentsline{toc}{chapter}{#1}%
  \markboth{#1}{#1}%
}

\begin{document}
  \chapter{First Chapter}
  Some more text \autocite{A01,B02}.
  \printbiblist[heading=chapterref, segment=\therefsegment]{chapterref}

  \chapter{Second Chapter}
  Some text \autocite{A01,C03}.
  \printbiblist[heading=chapterref, segment=\therefsegment]{chapterref}


  \printbibliography
\end{document}
hola
  • 4,026
  • 3
  • 35
  • 72

1 Answers1

4

The definition of \defbibenvironment{chapterref} is specific to the kind of style you use. Essentially it is a copy of the style definition of \defbibenvironment{bibliography} with \let\blx@anchor\relax in the list setup code. If you use an alphabetic-like style such as trad-alpha, you will need

\makeatletter
\defbibenvironment{chapterref}
  {\list
     {\printtext[labelalphawidth]{%
        \printfield{labelprefix}%
        \printfield{labelalpha}%
        \printfield{extraalpha}}}
     {\let\blx@anchor\relax
      \setlength{\labelwidth}{\labelalphawidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{##1\hss}}
  {\endlist}
  {\item}%
\makeatother
moewe
  • 175,683