我想自定义参考文献的打印方式。
我希望将引用参考文献的页面列表打印在新行上,就在书目条目及其最终摘要的下方。
我还想改变工作方式。如果列表中有两个以上的条目,backrefstyle=all+
我想在列表and
的最后一个条目之前添加一个。pageref
pageref
我浏览了 Biblatex 文档,但还没有找到改变行为的方法backrefstyle=all+
。你能帮助我吗?
以下是我目前拥有的:
问题是pageref
-list 出现了两次,并且backrefpage
或backrefpages
字段没有出现在列表前面;以及如果此列表仅显示一个项目,则在列表开头出现逗号问题。(\nopunct
没有解决问题。)
\documentclass{article}
\usepackage[
backend=biber,
style=verbose-trad1,
backref=true,
backrefstyle=all+,
]{biblatex}
\addbibresource{biblatex-examples.bib}
\DeclareFieldFormat{abstract}{\par\vspace{\baselineskip} Abstract : #1}
\renewbibmacro*{finentry}{%
\printfield{abstract}\par%
\vspace{\baselineskip}%
\nopunct\printlist[pageref][-\value{listtotal}]{pageref}%
\finentry%
}
\begin{document}
Bla\footcite{kastenholz}
\clearpage
Bla\footcite{kastenholz}
\clearpage
Bla\footcite{kastenholz}
\clearpage
Bla bla bla
\clearpage
Bla\footcite{kastenholz}
\clearpage
Bla bla bla
\clearpage
Bla\footcite{kastenholz}
\clearpage
\printbibliography
\end{document}
这是我想要实现的结果:
答案1
要打印反向引用,您需要记住,几乎永远不要在上下文之外直接打印标点符号或空格\setunit
。biblatex
此外,字段格式不应包含标点符号的前导或尾随空格。\setunit
正确使用应该可以消除所有不良标点符号的问题。您可以通过重新定义通常打印它们(之前)的宏来确保反向引用只打印一次,而finentry
不是执行任何操作。
反向引用的实际格式要复杂得多,因为放置“and”需要在打印之前循环遍历列表一次以计算打印的“块”。下面显示的代码改编自原始定义。但是,原始定义直接打印其输出,我们将“块”存储在辅助宏中并增加计数器。然后在最后我们循环遍历块并打印它们。
\documentclass{article}
\usepackage[
backend=biber,
style=verbose-trad1,
backref=true,
backrefstyle=all+,
]{biblatex}
\usepackage[colorlinks]{hyperref}
\renewbibmacro*{pageref}{}
\newbibmacro*{bastien:pageref}{%
\iflistundef{pageref}
{}
{\ifnumgreater{\value{pageref}}{1}
{\bibstring{backrefpages}\ppspace}
{\bibstring{backrefpage}\ppspace}%
\printlist[pageref][-\value{listtotal}]{pageref}}}
\DeclareFieldFormat{abstract}{\bibstring{abstract}\addcolon\addnbspace#1}
\renewbibmacro*{finentry}{%
\setunit{\par\vspace{0.5\baselineskip}}%
\printfield{abstract}%
\setunit{\par\vspace{0.5\baselineskip}}%
\usebibmacro{bastien:pageref}%
\finentry
}
\makeatletter
\newcounter{pageref:total}
\newcounter{pageref:loop}
\DeclareListWrapperFormat{pageref}{%
\setcounter{pageref:total}{0}%
#1%
\setcounter{pageref:loop}{0}%
\loop
\addtocounter{pageref:loop}\@ne
\ifnumgreater{\value{pageref:loop}}{1}
{\ifnumequal{\value{pageref:loop}}{\value{pageref:total}}
{\setcounter{liststop}{\value{pageref:total}}%
\printdelim{finallistdelim}}
{\printdelim{multilistdelim}}}
{}%
\csuse{pagerefc@chung@\the\value{pageref:loop}}%
\ifnum \value{pageref:loop}<\value{pageref:total}
\repeat
}
\renewbibmacro*{pageref:comp}[1]{%
\numdef\abx@range@prev{\abx@range@prev+1}%
\ifinteger{#1}
{\def\abx@range@num{#1}%
\def\abx@range@this{1}%
\ifnumequal{\abx@range@this}{\abx@range@last}
{}
{\def\abx@range@prev{-1}}}
{\ifrmnum{#1}
{\numdef\abx@range@num{\rmntonum{#1}}%
\def\abx@range@this{2}%
\ifnumequal{\abx@range@this}{\abx@range@last}
{}
{\def\abx@range@prev{-1}}}
{\undef\abx@range@num
\def\abx@range@this{0}%
\def\abx@range@prev{-1}}}%
\ifdef\abx@range@num
{\ifnumequal{\abx@range@num}{\abx@range@prev}
{\def\abx@range@hold{#1}%
\numdef\abx@range@diff{\abx@range@diff+1}}
{\usebibmacro{pageref:dump}%
\addtocounter{pageref:total}\@ne
\csgdef{pagerefc@chung@\the\value{pageref:total}}{%
\ifhyperref
{\hyperlink{page.#1}{#1}}
{#1}}}%
\edef\abx@range@prev{\abx@range@num}}
{\usebibmacro{pageref:dump}%
\addtocounter{pageref:total}\@ne
\csgdef{pagerefc@chung@\the\value{pageref:total}}{%
\ifhyperref
{\hyperlink{page.#1}{#1}}
{#1}}%
\def\abx@range@prev{-1}}%
\edef\abx@range@last{\abx@range@this}}
\renewbibmacro*{pageref:dump}{%
\ifnumgreater{\abx@range@diff}{0}
{\ifcase\abx@pagerefstyle\relax % two
\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\bibrangedash
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\expandonce\abx@range@hold}}
{\expandonce\abx@range@hold}}%
\or % three
\addtocounter{pageref:total}\@ne
\csxdef{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\expandonce\abx@range@hold}}
{\expandonce\abx@range@hold}}%
\or % two+
\ifnumless{\abx@range@diff}{2}
{\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\sqspace
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\noexpand\bibstring{sequens}}}
{\noexpand\bibstring{sequens}}}}
{\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\bibrangedash
\noexpand\ifhyperref
{\hyperlink{page.\expandonce\abx@range@hold}{\noexpand\abx@range@hold}}
{\expandonce\abx@range@hold}}}%
\or % three+
\ifnumless{\abx@range@diff}{2}
{\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\sqspace
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\noexpand\bibstring{sequens}}}
{\noexpand\bibstring{sequens}}}}
{\ifnumless{\abx@range@diff}{3}
{\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\sqspace
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\noexpand\bibstring{sequentes}}}
{\noexpand\bibstring{sequentes}}}}
{\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\bibrangedash
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\expandonce\abx@range@hold}}
{\expandonce\abx@range@hold}}}}%
\else % all+
\ifnumless{\abx@range@diff}{2}
{\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\sqspace
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\noexpand\bibstring{sequens}}}
{\noexpand\bibstring{sequens}}}}
{\csxappto{pagerefc@chung@\the\value{pageref:total}}{%
\noexpand\sqspace
\noexpand\ifhyperref
{\noexpand\hyperlink{page.\expandonce\abx@range@hold}{\noexpand\bibstring{sequentes}}}
{\noexpand\bibstring{sequentes}}}}%
\fi
\def\abx@range@diff{0}}
{}}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
Bla\footcite{kastenholz}
Bla\footcite{sigfridsson}
Bla\footcite{worman}
Bla\footcite{geer}
\clearpage
Bla\footcite{kastenholz}
Bla\footcite{sigfridsson}
Bla\footcite{worman}
\clearpage
Bla\footcite{kastenholz}
Bla\footcite{sigfridsson}
Bla\footcite{worman}
\clearpage
Bla bla bla
Bla\footcite{sigfridsson}
\clearpage
Bla\footcite{kastenholz}
Bla\footcite{sigfridsson}
Bla\footcite{geer}
\clearpage
Bla bla bla
Bla\footcite{geer}
\clearpage
Bla\footcite{kastenholz}
Bla\footcite{sigfridsson}
Bla\footcite{geer}
\clearpage
\printbibliography
\end{document}