0

Following on from this question, I would like to prepend a symbol to selected entries in my bibliography. But I would like to match the functionality here where the symbol is inserted automatically based on keywords in the .bbl file.

I can achieve the desired output by uncommenting the two lines in the MWE which does the job manually:

enter image description here

It'd be much more efficient for my workflow if I could use keywords instead.

As far as I can work out, this MWE does not acknowledge the presence of asterisk in the keywords field, even though I've tried to follow the logic in the above links:

\documentclass[american]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,
  bibencoding=utf8]{biblatex-chicago}

\begin{filecontents}{\jobname.bib} @book{uthor, author = {Uthor, Arnold}, title = {A Book}, date = {2013}, location = {Place}, publisher = {P. Ublisher's & Co.}, keywords = {asterisk} } \end{filecontents} \addbibresource{\jobname.bib}

%\DeclareBibliographyCategory{asterisk}

\renewbibmacro{bibindex}{% \ifbibindex {\indexnames{labelname}% \indexfield{indextitle}} {} \ifcategory{asterisk}% {}% {}% }

\begin{document} % \addtocategory{asterisk}{uthor} \cite{uthor} \printbibliography \end{document}

Please can someone let me know where I'm going wrong?

1 Answers1

1

The solution I see is to use the \ifkeyword test. I prefer to use xpatch in similar cases:

\usepackage{xpatch}
\AtEveryBibitem{\ifkeyword{asterisk}%
 {\xapptobibmacro{bibindex}{*}{}{}}
 {}}

but you can also do without it if you prefer:

\renewbibmacro*{bibindex}{%
 \ifbibindex
 {\indexnames{labelname}%
  \indexfield{indextitle}}
 {}
\ifkeyword{asterisk}{*}{}%
}

MWE

\documentclass[american]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,
bibencoding=utf8]{biblatex-chicago}

\begin{filecontents}{\jobname.bib} @book{uthor, author = {Uthor, Arnold}, title = {A Book}, date = {2013}, location = {Place}, publisher = {P. Ublisher's & Co.}, keywords = {asterisk} } \end{filecontents} \addbibresource{\jobname.bib} \addbibresource{biblatex-examples.bib}

\usepackage{xpatch} \xapptobibmacro{bibindex}{\ifkeyword{asterisk}{*}{}}{}{}

\begin{document}

\paragraph{An entry with “asterisk” keyword} \cite{uthor}

\paragraph{An entry without “asterisk” keyword} \cite{knuth:ct}

\printbibliography

\end{document}

enter image description here

Ivan
  • 4,368