对于我的论文的目录,当期刊文章中没有期刊号时,我想在卷号后添加一个逗号。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xpatch}
\usepackage[backend=biber, citestyle=nejm, sorting=none, natbib=true, isbn=false, url=false, doi=true, eprint = false, giveninits]{biblatex}
% remove pp
\DeclareFieldFormat{pages}{#1}
% No dot before number of articles
\xpatchbibmacro{volume+number+eid}{%
\setunit*{\adddot}%
}{%
}{}{}
% Number of articles in parentheses
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}\addcomma}
% Comma before date; date not in parentheses
\renewbibmacro*{issue+date}{%
\setunit*{\addcomma\space}%
\iffieldundef{issue}
{\usebibmacro{date}}
{\printfield{issue}%
\setunit*{\addspace}%
\usebibmacro{date}}%
\newunit}
% comma after journal
\renewbibmacro*{journal+issuetitle}{%
\usebibmacro{journal}%
\setunit*{\addcomma\space}%
\iffieldundef{series}
{}
{\newunit
\printfield{series}%
\setunit{\addspace}}%
\usebibmacro{volume+number+eid}%
\setunit{\addspace}%
\usebibmacro{issue+date}%
\setunit{\addcolon\space}%
\usebibmacro{issue}%
\newunit}
\usepackage{filecontents}
\begin{filecontents}{sample.bib}
@article{einstein,
author = {Albert Einstein},
title = {On the electrodynamics of moving bodies},
journal = {Annalen der Physik},
volume = {322},
number = {10},
pages = {891--921},
year = {1905},
DOI = {http://dx.doi.org/10.1002/andp.19053221004}
}
@article{test,
author = {Example, Author},
journal = {Journal},
pages = {2},
title = {{Test paper}},
volume = {5},
year = {2018}
}
\end{filecontents}
\addbibresource{sample.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
我尝试修改此问题的代码,询问在没有卷号(https://tex.stackexchange.com/questions/199301/change-separator-for-articles-in-journals-without-volume-number-biblatex)时更改分隔符的问题编号:
\renewcommand*{\bibpagespunct}{%
\ifentrytype{article}{%
\iffieldundef{number}
{\addcomma\space}}
{\space}}
但是,当存在发行号而不是我的预定目的时,这会消除年份和页面范围之间的空格和逗号。请有人帮忙告诉我我要去哪里。
答案 0 :(得分:0)
我通过在\DeclareBibliographyDriver
中插入以下代码来解决此问题。
\iffieldundef{number}
{\addcomma\space}
{\printfield{number}\addcomma\space}
这是我的代码块。
\DeclareBibliographyDriver{article}{%
\printnames{author}%
\printfield{year}%
\printfield{title}%
\usebibmacro{journal}%
% \usebibmacro{volume+number+eid}%
\printfield{volume}%
\iffieldundef{number}
{\addcomma\space}
{\printfield{number}\adddot\space}%
\iffieldundef{pages}
{}
{\printfield{pages}\adddot}%
尽管参考格式可能有所不同,但您可能会得到我尝试在此处提供的主要思想。