BibLaTeX 名称格式

BibLaTeX 名称格式

我为 biblatex 定制了一个 bbx 文件。我希望以这种方式获取参考资料:

[namepartprefix] [namepartfamily], [namepartgiveni] ...

不幸的是,名称前缀前有一些虚假空格(见下面的附件),我无法消除它们。我知道您必须注意源代码中行末的空格。我在 bbx 文件的所有相关行的末尾都放了一些 % 符号。但是,它不能正常工作。我的错误在哪里?

另外,作为引文出现的标签名称中缺少名称前缀。我该如何将 von/de 等部分插入到标签中?


bbx-文本.tex

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}

\usepackage[backend=biber,style=epicstructure,sorting=nyt]{biblatex}
    \addbibresource{test-companion.bib}

\begin{document}


\nocite{*}
\printbibliography
\end{document}

测试-companion.bib:

@Book{Alpha:2002,
  author    = {Beta von Alpha},
  year      = {2002},
  title     = {Book title},
  edition   = {2},
  note      = {(= optional note)},
  keywords  = {Walter,KAetGen},
  publisher = {Chicago},
}

@book{Gamma:2015,
    editor = {Delta Gamma and Zeta Epsilon and Sigma Rho},
    Publisher = {Berlin},
    Title = {Another book},
    Year = {2015},
    edition = {3}}

@article{Iota:1998,
    Author = {Kappa Iota},
    Journal = {journal name},
    Volume = {24},
    Pages = {11--18},
    Title = {article title},
    Year = {1998},
    keywords={KAetGen}}

@incollection{Ny:2018,
    Author = {Lambda Ny},
    Booktitle = {book title},
    Editor = {E. Ditor},
    Pages = {93--129},
    Publisher = {London},
    Title = {article title},
    Year = {2018}}

史诗结构.bbx:

\ProvidesFile{epicstructure.bbx}[2018/06/29 v1.0 biblatex bibliography style]

% Load the standard style to avoid copy-pasting unnecessary material
\RequireBibliographyStyle{authoryear}

\ExecuteBibliographyOptions{dashed=true}
\setlength{\bibparsep}{0em}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Eigene Änderungen                           %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Titel kursiv
\DeclareFieldFormat{title}{\mkbibemph{#1}\isdot}
\DeclareFieldFormat[article]{title}{#1}
\DeclareFieldFormat[inbook,incollection]{title}{#1}


%%% Seitenzahlen in Zitaten ohne "S. " davor
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

%%% Seiten bei article ohne "pp. "
\DeclareFieldFormat{pages}{#1}
\newcommand*{\bibpagespunctarticle}{\addcolon\addspace}
\newcommand*{\bibpagespunctincollinbook}{\adddot\addspace}


%%% "/" zwischen mehreren Autoren
\renewcommand*{\multinamedelim}{\addslash}%
\renewcommand*{\finalnamedelim}{\addslash}%
\renewcommand*{\multilistdelim}{\addslash}%
\renewcommand*{\finallistdelim}{\addslash}%


\DeclareNameFormat{author}{%
  \ifblank{\namepartprefix}{}{\namepartprefix\addspace}%
  \namepartfamily%
    \ifblank{\namepartgiven}{}{\addcomma\addspace\namepartgiveni}%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\multinamedelim}%
    {}%
}

\DeclareNameFormat{editor}{%
%  \ifblank{\namepartprefix}{}{\namepartprefix\addspace}%
  \namepartfamily%
    \ifblank{\namepartgiven}{}{\addcomma\addspace\namepartgiveni}%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\multinamedelim}%
    {}%
}

\DeclareNameFormat{reversed}{%
  \ifblank{\namepartgiven}{}{\namepartgiveni\addspace}%
  \ifblank{\namepartprefix}{}{\namepartprefix\addspace}%
  \namepartfamily%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\multinamedelim}%
    {}%
}

\renewbibmacro*{author}{%
  \ifboolexpr{%
    test \ifuseauthor%
    and%
    not test {\ifnameundef{author}}%
  }%
    {\printnames[author]{author}}%
    {}%
}

\renewbibmacro*{editor}{%
  \ifboolexpr{%
    test \ifuseeditor%
    and%
    not test {\ifnameundef{editor}}%
  }%
    {\printnames[author]{editor}}%
    {}%
}

\renewbibmacro*{author/editor}{%
  \ifboolexpr{%
    test \ifuseauthor%
    and%
    not test {\ifnameundef{author}}%
  }%
    {\usebibmacro{author}}%
    {\usebibmacro{editor}}%
}


\newbibmacro*{pages+article}{%
  \setunit{\bibpagespunctarticle}%
  \printfield{pages}%
  \newunit%
}


\renewcommand*{\bibnamedash}{%
    \rule[.5ex]{2em}{.15ex}.%
}


%%% ed./eds.
\DefineBibliographyStrings{english}{%
  editor={ed\adddot},%
  editors={eds\adddot},%
  in={in}%
}

\newbibmacro*{editorstrng}{%
  \ifthenelse{\value{editor}>1}%\OR\ifandothers{editor}}%
    {\bibstring{editors}}%
    {\bibstring{editor}}%
}

\DeclareFieldFormat{edition}{%
  #1%
}

\newbibmacro*{editionsupscr}{%
  \iffieldundef{edition}%
    {}%
    {\textsuperscript{\printfield{edition}}}%
}

%%% (year)//(ed., year) -- article/book
\newbibmacro*{editor+edition+year}{%
  \ifnameundef{editor}%
    {\mkbibparens{\usebibmacro{editionsupscr}\printfield{year}}}%
    {\mkbibparens{\usebibmacro{editorstrng}\addcomma\addspace\usebibmacro{editionsupscr}\printfield{year}}}%
}

%%% (year) -- inbook/incoll
\newbibmacro*{yearinbkcoll}{%
  \mkbibparens{\printfield{year}}%
}



\newbibmacro*{reversed:author}{%
    \printnames[reversed]{author}%
}

\newbibmacro*{reversed:editor}{%
    \printnames[reversed]{editor}\addspace\mkbibparens{\usebibmacro{editorstrng}}%
}


\renewbibmacro*{in:}{%
  \biblcstring{in}\intitlepunct%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\renewbibmacro*{publisher+location+date}{%
  \printlist{publisher}%
  \iflistundef{publisher}%
    {\setunit*{\addcomma\addspace}}%
    {\setunit*{\addcolon\addspace}}%
  \printlist{location}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
  \newunit%
}

\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
%  \setunit*{\adddot}%
  \iffieldundef{number}{}{(\printfield{number})}%
  \setunit{\addcomma\addspace}%
  \printfield{eid}%
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Änderungen an Bibliography-Drivern          %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% article: FERTIG
\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor}\addspace%
  \usebibmacro{editor+edition+year}\newunit\newblock%
  \usebibmacro{title}\addcomma%
  \newunit%
  \usebibmacro{journal+issuetitle}%
  \newunit%
  \usebibmacro{pages+article}%
  \usebibmacro{finentry}%
}



%%% book: FERTIG
\DeclareBibliographyDriver{book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor}\addspace%
  \usebibmacro{editor+edition+year}\newunit\newblock%
  \usebibmacro{maintitle+title}%
  \newunit%
  \iffieldundef{maintitle}%
    {\printfield{volume}%
     \printfield{part}}%
    {}%
  \newunit%
  \printfield{volumes}%
  \newunit\newblock%
  \usebibmacro{series+number}%
  \newunit\newblock%
  \usebibmacro{publisher+location+date}%
  \newunit\newblock%
  \printfield{note}%
  \usebibmacro{finentry}%
}



%%% inbook: work
\DeclareBibliographyDriver{inbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author}\addspace%
  \usebibmacro{yearinbkcoll}\newunit\newblock%
  \usebibmacro{title}%
  \newunit\newblock%
  \usebibmacro{in:}%
  \usebibmacro{reversed:editor}%
  \newunit\newblock%
  \usebibmacro{maintitle+booktitle}%
  \newunit\newblock%
  \usebibmacro{publisher+location+date}\adddot%
  \printfield{pages}%
  \printfield{note}%
  \usebibmacro{finentry}%
}


\DeclareBibliographyAlias{incollection}{inbook}

\endinput

史诗结构.cbx:

\ProvidesFile{epicstructure.cbx}
[\abx@cbxid]

\ExecuteBibliographyOptions{labeldateparts,uniquename,uniquelist,autocite=inline}

\renewcommand*{\iffinalcitedelim}{\iflastcitekey}

\newbool{cbx:parens}

\newbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}}
       {\printnames[bibhyperref]{labelname}%
        \setunit{\printdelim{nameyeardelim}}}%
     \usebibmacro{cite:labeldate+extradate}}
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{citeyear}{%
  \iffieldundef{shorthand}
    {\iffieldundef{labelyear}
       {\usebibmacro{cite:label}}
       {\usebibmacro{cite:labeldate+extradate}}}
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{textcite}{%
  \ifnameundef{labelname}
    {\iffieldundef{shorthand}
       {\usebibmacro{cite:label}%
        \setunit{%
          \global\booltrue{cbx:parens}%
          \printdelim{nonameyeardelim}\bibopenparen}%
        \ifnumequal{\value{citecount}}{1}
          {\usebibmacro{prenote}}
          {}%
        \usebibmacro{cite:labeldate+extradate}}
       {\usebibmacro{cite:shorthand}}}
    {\printnames[bibhyperref]{labelname}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \printdelim{nameyeardelim}\bibopenparen}%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{citeyear}}}

\newbibmacro*{cite:shorthand}{%
  \printtext[bibhyperref]{\printfield{shorthand}}}

\newbibmacro*{cite:label}{%
  \iffieldundef{label}
    {\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}
    {\printtext[bibhyperref]{\printfield{label}}}}

\newbibmacro*{cite:labeldate+extradate}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[bibhyperref]{\usebibmacro{editionsupscr}\printlabeldateextra}}}

