4

I have a Biber bibliography where certain works are marked with a special keyword. When Biblatex prints the list of references (in author–year style), I want it annotate these entries with some marker, such as an asterisk. So I tried the following:

\documentclass{article}
\usepackage{calc}
\usepackage[bibstyle=authoryear]{biblatex}
\addbibresource{\jobname.bib}

\renewbibmacro*{begentry}{\ifkeyword{ownwork}{\textasteriskcentered\addspace}{}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{foo,
  author       = {Foo},
  title        = {Foo},
  booktitle    = {Foo},
  year         = {2017},
}
@inproceedings{bar,
  author       = {Bar},
  title        = {Bar},
  booktitle    = {Bar},
  year         = {2017},
  keywords     = {ownwork},
}
\end{filecontents}

\begin{document}
\nocite{foo,bar}
\printbibliography
\end{document}

References list showing the first entry with an asterisk, the asterisk being flush left with the next entry

However, I want these asterisks to appear in the left margin, so that the author lists of the references are aligned. I tried changing the definition of begentry to the following, which uses \widthof rather than an absolute width (to avoid my having to guess how much space to use, and to make the command robust against changes in font size). However, it doesn't work:

\renewbibmacro*{begentry}{%
  \ifkeyword{ownwork}{%
    \setlength{\dimen0}{-\widthof{\textasteriskcentered\addspace}}%
    \hspace{\dimen0}\textasteriskcentered\addspace%
  }{}}

What am I doing wrong? How can I put the marker slightly to the left of the bibliography entry?

  • You can't use \widthof like this. Beside this the calculations are not needed, use \makebox[0pt][r]{\textasteriskcentered\addspace} – Ulrike Fischer Nov 23 '17 at 16:54
  • Somewhat related: Getting two different bibliographies depending on where the one and the same citation is cited: khirevich.com/latex/bibliography You might want to re-state a short citation in the marin (marginpar or similar) of the main text to rub the reader into the face that these papers are yours. – Oleg Lobachev Nov 23 '17 at 16:57
  • Oh, and I used \newcommand{\hangleft}[1]{\makebox[0pt][r]{#1}} and \newcommand{\hangright}[1]{\makebox[0pt][l]{#1}} in similar circumstances, but did not test with your MWE. – Oleg Lobachev Nov 23 '17 at 16:58
2

You only need to put the text in a box of width zero:

\documentclass{article}
\usepackage{calc}
\usepackage[bibstyle=authoryear]{biblatex}
\addbibresource{\jobname.bib}

\renewbibmacro*{begentry}{\ifkeyword{ownwork}{\makebox[0pt][r]{\textasteriskcentered\addspace}}{}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{foo,
  author       = {Foo},
  title        = {Foo},
  booktitle    = {Foo},
  year         = {2017},
}
@inproceedings{bar,
  author       = {Bar},
  title        = {Bar},
  booktitle    = {Bar},
  year         = {2017},
  keywords     = {ownwork},
}
\end{filecontents}

\begin{document}
\nocite{foo,bar}
\printbibliography
\end{document}

enter image description here

  • @moewe's answer also works for me, but I prefer this one because of its simplicity. – Psychonaut Nov 24 '17 at 8:49
3

We can use egreg's solution to Add a marker to the left of the text

\documentclass{article}
\usepackage[bibstyle=authoryear]{biblatex}
\addbibresource{\jobname.bib}


\newcommand{\impmark}{\strut\vadjust{\domark}}
\newcommand{\domark}{%
  \vbox to 0pt{
    \kern-\dp\strutbox
    \smash{\llap{*\kern1em}}
    \vss
  }%
}
\renewbibmacro*{begentry}{\ifkeyword{ownwork}{\impmark}{}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{foo,
  author       = {Foo},
  title        = {Foo},
  booktitle    = {Foo},
  year         = {2017},
}
@inproceedings{bar,
  author       = {Bar},
  title        = {Bar},
  booktitle    = {Bar},
  year         = {2017},
  keywords     = {ownwork},
}
\end{filecontents}

\begin{document}
\nocite{foo,bar}
\printbibliography
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.