新的 bib(la)tex-entrytype 用于音乐乐谱

新的 bib(la)tex-entrytype 用于音乐乐谱

简短的问题:如何创建一个新的条目类型(@music),其中包含作曲家、标题、作品、编辑、系列、地点和年份等字段?

\begin{filecontents*}{\jobname.bib}
@music{citekey,
    composer={Johann Sebastian Bach},
    title={Motetten},
    number={BWV 225--230},
%   opus={}, % no opus in this case
    editor={Konrad Ameln},
    series={Neue Bach-Ausgabe Serie III, Band 1},
    loaction={Kassel},
    publisher={Bärenreiter},
    year={1965},
}
\end{filecontents*}

\documentclass[ngerman]{scrartcl}
\usepackage[style=authortitle]{biblatex}
\bibliography{\jobname}

\begin{document}
\cite{citekey} should look like

Johann Sebastian Bach: Motetten. BWV 225-230, hrsg von Konrad Ameln
= Neue Bach-Ausgabe Serie III, band 1. Kassel: Bärenreiter, 1965

or in general

(composer): (title)[, (opus)][, (number)][hrsg. von (editor)][= (series)].
[(location)][: (publisher)][, (year)][.]

where (xxx)=field and [yyy]=optional

\printbibliography
\end{document}

答案1

\documentclass[ngerman]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[style=authortitle,backend=biber]{biblatex}
\DeclareBibliographyDriver{music}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{usera}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{maintitle+title}%
  \newunit
  \printfield{userb}%
  \newunit\newblock
  \printfield{number}%
  \newunit
  \usebibmacro{byeditor+others}%
  \setunit{=\addspace}
  \printfield{series}%
  \setunit{\adddot\addspace}
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \usebibmacro{finentry}}

\renewcommand{\labelnamepunct}{\addcolon\space}
\renewcommand*{\newunitpunct}{\addcomma\space}
\DeclareFieldFormat{title}{#1}

\bibliography{9}
\begin{document}
\cite{citekey} should look like

Johann Sebastian Bach: Motetten. BWV 225-230, hrsg von Konrad Ameln
= Neue Bach-Ausgabe Serie III, band 1. Kassel: Bärenreiter, 1965

or in general

(composer): (title)[, (opus)][, (number)][hrsg. von (editor)][= (series)].
[(location)][: (publisher)][, (year)][.]

where (xxx)=field and [yyy]=optional

\printbibliography
\end{document}

以及对应的.bib文件:

@music{citekey,
    usera={Johann Sebastian Bach},
    userb={myopus},
    title={Motetten},
    number={BWV 225--230},
    editor={Konrad Ameln},
    series={Neue Bach-Ausgabe Serie III, Band 1},
    location={Kassel},
    publisher={Bärenreiter},
    year={1965},
}

在此处输入图片描述

答案2

我的回答很大程度上建立在Thorsten的回答之上。我添加了以下修改:

  • 我没有使用作曲家的自定义字段,而是利用了字段author和基于该字段构建的 bibmacros。否则(如 Thorsten 的示例),书目条目将在书目中列在作曲家下,但文内引用将显示编辑者的名字(我想这不是人们想要的)。

  • 用于作品的自定义字段的格式应默认为“op.~”加上字段的内容(因此无需每次都输入“op.~”)。我已经自定义了格式,以便userc如果定义了此字段(例如“BWV”),它将使用字段的内容作为前缀。

  • 我添加了对反向引用的支持。可以通过删除相应的包选项来关闭这些引用。

该字段的内容series可能应该分成几个单独的字段,但是我暂时不考虑它。

\documentclass{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage[style=authortitle,backref=true]{biblatex}

\DeclareBibliographyDriver{music}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
%   \printfield{usera}% DELETED
  \usebibmacro{author/editor+others/translator+others}% NEW
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{maintitle+title}%
  \newunit
  \printfield{userb}%
%   \newunit\newblock% DELETED
  \newunit% NEW
  \printfield{number}%
%   \newunit% DELETED
  \newunit\newblock% NEW
  \usebibmacro{byeditor+others}%
  \setunit{=\addspace}
  \printfield{series}%
%   \setunit{\adddot\addspace}% DELETED
  \setunit{\addperiod\space}% NEW
  \usebibmacro{publisher+location+date}%
%   \newunit\newblock% DELETED
  \setunit{\bibpagerefpunct}\newblock% NEW
  \usebibmacro{pageref}% NEW
  \usebibmacro{finentry}%
}

\renewcommand*{\labelnamepunct}{\addcolon\space}
\renewcommand*{\newunitpunct}{\addcomma\space}
% \DeclareFieldFormat{title}{#1}% DELETED
\DeclareNameAlias{sortname}{first-last}% NEW
\DeclareFieldFormat{userb}{% NEW
  \iffieldundef{userc}{%
    op.~#1%
  }{%
    \printfield{userc}~#1%
  }%
}
\DeclareFieldFormat{number}{\bibstring{number}~#1}% NEW

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@music{citekey,
  author = {Johann Sebastian Bach},
  title = {Motetten},
  userb = {225--230},
  userc = {BWV},
  editor = {Konrad Ameln},
  series = {Neue Bach-Ausgabe Serie III, Band 1},
  volume = {1},
  location = {Kassel},
  publisher = {Bärenreiter},
  year = {1965},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

Ein wenig Text \autocite{citekey}.

\printbibliography

\end{document}

相关内容