我正在根据以下标准编写自己的参考书目风格:trad-standard.bbx
对于phdthesis
司机,我想将部门作为 bib 文件中的单独输入。所以我的 bibfile 如下所示:
@phdthesis{Test2018,
author = {Doe, John},
school = {University of Foo},
department = {Department for eggs and bacon},
title = {{Studies on the cooking time of eggs and bacon, searching for the perfect symbiosis.}},
type = {Master's Thesis},
year = {2018}
}
论文的驱动程序定义如下trad-standard.bbx
:
\DeclareBibliographyDriver{thesis}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\printfield{type}%
\newcommaunit
\usebibmacro{institution+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\usebibmacro{doi+eprint+url+issn}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}{%
\usebibmacro{related:init}%
\usebibmacro{related}%
}{}%
\usebibmacro{finentry}%
}
并且当前输出Test2018
是
J. Doe:“研究鸡蛋和培根的烹饪时间,寻找完美的共生关系”。硕士论文,Foo 大学,2018 年。
我想在学校后面添加部门,因此结果将是:
J. Doe:“研究鸡蛋和培根的烹饪时间,寻找完美的共生关系”。硕士论文,Foo 大学,鸡蛋和培根系,2018 年。
在驱动程序中,我找不到学校的打印功能,因此我无法定义新的支票以便随后打印部门。我猜想学校是通过命令打印的,\printlist{location}
但我找不到该命令的定义,因此,我不知道如何设置此列表以及如何注入部门。
谁能帮我吗?
我们
注意:文件很长!(为了节省空间,我删除了所有驱动程序,只留下用于论文的驱动程序。)
\documentclass{article}
\usepackage{filecontents}
\usepackage{hyperref}
\begin{filecontents*}{custom-abbrv.bbx}
% %%%%%%%%%%%%%
% Declare Style
% %%%%%%%%%%%%%
\ProvidesFile{custom-abbrv.bbx}[2018/08/20 v2.0.0 Custom abbrv Bibliography Style]
% %%%%%%%%%%%%%
% Require Style
% %%%%%%%%%%%%%
\RequireBibliographyStyle{standard}
% %%%%%%%%%%%%%
% Basic Options
% %%%%%%%%%%%%%
\ExecuteBibliographyOptions{%
abbreviate = false,
arxiv = false,
useprefix = true,
autolang = hyphen,
backref = false,
dateabbrev = true,
eprint = false,
hyperref = true,
labelnumber = true,
maxnames = 3,
minnames = 3,
sorting = none,
}
% %%%%%%%%%%%%%%%%%%%%%
% Package Functionality
% %%%%%%%%%%%%%%%%%%%%%
\@ifpackagelater{biblatex}{2016/03/01}
{\ExecuteBibliographyOptions{giveninits=true}}
{\ExecuteBibliographyOptions{firstinits=true}}
\@ifpackagelater{biblatex}{2016/03/01}{%
\@ifpackagelater{biblatex}{2016/05/14}{%
\DeclareNameFormat{abbrv}{%
\usebibmacro{name:given-family}%
{\namepartfamily}%
{\namepartgiveni}%
{\namepartprefixi}%
{\namepartsuffixi}%
\usebibmacro{name:andothers}%
}%
}{%
\DeclareNameFormat{abbrv}{%
\nameparts{#1}%
\usebibmacro{name:given-family}%
{\namepartfamily}%
{\namepartgiveni}%
{\namepartprefixi}%
{\namepartsuffixi}%
\usebibmacro{name:andothers}%
}%
}%
}{%
\DeclareNameFormat{abbrv}{%
\usebibmacro{name:first-last}{#1}{#4}{#6}{#8}%
\usebibmacro{name:andothers}%
}%
}%
\DeclareNameAlias{default}{abbrv}
\@ifpackagelater{biblatex}{2016/05/14}{%
\defbibenvironment{bibliography}%
{%
\list{%
\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\printfield{labelnumber}%
}%
}{%
\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
}%
\renewcommand*{\makelabel}[1]{\hss##1}%
}
{\endlist}
{\item}%
}{%
\defbibenvironment{bibliography}%
{%
\list{%
\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}%
}%
}{%
\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
}%
\renewcommand*{\makelabel}[1]{\hss##1}%
}%
{\endlist}%
{\item}%
}
\defbibenvironment{shorthands}%
{%
\list{%
\printfield[shorthandwidth]{shorthand}%
}{%
\setlength{\labelwidth}{\shorthandwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
\renewcommand*{\makelabel}[1]{\hss##1}%
}%
}%
{\endlist}%
{\item}%
% %%%%%%%%%%%%%%%%%%%%%%%
% Preliminary Definitions
% %%%%%%%%%%%%%%%%%%%%%%%
% Booleans
\providebool{bbx:subentry}
\DeclareBibliographyOption[boolean]{subentry}[true]{%
\setbool{bbx:subentry}{#1}%
}
\newbool{bbxtrad:doisequal}
\newbool{bbxtrad:eprintsequal}
\newbool{bbxtrad:urlsequal}
\newbool{bbxtrad:notesequal}
\newbool{bbxtrad:addendumsequal}
% Aliases
\DeclareNameAlias{author}{default}
\DeclareNameAlias{editor}{default}
\DeclareNameAlias{translator}{default}
% New commands
\newcommand*{\volumenumberdelim}{} % delim between number and volume
\renewcommand*{\intitlepunct}{\addspace} % after the bibstring in
\renewcommand*{\newunitpunct}{\addperiod\space}
\newcommand*{\newcommaunit}{\@ifstar\newcommaunitStar\newcommaunitNoStar}
\newcommand*{\newcommaunitStar}{\setunit*{\addcomma\space}}
\newcommand*{\newcommaunitNoStar}{\setunit{\addcomma\space}}
\renewcommand*{\labelnamepunct}{\addcolon\space}
\renewcommand*{\subtitlepunct}{\addperiod\space}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Field Formatting and Appearance
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title
\DeclareFieldFormat*{title}{%
\enquote{#1}\isdot%
}
% Titlecase
\DeclareFieldFormat{titlecase}{%
\MakeTitleCase{#1}%
}
\newrobustcmd{\MakeTitleCase}[1]{%
\ifthenelse{
\ifcurrentfield{booktitle}%
\OR\ifcurrentfield{booksubtitle}%
\OR\ifcurrentfield{maintitle}\OR\ifcurrentfield{mainsubtitle}%
\OR\ifcurrentfield{journaltitle}%
\OR\ifcurrentfield{journalsubtitle}%
\OR\ifcurrentfield{issuetitle}%
\OR\ifcurrentfield{issuesubtitle}%
\OR\ifentrytype{book}%
\OR\ifentrytype{mvbook}%
\OR\ifentrytype{bookinbook}%
\OR\ifentrytype{booklet}%
\OR\ifentrytype{suppbook}%
\OR\ifentrytype{collection}%
\OR\ifentrytype{mvcollection}%
\OR\ifentrytype{suppcollection}%
\OR\ifentrytype{manual}%
\OR\ifentrytype{periodical}%
\OR\ifentrytype{suppperiodical}%
\OR\ifentrytype{proceedings}%
\OR\ifentrytype{mvproceedings}%
\OR\ifentrytype{reference}%
\OR\ifentrytype{mvreference}%
\OR\ifentrytype{report}%
\OR\ifentrytype{thesis}%
}
{#1}
{\MakeSentenceCase{#1}}%
}
% Journal title
\DeclareFieldFormat{journaltitle}{%
\mkbibemph{#1},%
}
% Chapter
\DeclareFieldFormat{chapter}{%
\bibstring{chapter}~#1%
}
% Volume
\DeclareFieldFormat[article]{volume}{#1}
% Number
\DeclareFieldFormat*{number}{\mkbibparens{#1}}
\DeclareFieldFormat[book,incollection,inproceedings,proceedings]{number}{%
\biblstring{number}~#1%
}
\DeclareFieldFormat[techreport,report]{number}{#1}
% Edition
\DeclareFieldFormat{edition}{%
\ifinteger{#1}%
{\mkbibordedition{#1}~\bibstring{edition}}%
{\MakeLowercase{#1}~\bibstring{edition}}%
}
% Series
\DeclareFieldFormat[book,inproceedings,proceedings]{series}{%
\mkbibemph{#1}%
}
% Pages
\DeclareFieldFormat*{pages}{\space#1\space}
\renewcommand*{\bibpagespunct}{\addspace}
% Year
\DeclareFieldFormat{date}{\textbf{#1}}
% URL
\DeclareFieldFormat{url}{URL:\space\url{#1}}
% ISSN / ISBN
\DeclareFieldFormat{issn}{ISSN:\space\url{#1}}
\DeclareFieldFormat{isbn}{ISBN:\space\url{#1}}
% DOI
\DeclareFieldFormat{doi}{%
DOI\addcolon\space
\ifhyperref
{\href{http://dx.doi.org/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}%
}
% Item Separation
\setlength\bibitemsep{.5\baselineskip}
% Alignment
\AtBeginBibliography{\raggedright}
% Bibentrysetcount
\DeclareFieldFormat{bibentrysetcount}{\mkbibparens{\mknumalph{#1}}}
% Labelnumberwidth
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
% Shorthandwidth
\DeclareFieldFormat{shorthandwidth}{\mkbibbrackets{#1}}
% In
\renewbibmacro*{in:}{%
\printtext{%
\bibstring{in}%
\printunit{\intitlepunct}%
}%
}
% %%%%%%%%%%%%
% Driver Setup
% %%%%%%%%%%%%
% Thesis
\DeclareBibliographyDriver{thesis}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\printfield{type}%
\newcommaunit
\usebibmacro{institution+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\usebibmacro{doi+eprint+url+issn}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}{%
\usebibmacro{related:init}%
\usebibmacro{related}%
}{}%
\usebibmacro{finentry}%
}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Redefinition of diverse Macros
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newbibmacro*{crossref:label}{%
\usebibmacro{maintitle+booktitle:noemph}%
\setunit{\addspace}%
\entrydata{\strfield{crossref}}{%
\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}%
}%
}%
}
\newbibmacro*{maintitle+booktitle:noemph}{%
\iffieldundef{maintitle}{}{%
\usebibmacro{maintitle:noemph}%
\newunit\newblock
\iffieldundef{volume}%
{}%
{\printfield{volume}%
\printfield{part}%
\setunit{\addcolon\space}}%
}%
\usebibmacro{booktitle:noemph}%
\newunit%
}
\newbibmacro*{maintitle:noemph}{%
\ifboolexpr{
test {\iffieldundef{maintitle}}
and
test {\iffieldundef{mainsubtitle}}
}%
{}%
{%
\printtext{%
\printfield[titlecase]{maintitle}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{mainsubtitle}%
}%
\newunit%
}%
\printfield{maintitleaddon}%
}
\newbibmacro*{booktitle:noemph}{%
\ifboolexpr{
test {\iffieldundef{booktitle}}
and
test {\iffieldundef{booksubtitle}}
}%
{}%
{%
\printtext{%
\printfield[titlecase]{booktitle}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{booksubtitle}%
}%
\newunit%
}%
\printfield{booktitleaddon}%
}
\newbibmacro*{inproc:crossref:full}{%
\ifboolexpr{
test {\ifnameundef{editor}}
and
test {\ifnameundef{editora}}
and
test {\ifnameundef{editorb}}
and
test {\ifnameundef{editorc}}
and
test {\ifnameundef{translator}}
}%
{}%
{%
\usebibmacro{byeditor+others}\newcommaunit%
}%
\usebibmacro{maintitle+booktitle}%
\newunit
\usebibmacro{event+venue+date}%
\newcommaunit
\iffieldundef{maintitle}{%
\printfield{volume}%
\printfield{part}%
\ifboolexpr{
test {\iffieldundef{volume}}
and
test {\iffieldundef{part}}
}%
{}%
{%
\setunit{\addspace\bibstring{ofseries}\addspace}%
}%
}%
{}%
\usebibmacro{series+number:emphcond}%
\newcommaunit
\iffieldundef{maintitle}{%
\printfield{volumes}%
\newcommaunit%
}%
{}%
}
\newbibmacro*{inproc:crossref:extra}{%
\newcommaunit
\printlist{location}%
\newcommaunit
\printfield{edition}%
\newunit
\printlist{organization}%
\newcommaunit*%
\printlist{publisher}%
\newcommaunit
\usebibmacro{date}%
\newunit\newblock
\usebibmacro{doi+eprint+url+issn}
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
}
\newbibmacro*{inproc:crossref:conditional}{%
\entrydata*{\strfield{crossref}}{%
\iffieldsequal{doi}{saveddoi}%
{\global\booltrue{bbxtrad:doisequal}}%
{\global\boolfalse{bbxtrad:doisequal}}%
\iffieldsequal{eprint}{savedeprint}%
{\global\booltrue{bbxtrad:eprintsequal}}%
{\global\boolfalse{bbxtrad:eprintsequal}}%
\iffieldsequal{url}{savedurl}%
{\global\booltrue{bbxtrad:urlsequal}}%
{\global\boolfalse{bbxtrad:urlsequal}}%
\iffieldsequal{note}{savednote}%
{\global\booltrue{bbxtrad:notesequal}}%
{\global\boolfalse{bbxtrad:notesequal}}%
\iffieldsequal{addendum}{savedaddendum}%
{\global\booltrue{bbxtrad:addendumsequal}}%
{\global\boolfalse{bbxtrad:addendumsequal}}%
}
\newunit\newblock
\iftoggle{bbx:doi}
{\ifbool{bbxtrad:doisequal}{}{\printfield{saveddoi}}}
{}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\ifbool{bbxtrad:eprintsequal}{}{\usebibmacro{eprint}}}
{}%
\newunit\newblock
\iftoggle{bbx:url}
{\ifbool{bbxtrad:urlsequal}{}{\usebibmacro{url+urldate}}}
{}%
\newunit\newblock
\ifbool{bbxtrad:notesequal}{}{\printfield{note}}%
\newunit\newblock
\ifbool{bbxtrad:addendumsequal}{}{\printfield{addendum}}%
}
\newbibmacro*{journal+date+issuetitle}{%
\usebibmacro{journal}%
\usebibmacro{date}
\newcommaunit*%
\iffieldundef{series}
{}
{%
\newunit
\printfield{series}%
\setunit{\addcomma\space}%
}%
\usebibmacro{volume+number+pages+eid}%
\newcommaunit
% \setunit{\addspace}%
\usebibmacro{issue-parens}%
\setunit*{\addcolon\space}%
\usebibmacro{issue}%
\newunit%
}
\newbibmacro*{volume+number+pages+eid}{%
\printfield{volume}%
\setunit*{\volumenumberdelim}%
\printfield{number}%
\setunit{\addcolon}
\printfield{pages}%
\newcommaunit
\printfield{eid}%
}
\renewbibmacro*{byeditor+others}{%
\ifnameundef{editor}
{}
{%
\printnames[byeditor]{editor}%
\setunit{\addcomma\space}%
\usebibmacro{editorlstr}%
\clearname{editor}%
\newunit%
}%
\usebibmacro{byeditorx}%
\usebibmacro{bytranslator+others}%
}
\newbibmacro*{editorlstr}{%
\ifboolexpr{
test {\ifnumgreater{\value{editor}}{1}}
or
test {\ifandothers{editor}}
}%
{\biblstring{editors}}%
{\biblstring{editor}}%
}
\renewbibmacro*{series+number}{%
\printfield{number}%
\setunit*{\addspace\bibstring{inseries}\addspace}%
\printfield{series}%
\newunit%
}
\newbibmacro*{series+number:emphcond}{%
\printfield{number}%
\setunit*{\addspace\bibstring{inseries}\addspace}%
\ifboolexpr{
not test {\iffieldundef{volume}}
}%
{\printfield{series}}%
{%
\ifboolexpr{
test {\iffieldundef{volume}}
and
test {\iffieldundef{part}}
and
test {\iffieldundef{number}}
and
test {\ifentrytype{book}}
}%
{\newunit\newblock}%
{}%
\printfield[noformat]{series}%
}%
\newunit%
}
\newbibmacro*{book:series+number}{%
\iffieldundef{maintitle}%
{%
\printfield{volume}%
\printfield{part}%
\ifboolexpr{
test {\iffieldundef{volume}}
and
test {\iffieldundef{part}}
}%
{}%
{\setunit{\addspace\bibstring{ofseries}\addspace}}%
}%
{}%
\usebibmacro{series+number:emphcond}%
\newunit%
}
\renewbibmacro*{volume+number+eid}{%
\printfield{volume}%
\setunit*{\volumenumberdelim}%
\printfield{number}%
\setunit{\addcomma\space}%
\printfield{eid}%
}
\renewbibmacro*{publisher+location+date}{%
\printlist{publisher}%
\newcommaunit*%
\printlist{location}%
\newcommaunit*%
\printfield{edition}%
\newcommaunit*%
\usebibmacro{date}%
\newunit%
}
\renewbibmacro*{institution+location+date}{%
\printlist{institution}%
\newcommaunit*%
\printlist{location}%
\printlist{location}%
\newcommaunit*%
\usebibmacro{date}%
\newunit%
}
\newbibmacro*{location+date+publisher}{%
\printlist{location}%
\newcommaunit*%
\printfield{edition}%
\newcommaunit*%
\usebibmacro{date}%
\newunit
\printlist{publisher}%
}
\newbibmacro*{issue-parens}{%
\printfield{issue}%
\newunit%
}
\newbibmacro*{doi+eprint+url+issn}{%
\iftoggle{bbx:doi}
{\printfield{doi}}
{%
\iftoggle{bbx:isbn}
{\printfield{issn}}
{%
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{%
\iftoggle{bbx:url}
{\usebibmacro{url+urldate}}
{}
}%
}%
}%
}
\endinput
\end{filecontents*}
\begin{filecontents*}{references.bib}
@phdthesis{Test2018,
author = {Doe, John},
school = {University of Foo},
department = {Department for eggs and bacon},
title = {{Studies on the cooking time of eggs and bacon, searching for the perfect symbiosis.}},
type = {Master's Thesis},
year = {2018}
}
\end{filecontents*}
\usepackage[backend = biber, style = custom-abbrv, citestyle = numeric-comp]{biblatex}
\addbibresource{references.bib}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\cite{Test2018}
\printbibliography
\end{document}
答案1
biblatex
无法识别department
为有效字段。您需要在样式dbx
文件中指定它。由于您正在编写样式,因此您只需调用它custom-abbrev.dbx
并biblatex
在指定样式时将其拾取即可。
在这个答案中,我使用了datamodel
选项来指定这一点,并且只是用作trad-standard
风格来简化正在发生的事情。
其他一些注意事项:
biblatex
更喜欢institution
而不是school
。- 您可以使您的风格自动使用句子大小写。
- 您应该使用
type={mathesis}
可以为您提供与语言无关的字符串
institution
(和location
)在默认情况下是列表biblatex
(意味着它们可以有多个条目)。在这个答案中,我将部门设为字段并使用打印它\printfield
,但如果您认为您可能需要多个部门来与多个机构配合,您可以将其设为列表。
我通过重新定义宏来打印部门institution+location+date
。
平均能量损失
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{department.dbx}
\DeclareDatamodelFields[type=field, datatype=literal]{
department}
\end{filecontents}
\begin{filecontents}{\jobname.bib}
@thesis{Test2018,
author = {Doe, John},
institution = {University of Foo},
department = {Department for Eggs and Bacon},
title = {Studies on the Cooking Time of Eggs and Bacon, Searching for the Perfect Symbiosis},
type = {mathesis},
year = {2018}
}
\end{filecontents}
\usepackage[datamodel=department,style=trad-standard,giveninits]{biblatex}
\addbibresource{\jobname.bib}
\DeclareFieldFormat[thesis]{title}{\mkbibquote{#1}}
\DeclareFieldFormat{titlecase}{\MakeSentenceCase{#1}}
\DeclareDelimFormat[bib,biblist]{nametitledelim}{\addcolon\space}
\renewbibmacro*{institution+location+date}{%
\printlist{institution}%
\newcommaunit*%
\printfield{department}%
\newcommaunit*%
\printlist{location}%
\newcommaunit*%
\usebibmacro{date}%
\newunit}
\begin{document}
\nocite{*}
\printbibliography
\end{document}