多次引用同一作者且没有日期 - 如何删除“a”周围的括号,例如 (Johansson nd [a])?

多次引用同一作者且没有日期 - 如何删除“a”周围的括号,例如 (Johansson nd [a])?

我试图管理引用比布拉特克斯作者年份-icp 样式很难让引文和参考书目看起来完全符合我所在大学的要求。通过阅读本网站上其他人的问题和答案,我设法纠正了大多数错误,但仍有一个问题。当我有同一作者撰写的两个不同参考文献并且两个参考文献都没有日期时,我希望它们看起来如下所示。

在正文中:

字字珠玑(Johansson u.å. a)。

字字珠玑(Johansson u.å. b)。

在参考书目中:

约翰逊(Johansson),S.(u.å.a)。太阳。 [2018-04-12]。

约翰逊(Johansson),S.(u.å. b)。地球。 [2018-04-12]。

相反,我得到-在文本中:

单词单词单词单词(Johansson u.å.[a])。

单词单词单词单词(Johansson u.å.[b])。

在参考书目中:

约翰逊(Johansson),S.(u.å.[a])。太阳。 [2018-04-12]。

约翰逊(Johansson),S.(u.å.[b])。地球。 [2018-04-12]。

有没有什么办法可以去掉括号?我还希望这适用于所有类型的参考。

\documentclass[a4paper, 12pt]{article}
\usepackage[swedish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}

% Biblatex
\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sorting=nyc,
    isbn=false, 
    doi=true, 
    dashed=false, 
    maxbibnames=99,
   uniquename=init,
    giveninits 
  ]{biblatex}

\addbibresource{test.bib}

%--changes to get citations and bibliography the way my university wants---- 
\DeclareFieldFormat[article]{title}{#1}
\renewbibmacro{in:}{}

\renewcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

\DefineBibliographyStrings{swedish}{%
  andothers = {et\addabbrvspace al\adddot}
}

%u.å is swedish for n.d. (no date)
\newcommand{\mkbibnodate}{u\adddot å\adddot}
\AtEveryCitekey{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}
\AtEveryBibitem{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}

\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}
\NewBibliographyString{available}

%tillgänglig is swedish for available
\DefineBibliographyStrings{swedish}{%
  available = {Tillgänglig},
}