\newbibmacro{cite:labelyear+extrayear}{%
  \blx@warning{bibmacro 'cite:labelyear+extrayear' is deprecated.\MessageBreak
    Please use 'cite:labeldate+extradate'.\MessageBreak
    Using 'cite:labeldate+extradate' instead}%
  \usebibmacro{cite:labeldate+extradate}}

\newbibmacro*{textcite:postnote}{%
  \iffieldundef{postnote}
    {\ifbool{cbx:parens}
       {\bibcloseparen}
       {}}
    {\ifbool{cbx:parens}
       {\setunit{\postnotedelim}}
       {\setunit{\extpostnotedelim\bibopenparen}}%
     \printfield{postnote}\bibcloseparen}}

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}%[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibparens\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \iffirstcitekey
     {\setcounter{textcitetotal}{1}}
     {\stepcounter{textcitetotal}%
      \textcitedelim}%
   \usebibmacro{textcite}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}}
  {\usebibmacro{textcite:postnote}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames[bibhyperref]{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames[bibhyperref][1-1]{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\printfield[bibhyperref]{year}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\citeyear}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\printfield[bibhyperref]{\usebibmacro{editionsupscr}year}\printfield{extradate}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\textcites}{\textcite}{}

\endinput

在此处输入图片描述

答案1

主要问题是使用\ifblank来检查名称部分是否为空。由于名称部分是宏,因此必须使用\ifdefvoid\ifblank检查提供的字符串是否为空,但\ifdefvoid检查提供的命令序列是否扩展为空字符串(或多或少)。

所以你的名字格式应该是

\DeclareNameFormat{author}{%
  \ifdefvoid{\namepartprefix}{}{\namepartprefix\addspace}%
  \namepartfamily%
    \ifdefvoid{\namepartgiven}{}{\addcomma\addspace\namepartgiveni}%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\multinamedelim}%
    {}%
}

\DeclareNameFormat{editor}{%
%  \ifdefvoid{\namepartprefix}{}{\namepartprefix\addspace}%
  \namepartfamily%
    \ifdefvoid{\namepartgiven}{}{\addcomma\addspace\namepartgiveni}%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\multinamedelim}%
    {}%
}

\DeclareNameFormat{reversed}{%
  \ifdefvoid{\namepartgiven}{}{\namepartgiveni\addspace}%
  \ifdefvoid{\namepartprefix}{}{\namepartprefix\addspace}%
  \namepartfamily%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\multinamedelim}%
    {}%
}

但我相信,

\DeclareNameAlias{sortname}{family-given}

\DeclareNameAlias{reversed}{given-family}

与其他选项一起使用useprefix=true,giveninits=true可以用更少的工作获得相同的结果。


请参阅§4.11.7使用标点符号追踪器手册biblatex。您不应该\addspace在参考书目驱动程序中使用裸 s。它们应该始终被包装在\setunit(或\setunit*) 中。

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor}
  \setunit{\addspace}%
  \usebibmacro{editor+edition+year}
  \newunit\newblock%
  \usebibmacro{title}
  \setunit{\addcomma}%
  \usebibmacro{journal+issuetitle}%
  \newunit%
  \usebibmacro{pages+article}%
  \usebibmacro{finentry}%
}

还有一些其他的事情。

multinamedelim和朋友现在是上下文相关的,所以我会使用

\DeclareDelimFormat{multinamedelim}{\addslash}%
\DeclareDelimAlias{finalnamedelim}{multinamedelim}%
\DeclareDelimFormat{multilistdelim}{\addslash}%
\DeclareDelimAlias{finallistdelim}{multilistdelim}%

author我认为,只要发出选项,您就可以摆脱重新定义dashed=false。为此editor,可能需要做更多工作……

\mkbibparens切勿在 bibmacros 中使用或 其他直接标点符号或格式命令。请改用\DeclareFieldFormat\printtext(\DeclareFieldFormat通常是更好的选择,但有时也需要\printtext)。

\DeclareFieldFormat{superedition}{%
  \ifinteger{#1}
    {}
    {\PackageWarning{epicstructure}{%
       Hang on! #1 does not look like an integer edition.\MessageBreak
       I will print it as superscript,\MessageBreak but it might look weird}}%
  \textsuperscript{#1}%
}

%%% (year)//(ed., year) -- article/book
\newbibmacro*{editor+edition+year}{%
  \printtext[parens]{%
    \ifnameundef{editor}%
      {}
      {\usebibmacro{editorstrng}%
       \setunit{\addcomma\space}}%
    \printfield[superedition]{edition}%
    \iflabeldateisdate
      {\printlabeldate}
      {\printfield{year}}% <- still don't like that...
  }%
}

yearinbkcoll可以使用全局选项date=year,然后

\newbibmacro*{yearinbkcoll}{%
  \iffieldundef{year}
    {}
    {\printtext[parens]{\printdate}}%
}

\newbibmacro*{reversed:editor}{%
    \printnames[reversed]{editor}%
    \setunit{\addspace}
    \printtext[parens]{\usebibmacro{editorstrng}}%
}
\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}

\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
%  \setunit*{\adddot}%
  \printfield{number}%
  \setunit{\addcomma\addspace}%
  \printfield{eid}%
}

相关内容