平均能量损失

平均能量损失

我的样式只有一个、和 的biblatex缩写列表。这很容易做到,但有些条目同时包含和。我有一个使用条目克隆源映射来执行此操作的有效方法,但想知道是否有人有更简洁的解决方案。shorthandshortseriesshortjournalshorthandshortseries

我当前的方法存在一个潜在问题:如果带有shorthand和的条目shortseries有一个xref字段,那么这个信息就会丢失,因为我覆盖了它以指向克隆的条目(否则它不会出现在简写列表中)。

欢迎任何建议。

平均能量损失

这小于 MWE 给出了一个相当复杂的例子来说明我目前如何做到这一点。

笔记:除非您使用的是最新的开发版本biblatex,否则您需要在选项中替换minxrefs为。mincrossrefsbiblatex

\documentclass{article}
\usepackage{xparse}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{ABC,
  author = {Grayson, Albert Kirk},
  title = {Assyrian and Babylonian Chronicles},
  series = {Texts from Cuneiform Sources},
  shortseries = {TCS},
  number = {5},
  location = {Locust Valley, NY},
  publisher = {Augustin},
  date = {1975},
  shorthand = {\mkbibemph{ABC}}
}
@misc{esarhaddonchronicle,
  title = {Esarhaddon Chronicle},
  xref = {ABC},
  related = {ABC},
  options = {skipbib}
}
\end{filecontents}
\usepackage[style=verbose,minxrefs=1,backend=biber]{biblatex}
\ExplSyntaxOn
\cs_generate_variant:Nn \__xparse_split_argument:nnn { nno }
\cs_new_eq:NN \eSplitArgument  \__xparse_split_argument:nno
\DeclareDocumentCommand \splitpostnote
{ > { \eSplitArgument { 1 } { | } } m }
{ \savepostnotes #1 }
\DeclareDocumentCommand{\savepostnotes}{mm}{%
  \IfNoValueTF{#2}
    {\gdef\postnotelast{#1}}
    {\tl_if_empty:nF {#1}
       {\gdef\postnotefirst{#1}}%
     \tl_if_empty:nF {#2}
       {\gdef\postnotelast{#2}}}}
\ExplSyntaxOff

\makeatletter
\def\setuppostnotes{%
  \global\undef\postnotefirst
  \global\undef\postnotelast
  \splitpostnote{\abx@field@postnote}}
\makeatother

\renewbibmacro*{prenote}{%
  \iffieldundef{postnote}
    {}
    {\setuppostnotes
     \restorefield{postnote}{\postnotelast}%
     \restorefield{altpostnote}{\postnotefirst}}%
  \iffieldundef{prenote}
    {}
    {\printfield{prenote}%
     \setunit{\prenotedelim}}}

\DeclareFieldFormat{altpostnote}{\mkcomprange{#1}}
\DeclareFieldFormat{postnote}{\mkcomprange{#1}}

\renewbibmacro*{postnote}{%
  \iffieldundef{postnote}
    {}
    {\iffieldundef{related}
       {\printfield{postnote}}
       {}}}

\renewbibmacro*{cite}{%
  \usebibmacro{cite:citepages}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:full}}
    {\usebibmacro{cite:shorthand}}}

\DeclareBibliographyDriver{misc}{%
  \usebibmacro{begentry}%
  \usebibmacro{title}%
  \setunit{\postnotedelim}%
  \printfield{altpostnote}%
  \setunit{\addspace}%
  \printtext[parens]{%
    \usebibmacro{related:init}%
    \usebibmacro{related}%
    \setunit{\postnotedelim}%
    \printfield{postnote}}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{book}{%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \newunit
  \printfield{title}%
  \newunit
  \usebibmacro{byauthor}
  \newunit
  \printfield{shortseries}%
  \setunit{\addspace}%
  \printfield{number}%
  \newunit
  \usebibmacro{publisher+location+date}%
  \usebibmacro{finentry}}

\DeclareFieldFormat[misc]{title}{#1}

\renewbibmacro*{related:default}[1]{%
  \ifciteseen
    {\entrydata*{#1}{\printfield{shorthand}}}
    {\entrydata*{#1}{\usedriver{}{\thefield{entrytype}}}}}

\newlength{\abbrevwidth}

\def\setmaxlength#1#2{%
  \ifdim\dimexpr#2>\dimexpr#1
    \global\setlength{#1}{#2}%
  \fi
}

\defbibenvironment{shorthand}
  {\list
     {\printfield[shorthandwidth]{shorthand}%
      \ifboolexpr{
        not test {\iffieldundef{shorthand}}
        and
        not test {\iffieldundef{shortseries}}
      }
        {}
        {\printfield[shorthandwidth]{shortseries}}}
     {\setmaxlength{\abbrevwidth}{\shorthandwidth}%
      \setmaxlength{\abbrevwidth}{\shortserieswidth}%
      \setlength{\labelwidth}{\abbrevwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\DeclareBiblistFilter{shorthand}{
  \filteror{
    \filter[type=field,filter=shorthand]
    \filter[type=field,filter=shortseries]
  }
}

\DeclareSortingScheme{shorthand}{%
  \sort{%
    \field{shorthand}%
    \field{shortseries}%
  }%
}

\DeclareBibliographyDriver{shorthand}{%
  \iffieldundef{shorthand}
    {\printfield{series}}
    {\usedriver
       {}
       {\thefield{entrytype}}}
  \finentry}

\DeclareSourcemap{
  \maps{
    \map[overwrite]{
      \step[fieldsource=shortseries, final]
      \step[fieldsource=shorthand, final]
      \step[fieldsource=shorthand, fieldtarget=usera]
      \step[fieldsource=options, fieldtarget=userb]
      \step[fieldset=options, fieldvalue={,skipbib}, append]
      \step[entryclone={shortseries-}]
      \step[fieldsource=usera, fieldtarget=shorthand]
      \step[fieldset=options, null]
      \step[fieldsource=userb, fieldtarget=options]
      \step[fieldsource=entrykey, match=\regexp{(.*)}]
      \step[fieldset=xref, fieldvalue={shortseries-$1}]
    }
  }
}

\addbibresource{\jobname.bib}
\begin{document}
\strut\vfill
\autocite[lines 3--4|125]{esarhaddonchronicle}
\autocite[lines 3--4|125]{esarhaddonchronicle}
\printbiblist{shorthand}
\printbibliography
\end{document}

答案1

bilatex和的最新开发版本biber(感谢@plk)现在允许这个源映射代码,它更加优雅:

\DeclareSourcemap{
  \maps{
    \map{
      \step[fieldsource=shortseries, final]
      \step[fieldsource=shorthand, final]
      \step[fieldsource=entrykey, match=\regexp{(.*)}]
      \step[fieldset=xref, fieldvalue=series-$1]
      \step[entrynew=series-$1, entrynewtype=misc]
      \step[fieldsource=shortseries]
      \step[fieldset=shorthand, origfieldval, entrytarget=series-$1]
      \step[fieldsource=series]
      \step[fieldset=note, origfieldval, entrytarget=series-$1]
      \step[fieldset=options, fieldvalue=skipbib, entrytarget=series-$1]
    }
  }
}

相关内容