本周我已经在以下问题上得到了一些帮助。我必须用作者年份格式写一篇论文,其中包含参考书目。但是,有些特殊的条目类型(如规范)必须以不同的方式出现。虽然书籍和文章可以正常工作,但参考书目中的规范必须如下所示:
DIN 18351-1:2006-10:标题, 版本。
在我想要的文本中:文本文本文本(DIN 18351-1, 2010)
这里我得到了我尝试修改的脚本的第一个版本: 除作者年份样式外的书目条目
在原始版本中,文本“DIN”由 手动写入文本和参考书目中 \printtext{DIN}
。现在我尝试定义一个字段,如“institute”,其中我可以写入例如 ISO、DIN、VDI 等。我通过 \DeclareFieldFormat[norm]{institute}{#1} 定义了一个新字段“institute”,并尝试用 printfield{institute} 替换 \printtext{DIN ISO},但它在编译时没有出现。而且我还有一个问题,因为没有作者,我不知道它最终会如何排序。如果您能帮助我,我将不胜感激!
这是我目前得到的:
\documentclass{article}
\usepackage[
%style = alphabetic,
citestyle=authoryear-comp,
bibstyle=authoryear,
]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@norm{diniso18351,
title = {Title},
number = {18351-1},
version = {Entwurf},
%pubstate = {DIN ISO 18351-1:2010-06},
date = {2010-06},
institute = {VDI}},
@book{Kaltschmitt.2003,
year = {2003},
title = {Erneuerbare Energien: Systemtechnik, Wirtschaftlichkeit, Umweltaspekte},
address = {Berlin, Heidelberg and s.l.},
edition = {dritte, vollst{\"a}ndig neu bearbeitete und erweiterte Auflage},
publisher = {{Springer Berlin Heidelberg}},
isbn = {978-3-662-07116-8},
editor = {Kaltschmitt, Martin and Wiese, Andreas and Streicher, Wolfgang},
doi = {10.1007/978-3-662-07115-1}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
% add new diniso entry type
\DeclareDatamodelEntrytypes{
norm}
% set bibliography label template for diniso entry type
\DeclareLabelalphaTemplate[norm]{%
\labelelement{
\field{number}
}
}
% use comma before year in citations without authors
% this will apply to all entry types
\renewcommand*{\nonameyeardelim}{\addcomma\space}
% field formats for diniso entry type
\DeclareFieldFormat[norm]{version}{#1}
\DeclareFieldFormat[norm]{institute}{#1}
%\DeclareFieldFormat[norm]{pubstate}{\mkbibparens{#1}}
\DeclareFieldFormat[norm]{date}{%
\thefield{year}%
\bibdatesep
\mkmonthzeros{\thefield{month}}}
% custom driver for diniso entry type
\DeclareBibliographyDriver{norm}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
% \printtext{DIN EN ISO}%
\printfield{institute}% This field is not printed
\setunit{\addspace}%
\printfield{number}%
\setunit{\addcolon}%
\printdate
\setunit{\addcolon\space}%
\usebibmacro{title}%
\setunit{\addcomma\space}%
\printfield{version}%
\setunit{\addspace}%
%\printfield{pubstate}%
\usebibmacro{finentry}}
% custom citation label for diniso entry type
\newbibmacro*{cite:label}{%
\iffieldundef{label}
{\ifentrytype{norm}
{\printtext[bibhyperref]{%
%\printtext{DIN EN1 ISO}%
\printfield{institute}% This field is not printed
\printfield{number}
\setunit{\addspace}%
}}
{\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}}
{\printtext[bibhyperref]{\printfield{label}}}}
\pagestyle{empty}
\begin{document}
\section{First section}
quote 1 \parencite{diniso18351}\\
quote 2 \parencite{Kaltschmitt.2003}
\printbibliography
\end{document}
答案1
问题是institute
不是 中的默认字段名称biblatex
。您需要使用以下命令声明它:
\begin{filecontents*}{norm.dbx}
\DeclareDatamodelEntrytypes{
norm}
\DeclareDatamodelFields[type=field,datatype=literal]{
institute,
}
\DeclareDatamodelEntryfields[norm]{
institute,
}
\end{filecontents*}
然后datamodel=norm
在添加包时使用该选项biblatex
。
\usepackage[
%style = alphabetic,
datamodel=norm,
citestyle=authoryear-comp,
bibstyle=authoryear,
]{biblatex}
}
请注意,必须出现逗号或右括号直接地after institute
:否则字段名称会添加尾随空格。请参阅这个答案了解详情。
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{norm.dbx}
\DeclareDatamodelEntrytypes{
norm}
\DeclareDatamodelFields[type=field,datatype=literal]{
institute,
}
\DeclareDatamodelEntryfields[norm]{
institute,
}
\end{filecontents*}
\begin{filecontents*}{\jobname.bib}
@norm{diniso18351,
title = {Title},
number = {18351-1},
version = {Entwurf},
%pubstate = {DIN ISO 18351-1:2010-06},
date = {2010-06},
institute = {VDI}},
@book{Kaltschmitt.2003,
year = {2003},
title = {Erneuerbare Energien: Systemtechnik, Wirtschaftlichkeit, Umweltaspekte},
address = {Berlin, Heidelberg and s.l.},
edition = {dritte, vollst{\"a}ndig neu bearbeitete und erweiterte Auflage},
publisher = {{Springer Berlin Heidelberg}},
isbn = {978-3-662-07116-8},
editor = {Kaltschmitt, Martin and Wiese, Andreas and Streicher, Wolfgang},
doi = {10.1007/978-3-662-07115-1}
}
\end{filecontents*}
\usepackage[
%style = alphabetic,
datamodel=norm,
citestyle=authoryear-comp,
bibstyle=authoryear,
]{biblatex}
\addbibresource{\jobname.bib}
% set bibliography label template for diniso entry type
\DeclareLabelalphaTemplate[norm]{%
\labelelement{
\field{number}
}
}
% use comma before year in citations without authors
% this will apply to all entry types
\renewcommand*{\nonameyeardelim}{\addcomma\space}
% field formats for diniso entry type
\DeclareFieldFormat[norm]{version}{#1}
\DeclareFieldFormat[norm]{institute}{#1}
%\DeclareFieldFormat[norm]{pubstate}{\mkbibparens{#1}}
\DeclareFieldFormat[norm]{date}{%
\thefield{year}%
\hyphen
{\thefield{month}}}
% custom driver for diniso entry type
\DeclareBibliographyDriver{norm}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
% \printtext{DIN EN ISO}%
\printfield{institute}% This field is not printed
\setunit{\addspace}%
\printfield{number}%
\setunit{\addcolon}%
\printdate
\setunit{\addcolon\space}%
\usebibmacro{title}%
\setunit{\addcomma\space}%
\printfield{version}%
\setunit{\addspace}%
%\printfield{pubstate}%
\usebibmacro{finentry}}
% custom citation label for diniso entry type
\newbibmacro*{cite:label}{%
\iffieldundef{label}
{\ifentrytype{norm}
{\printtext[bibhyperref]{%
%\printtext{DIN EN1 ISO}%
\printfield{institute}% This field is not printed
\printfield{number}
\setunit{\addspace}%
}}
{\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}}
{\printtext[bibhyperref]{\printfield{label}}}}
\pagestyle{empty}
\begin{document}
\section{First section}
quote 1 \parencite{diniso18351}\\
quote 2 \parencite{Kaltschmitt.2003}
\printbibliography
\end{document}