\DeclareFieldFormat{url}{\bibstring{available}\addcolon\space\url{#1}}

%", Vol. x (x),"
 \DeclareFieldFormat[article]{volume}{vol. #1}

\renewbibmacro*{volume+number+eid}{%
 \setunit{\addcomma\space}%
  \printfield{volume}%
  \setunit*{\addnbspace}% 
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

%"ss. XX-XX."
\DeclareFieldFormat[article]{pages}{ss. #1 \adddot}

\DeclareNameAlias{sortname}{last-first}

\DeclareSortingScheme{nyc}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{\citeorder}
}
%----------------end of changes------------------
\begin{document}
Word word word word \parencite{johansson_sun_????}. \\
Word word word word \parencite{johansson_earth_????}.\\

\printbibliography
\end{document}

(u.å 是瑞典语,表示 nd(无日期))。

我的.bib 文件:

@online{johansson_sun_????,
    title = {Sun},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}

@online{johansson_earth_????,
    title = {Earth},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}

答案1

好吧,要实现你想要的,还有一些事情要做。@samcarter 提到的代码行似乎试图覆盖 的底层机制labeldate。我在这里假设你只想对online条目这样做,而不是让urldate取代labeldate。这是通过注释提到的代码行并重新定义字段来完成的,labeldate其中考虑了:

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  % \field{urldate}
  \literal{nodate}
}

您还希望为“nd”添加本地化字符串。这通常应该可以立即使用。但该特定字符串swedish.lbx%FIXME。(您可能希望在https://github.com/plk/biblatex/issues。biblatex 的本地化字符串的维护依赖于母语人士来提供它们)。无论如何,目前,您必须将字符串添加到您的\DefineBibliographyString

nodate = {u\adddot å\adddot},

最后,要删除 extradate 的括号,可以使用:

\DeclareFieldFormat{extradate}{%
  \iffieldnums{labelyear}
    {\mknumalph{#1}}
    {\addnbthinspace\mknumalph{#1}}}

我还将您已弃用的版本更改\DeclareSortingScheme为当前的版本\DeclareSortingTemplate

将所有内容放在一起(通过@moewe 对您的 biblatex 定制进行彻底更新):

\documentclass[a4paper, 12pt]{article}
\usepackage[swedish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}

% Biblatex
\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sorting=nyc,
    isbn=false, 
    doi=true, 
    dashed=false, 
    maxbibnames=99,
    uniquename=init,
    giveninits 
  ]{biblatex}

\addbibresource{test.bib}

%--changes to get citations and bibliography the way my university wants---- 
\DeclareFieldFormat[article]{title}{#1}
\renewbibmacro{in:}{}

% \renewcommand*{\finalnamedelim}{%
%   \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
%   \addspace\&\space}
\DeclareDelimFormat{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}


%u.å is swedish for n.d. (no date) % better to do this with the
%localized "nodate" string
% \newcommand{\mkbibnodate}{u\adddot å\adddot}
% \AtEveryCitekey{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}
% \AtEveryBibitem{\iffieldundef{year}{\restorefield{labelyear}{\mkbibnodate}}{}}

% do not consider "urldate" as a candidate for labeldate
\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  % \field{urldate}
  \literal{nodate}
}

% This is the original definition
% \DeclareFieldFormat{extradate}{%
%   \iffieldnums{labelyear}
%     {\mknumalph{#1}}
%     {\mkbibparens{\mknumalph{#1}}}}
% If you don't want brackets in any case:
\DeclareFieldFormat{extradate}{%
  \iffieldnums{labelyear}
    {\mknumalph{#1}}
    {\addnbthinspace\mknumalph{#1}}}

\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}
% \NewBibliographyString{available}

%tillgänglig is swedish for available
\DefineBibliographyStrings{swedish}{%
  % available = {Tillgänglig},
  urlfrom     = {Tillgänglig},
  andothers   = {et\addabbrvspace al\adddot},
  nodate      = {u\adddot å\adddot}, % added: that currently stands with a % FIXME in swedish.lbx
  pages       = {ss\adddot},
}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}

%", Vol. x (x),"
% \DeclareFieldFormat[article]{volume}{vol. #1}
\DeclareFieldFormat[article]{volume}{\bibstring{volume}~#1}

\renewbibmacro*{volume+number+eid}{%
  \setunit{\addcomma\space}%
  \printfield{volume}%
  \setunit*{\addnbspace}% 
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

%"ss. XX-XX."
% \DeclareFieldFormat[article]{pages}{ss. #1 \adddot}
\DeclareFieldFormat{pages}{\mkpageprefix[bookpagination]{#1}}

% \DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{sortname}{family-given}

\DeclareSortingTemplate{nyc}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{\citeorder}
}
%----------------end of changes------------------
\begin{document}
Word word word word \parencite{johansson_sun_????}.

Word word word word \parencite{johansson_earth_????}.

\printbibliography
\end{document}

在此处输入图片描述

编辑:moewe 在以下网址提供了 Overleaf 当前 biblatex 版本 (3.4) 的工作设置https://www.overleaf.com/read/ydgxhpnsfyxs

我把代码也留在这里:

\documentclass[a4paper, 12pt]{article}
\usepackage[swedish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}

% Biblatex
\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sorting=nyc,
    isbn=false, 
    doi=true, 
    dashed=false, 
    maxbibnames=99,
    uniquename=init,
    giveninits 
  ]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{johansson_sun_????,
    title = {Sun},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}

@online{johansson_earth_????,
    title = {Earth},
    author = {Johansson, Sven},
    urldate = {2018-04-12},
}
\end{filecontents}
\addbibresource{\jobname.bib}

%--changes to get citations and bibliography the way my university wants---- 
\DeclareFieldFormat[article]{title}{#1}
\renewbibmacro{in:}{}

\renewcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  % \field{urldate}
  \literal{nodate}
}

%u.å is swedish for n.d. (no date)
\DeclareFieldFormat{extrayear}{%
  \iffieldnums{labelyear}
    {\mknumalph{#1}}
    {\addnbthinspace\mknumalph{#1}}}

\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}
% \NewBibliographyString{available}

%tillgänglig is swedish for available
\DefineBibliographyStrings{swedish}{%
  urlfrom   = {Tillgänglig},
  andothers = {et\addabbrvspace al\adddot},
  nodate    = {u\adddot å\adddot}, % added: that currently stands with a % FIXME in swedish.lbx
  pages     = {ss\adddot},
}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}

%", Vol. x (x),"
% \DeclareFieldFormat[article]{volume}{vol. #1}
\DeclareFieldFormat[article]{volume}{\bibstring{volume}~#1}

\renewbibmacro*{volume+number+eid}{%
  \setunit{\addcomma\space}%
  \printfield{volume}%
  \setunit*{\addnbspace}% 
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

%"ss. XX-XX."
% \DeclareFieldFormat[article]{pages}{ss. #1 \adddot}
\DeclareFieldFormat{pages}{\mkpageprefix[bookpagination]{#1}}

% \DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{sortname}{family-given}
\DeclareSortingScheme{nyc}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{\citeorder}
}
%----------------end of changes------------------
\begin{document}
Word word word word \parencite{johansson_sun_????}. \\
Word word word word \parencite{johansson_earth_????}.\\

\printbibliography
\end{document}

相关内容