由于我对文中引用书目参考的页面在参考书目中的反映方式不太满意,因此我尝试修改pageref
Biblatex 中的宏,如下所示:
\documentclass{article}
\usepackage{times}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage[style=numeric-comp,backref=true,backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{saad00,
title = {Iterative Methods for Sparse Linear Systems},
year = {2000},
author = {Y. Saad}}
\end{filecontents}
\addbibresource{\jobname.bib}
% pagereference in the right margin
\renewbibmacro*{pageref}{%
\iflistundef{pageref}
{}
{\printtext{\hfill\rlap{\hskip15pt\colorbox{blue!5}{\scriptsize\printlist[pageref][-\value{listtotal}]{pageref}}}}}}
\begin{document}
text \cite{saad00}
\printbibliography
\end{document}
我认为问题在于将\hfill
与前一个块(给定示例中的条目)相关的标点符号推到右侧。我知道如何通过在文件中year
挂接来解决这个问题,但如果在宏中直接有一个更简单的解决方案,我会很高兴。\DeclareBibliographyDriver{book}
.bbx
pageref
答案1
pageref
尝试以这种方式重新定义 bibmacro :
\renewbibmacro*{pageref}{%
\iflistundef{pageref}
{\renewcommand{\finentrypunct}{\addperiod}}
{\renewcommand{\finentrypunct}{\addspace}%
\printtext{\addperiod\hfill\rlap{\hskip15pt\colorbox{blue!5}{\scriptsize\printlist[pageref][-\value{listtotal}]{pageref}}}}}}
如果pageref
未定义,则 的含义\finentrypunct
保持不变,而当 已定义时,我们将其重新定义\finentrypunct
为并在 之前\addspace
添加。这样,即使使用 也可以正常工作。\addperiod
\hfill
\nocite
梅威瑟:
\documentclass{article}
\usepackage{times}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage[style=numeric-comp,backref=true,backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{saad00,
title = {Iterative Methods for Sparse Linear Systems},
year = {2000},
author = {Y. Saad}}
\end{filecontents}
\addbibresource{\jobname.bib}
% pagereference in the right margin
\renewbibmacro*{pageref}{%
\iflistundef{pageref}
{\renewcommand{\finentrypunct}{\addperiod}}
{\renewcommand{\finentrypunct}{\addspace}%
\printtext{\addperiod\hfill\rlap{\hskip15pt\colorbox{blue!5}{\scriptsize\printlist[pageref][-\value{listtotal}]{pageref}}}}}}
\begin{document}
text \cite{saad00}
\printbibliography
\end{document}
输出: