biblatex:向参考书目添加特定条目信息(期刊评级)

biblatex:向参考书目添加特定条目信息(期刊评级)

对于一篇论文,我需要将期刊评级添加到参考书目条目中。我尝试使用以下方法执行此操作:

\begin{filecontents}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=literal]{rating}
\DeclareDatamodelEntryfields{rating}
\end{filecontents}

\DeclareFieldFormat{rating}{#1}
\renewbibmacro{finentry}{\finentry\par\printfield{rating}}

现在,这不起作用。我在我的书目文件中添加了一个“评级”字段,但没有任何变化……所以我想这不是向参考书目添加内容的正确方法。

我目前正在使用以下包:

\usepackage[style=apa, backend=biber]{biblatex}
\printbibliography[heading=bibintoc,title={Literaturverzeichnis}]

答案1

似乎有效(下次发布实际代码来演示您的问题):

\documentclass{article}
\begin{filecontents}[overwrite]{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=literal]{rating}
\DeclareDatamodelEntryfields{rating}
\end{filecontents}
\begin{filecontents}[overwrite]{\jobname.bib}
@article{testa,
  author = {Author, An},
  title = {Title A},
  journaltitle = {Journal Name},
  volume = {1},
  date = {2022},
  rating = {3}
}
@article{testb,
  author = {Author, Another},
  title = {Title B},
  journaltitle = {Difference Journal Name},
  volume = {5},
  date = {2020},
  rating = {4}
}
\end{filecontents}
\usepackage{fontawesome}
\usepackage[style=apa]{biblatex}
\addbibresource{\jobname.bib}
\newcount\rating
\newcount\ratingmax
\newcount\ratingiter
\ratingmax5
\DeclareFieldFormat{rating}{%
  \rating#1
  \ifnum\rating<0\rating0\fi
  \ifnum\rating>\ratingmax\rating\ratingmax\fi
  \ratingiter0
  \loop\ifnum\ratingiter<\rating
    \faStar
    \advance\ratingiter1\relax
  \repeat
  \loop\ifnum\ratingiter<\ratingmax\relax
    \faStarO
    \advance\ratingiter1\relax
  \repeat
}
\renewbibmacro*{finentry}{\finentry\par\printfield{rating}}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

输出

相关内容