我是 biblatex 新手,需要为哈佛修改版的报告创建参考书目条目。到目前为止,我已经能够满足要求,如下所示。
世界经济论坛 (2020)《2020 年就业未来报告》。[pdf]。日内瓦:世界经济论坛。网址:http://www3.weforum.org/docs/WEF_Future_of_Jobs_2020.pdf[2020 年 12 月 19 日访问]。
但是,我仍然需要删除“[pdf]”后的句号以确保样式正确,但不确定如何操作。
main-bib.bib
@report{WEF:2020,
author = {{World Economic Forum}},
title = {The Future of Jobs Report 2020},
type = {pdf},
institution = {World Economic Forum},
year = {2020},
location = {Geneva},
url = {http://www3.weforum.org/docs/WEF_Future_of_Jobs_2020.pdf},
urldate = {2020-12-19},
}
主文件:
\documentclass[a4]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[
style=ext-authoryear,
uniquename=init,
articlein=false,
dateabbrev=false,
maxcitenames=1,
maxbibnames=99,
giveninits,
backend=biber
]{biblatex}
%formats report type into square brackets
\DeclareFieldFormat[report]{type}{\mkbibbrackets{#1}}
\addbibresource{main-bib.bib}
\begin{document}
Citing: \cite{WEF:2020}
\printbibliography
\end{document}
答案1
只需进行两项更改即可完成 \DeclareBibliographyDriver{report}
,
从
\printfield{type}%
\setunit*{\addspace}%
到
\printfield[brackets]{type}% changed <<<<<<<<<<<<
\printunit*{\addspace}% changed <<<<<<<<<<<<<<<<<
尝试此代码
\documentclass[a4]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[
style=ext-authoryear,
uniquename=init,
articlein=false,
dateabbrev=false,
maxcitenames=1,
maxbibnames=99,
giveninits,
backend=biber
]{biblatex}
%formats report type into square brackets
%\DeclareFieldFormat[report]{type}{\mkbibbrackets{#1}}
\DeclareBibliographyDriver{report}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\printfield[brackets]{type}% changed <<<<<<<<<<<<
\printunit*{\addspace}% changed <<<<<<<<<<<<<<<<
\printfield{number}%
\newunit\newblock
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\usebibmacro{institution+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isrn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}
\addbibresource{main-bib.bib}
\begin{document}
Citing: \cite{WEF:2020}
\printbibliography
\end{document}
您已经弄清楚了第一个,但我认为最好将两者结合起来。
这是第二部分的解释,来自biblatex
手册4.7.1 节
\setunit{⟨标点符号⟩} \setunit*{⟨标点符号⟩}
\setunit 命令与 \newunit 类似,只不过它使用 ⟨punctuation⟩ 而不是 \newunitpunct。带星号的版本与常规版本的区别在于,它会检查最后的 \printtext、\printfield、\printlist、\printnames 或 \bibstring 命令是否确实打印了任何内容。如果没有,则不执行任何操作。
\printunit{⟨ 标点符号⟩ } \printunit*{⟨ 标点符号⟩ }
\printunit 命令与 \setunit 类似,只是⟨punctuation⟩ 仍保留在缓冲区中。
这样可以确保⟨punctuation⟩插入到由 \printtext、\printfield、\printlist、\printnames 或 \bibstring 命令打印的下一个非空字段之前 — — 无论中间是否调用了 \newunit 或 \setunit。