如何在页边空白处标记参考书目条目?

如何在页边空白处标记参考书目条目?

我有一个 Biber 书目,其中某些作品用特殊关键字标记。当 Biblatex 打印参考文献列表(作者-年份格式)时,我希望它用一些标记(例如星号)注释这些条目。因此我尝试了以下方法:

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

参考文献列表显示第一个条目带有星号,该星号与下一个条目左侧对齐

但是,我希望这些星号出现在左边距,以便参考文献的作者列表对齐。我尝试将的定义更改为begentry以下内容,使用\widthof而不是绝对宽度(以避免我必须猜测要使用多少空间,并使命令能够抵御字体大小的变化)。但是,它不起作用:

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

我做错了什么?我怎样才能将标记稍微放在参考书目条目的左侧?

答案1

您只需将文本放在宽度为零的框中:

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

在此处输入图片描述

答案2

我们可以使用 egreg 的解决方案来在文本左侧添加标记

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

在此处输入图片描述

相关内容