BibLaTex - 在引用和参考书目中标记编辑器(标签名称)

BibLaTex - 在引用和参考书目中标记编辑器(标签名称)

从作者年份样式开始,我定制了输出。大多数方法都有效。缺少的是让编辑者脱颖而出(具有某种标记,如参考书目条目本身)。我猜labelname需要进行一些定制,特别是因为它在参考书目中重复使用begentry

\documentclass{scrreprt}
\usepackage[
    backend=biber,
    sortlocale=auto,
    defernumbers=false,     % don't need continous numbers for the bibliography
    citestyle=authoryear,
    maxcitenames=3,
    citetracker=false,
    ibidtracker=false,
    idemtracker=false,
    opcittracker=false,
    minnames=3,
    bibstyle=authoryear,
    maxbibnames=99,
    url=true,               % print URL and access date
    doi=false,              % print DOI
    eprint=false,           % don't print eprint
    dashed=false,           % don't replace repeated authors by dash lines
]{biblatex}
\usepackage{hyperref}

% in foot cite year in parantheses
\renewbibmacro*{cite:labeldate+extradate}{%
    \iffieldundef{labelyear}%
    {}%
    {%
        \printtext[bibhyperref]{%
            \mkbibparens{\printlabeldateextra}%
        }%
    }%
}

% add a section like header to the bibliography with the same key we have in the cite
\renewbibmacro*{begentry}{%
    \begingroup
    \textbf{
        \printnames{labelname}%
        \setunit{\addspace}%
        % reuse layout from cite
        \usebibmacro{cite:labeldate+extradate}%
    }
    \endgroup \\
}

\DeclareBibliographyDriver{report}{%
    \usebibmacro{bibindex}%
    \usebibmacro{begentry}%
    \ifnameundef{author}%
    {\usebibmacro{editor}}%
    {\usebibmacro{author}}%
    \setunit{\printdelim{nametitledelim}}\newblock
    \iffieldequalstr{type}{RFC}%
    {% for RFCs only
        \printfield{type}%
        \setunit*{\addspace}%
        \printfield{number}%
        \addcolon%
        \setunit*{\addspace}%
    }
    {}%
    \usebibmacro{title}%
    \newunit
    \printlist{language}%
    \newunit\newblock
    \usebibmacro{byauthor}%
    \newunit\newblock
    \iffieldequalstr{type}{RFC}%
    {}% for RFCs only
    {% for all expect RFCs
        \printfield{type}%
        \setunit*{\addspace}%
        \printfield{number}%
        \newunit\newblock
    }
    \printfield{version}%
    \newunit
    \printfield{note}%
    \newunit\newblock
    \usebibmacro{institution+location+date}%
    \newunit\newblock
    \usebibmacro{chapter+pages}%
    \newunit
    \printfield{pagetotal}%
    \newunit\newblock
    \iftoggle{bbx:isbn}
    {\printfield{isrn}}
    {}%
    \newunit\newblock
    \usebibmacro{doi+eprint+url}%
    \newunit\newblock
    \usebibmacro{addendum+pubstate}%
    \setunit{\bibpagerefpunct}\newblock
    \usebibmacro{pageref}%
    \newunit\newblock
    \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
        \usebibmacro{related}}
    {}%
    \usebibmacro{finentry}}


\begin{filecontents}[overwrite]{\jobname.bib}
@TechReport{RFC0760,
    institution  = {RFC Editor},
    title        = {DoD standard Internet Protocol},
    doi          = {10.17487/rfc0760},
    language     = {en},
    number       = {760},
    pagetotal    = {42},
    type         = {RFC},
    url          = {https://tools.ietf.org/html/rfc760},
    editor       = {Jon Postel},
    howpublished = {Internet Requests for Comments},
    issn         = {2070-1721},
    month        = {1},
    publisher    = {RFC Editor},
    year         = {1980},
}
@TechReport{RFC0768,
    institution  = {RFC Editor},
    title        = {User Datagram Protocol},
    doi          = {10.17487/RFC0768},
    language     = {en},
    number       = {768},
    pagetotal    = {3},
    type         = {RFC},
    url          = {https://rfc-editor.org/rfc/rfc768.txt},
    editor       = {Jon Postel},
    howpublished = {Internet Requests for Comments},
    issn         = {2070-1721},
    month        = {8},
    publisher    = {RFC Editor},
    year         = {1980},
}
@TechReport{RFC0791,
    institution  = {RFC Editor},
    title        = {Internet Protocol},
    doi          = {10.17487/RFC0791},
    language     = {en},
    number       = {791},
    pagetotal    = {45},
    type         = {RFC},
    url          = {https://www.rfc-editor.org/rfc/rfc791.txt},
    editor       = {Jon Postel},
    howpublished = {Internet Requests for Comments},
    issn         = {2070-1721},
    month        = {9},
    publisher    = {RFC Editor},
    year         = {1981},
}
@TechReport{RFC1338,
    author       = {Fuller, Vincent and Li, Tony and Yu, Jessica and Varadhan, Kannan},
    institution  = {RFC Editor},
    title        = {Supernetting: an Address Assignment and Aggregation Strategy},
    doi          = {10.17487/rfc1338},
    language     = {en},
    number       = {1338},
    pagetotal    = {20},
    type         = {RFC},
    url          = {https://rfc-editor.org/rfc/rfc1338.txt},
    howpublished = {Internet Requests for Comments},
    issn         = {2070-1721},
    month        = {6},
    publisher    = {RFC Editor},
    year         = {1992},
}
@WWW{RIPE2019,
    author   = {{RIPE NCC}},
    date     = {2019-08-23},
    title    = {What is IPv4 Run Out?},
    url      = {https://www.ripe.net/manage-ips-and-asns/ipv4/ipv4-run-out},
    urldate  = {2020-10-11},
    urltime  = {14:57},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
    Some reference\footcite[See][]{RFC0791} and specifically\footcite[See][p. 2]{RFC0791}.
    Some reference\footcite[See][]{RFC0760} and specifically\footcite[See][p. 2]{RFC0768}.
    Also interesting.\footcite[See][]{RFC1338} Another reference\footcite[See][]{RIPE2019}.

    \printbibliography
\end{document}

因此,Postel (1981)我希望它是Postel, ed. (1981)(在 begentry 中均引用)。

答案1

labelname您可以使用 检查当前名称的“类型” labelnamesource。然后只需选择正确的宏来打印“ed”。

在下面的代码中,这是用来实现的cite:labelname

begentry请注意,如果您重复使用bibmacro,您可以使您的代码生活变得更轻松一些cite

\documentclass{article}
\usepackage[
  backend=biber,
  style=authoryear,
  minnames=3,
  maxcitenames=3,
  maxbibnames=99,
  url=true,               % print URL and access date
  doi=false,              % print DOI
  eprint=false,           % don't print eprint
  dashed=false,           % don't replace repeated authors by dash lines
]{biblatex}
\usepackage{hyperref}

\newbibmacro{cite:labelname}{%
  \printnames{labelname}%
  \iffieldequalstr{labelnamesource}{author}
    {\setunit{\printdelim{authortypedelim}}%
     \usebibmacro{authorstrg}}
    {\iffieldequalstr{labelnamesource}{editor}
       {\setunit{\printdelim{editortypedelim}}%
        \usebibmacro{editor+othersstrg}}
       {\iffieldequalstr{labelnamesource}{translator}
         {\setunit{\printdelim{editortypedelim}}%
          \usebibmacro{translator+othersstrg}}
         {}}}}

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}}
       {\usebibmacro{cite:labelname}%
        \setunit{\printdelim{nameyeardelim}}}%
     \usebibmacro{cite:labeldate+extradate}}
    {\usebibmacro{cite:shorthand}}}

% in foot cite year in parantheses
\renewbibmacro*{cite:labeldate+extradate}{%
  \iffieldundef{labelyear}%
    {}
    {\printtext[bibhyperref]{%
       \mkbibparens{\printlabeldateextra}}}}

% add a section like header to the bibliography with the same key we have in the cite
\renewbibmacro*{begentry}{%
  \textbf{%
    \usebibmacro{cite}}\\
}

\DeclareBibliographyDriver{report}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \ifnameundef{author}%
  {\usebibmacro{editor}}%
  {\usebibmacro{author}}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \iffieldequalstr{type}{RFC}%
  {% for RFCs only
      \printfield{type}%
      \setunit*{\addspace}%
      \printfield{number}%
      \addcolon%
      \setunit*{\addspace}%
  }
  {}%
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \iffieldequalstr{type}{RFC}%
  {}% for RFCs only
  {% for all expect RFCs
      \printfield{type}%
      \setunit*{\addspace}%
      \printfield{number}%
      \newunit\newblock
  }
  \printfield{version}%
  \newunit
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{institution+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit
  \printfield{pagetotal}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
  {\printfield{isrn}}
  {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
  {\usebibmacro{related:init}%
      \usebibmacro{related}}
  {}%
  \usebibmacro{finentry}}


\begin{filecontents}{\jobname.bib}
@TechReport{RFC0760,
  institution  = {RFC Editor},
  title        = {DoD standard Internet Protocol},
  doi          = {10.17487/rfc0760},
  language     = {en},
  number       = {760},
  pagetotal    = {42},
  type         = {RFC},
  url          = {https://tools.ietf.org/html/rfc760},
  editor       = {Jon Postel},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {1},
  publisher    = {RFC Editor},
  year         = {1980},
}
@TechReport{RFC0768,
  institution  = {RFC Editor},
  title        = {User Datagram Protocol},
  doi          = {10.17487/RFC0768},
  language     = {en},
  number       = {768},
  pagetotal    = {3},
  type         = {RFC},
  url          = {https://rfc-editor.org/rfc/rfc768.txt},
  editor       = {Jon Postel},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {8},
  publisher    = {RFC Editor},
  year         = {1980},
}
@TechReport{RFC0791,
  institution  = {RFC Editor},
  title        = {Internet Protocol},
  doi          = {10.17487/RFC0791},
  language     = {en},
  number       = {791},
  pagetotal    = {45},
  type         = {RFC},
  url          = {https://www.rfc-editor.org/rfc/rfc791.txt},
  editor       = {Jon Postel},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {9},
  publisher    = {RFC Editor},
  year         = {1981},
}
@TechReport{RFC1338,
  author       = {Fuller, Vincent and Li, Tony and Yu, Jessica and Varadhan, Kannan},
  institution  = {RFC Editor},
  title        = {Supernetting: an Address Assignment and Aggregation Strategy},
  doi          = {10.17487/rfc1338},
  language     = {en},
  number       = {1338},
  pagetotal    = {20},
  type         = {RFC},
  url          = {https://rfc-editor.org/rfc/rfc1338.txt},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {6},
  publisher    = {RFC Editor},
  year         = {1992},
}
@WWW{RIPE2019,
  author   = {{RIPE NCC}},
  date     = {2019-08-23},
  title    = {What is IPv4 Run Out?},
  url      = {https://www.ripe.net/manage-ips-and-asns/ipv4/ipv4-run-out},
  urldate  = {2020-10-11},
  urltime  = {14:57},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
  Some reference\footcite[See][]{RFC0791}
  and specifically\footcite[See][2]{RFC0791}.
  Some reference\footcite[See][]{RFC0760}
  and specifically\footcite[See][2]{RFC0768}.
  Also interesting.\footcite[See][]{RFC1338}
  Another reference\footcite[See][]{RIPE2019}.

  \printbibliography
\end{document}

Postel 编辑(1980a)


正如我所写https://github.com/plk/biblatex/issues/1062您可能会受益于使用捆绑包中的样式biblatex-ext警告我是该捆绑包的作者),因为它使一些事情变得更容易一些。

\documentclass{article}
\usepackage[
  backend=biber,
  style=ext-authoryear,
  minnames=3,
  maxcitenames=3,
  maxbibnames=99,
  introcite=plain,
  autocite=footnote,
  url=true,
  doi=false,
  eprint=false,
  dashed=false,
]{biblatex}
\usepackage{hyperref}

\DeclareInnerCiteDelims{footcite}{\bibopenparen}{\bibcloseparen}

\DeclareFieldFormat{bbx@introcite}{\mkbibbold{#1}}
\renewcommand*{\introcitepunct}{\\}

\DeclareInnerCiteDelimsAlias{bbx@introcite}{footcite}

% no need for the extradate label in the bibliography with introcite
\renewbibmacro*{date+extradate}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[parens]{%
       \iflabeldateisdate
         {\printdate}
         {\printlabeldate}}}}

\newbibmacro{cite:labelname}{%
  \printnames{labelname}%
  \iffieldequalstr{labelnamesource}{author}
    {\setunit{\printdelim{authortypedelim}}%
     \usebibmacro{authorstrg}}
    {\iffieldequalstr{labelnamesource}{editor}
       {\setunit{\printdelim{editortypedelim}}%
        \usebibmacro{editor+othersstrg}}
       {\iffieldequalstr{labelnamesource}{translator}
         {\setunit{\printdelim{editortypedelim}}%
          \usebibmacro{translator+othersstrg}}
         {}}}}

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}}
       {\usebibmacro{cite:labelname}%
        \setunit{\printdelim{nameyeardelim}}}%
     \usebibmacro{cite:labeldate+extradate}}
    {\usebibmacro{cite:shorthand}}}


\DeclareBibliographyDriver{report}{%
  \usebibmacro{introcite:plain}%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \iffieldequalstr{type}{RFC}%
    {% for RFCs only
      \printfield{type}%
      \setunit*{\addnbspace}%
      \printfield{number}%
      \printunit*{\addcolon\space}%
    }
    {}%
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \iffieldequalstr{type}{RFC}%
    {}% for RFCs only
    {% for all except RFCs
      \printfield{type}%
      \setunit*{\addspace}%
      \printfield{number}%
      \newunit\newblock
    }%
  \printfield{version}%
  \newunit
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{institution+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit
  \printfield{pagetotal}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isrn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}


\begin{filecontents}{\jobname.bib}
@TechReport{RFC0760,
  institution  = {RFC Editor},
  title        = {DoD standard Internet Protocol},
  doi          = {10.17487/rfc0760},
  language     = {en},
  number       = {760},
  pagetotal    = {42},
  type         = {RFC},
  url          = {https://tools.ietf.org/html/rfc760},
  editor       = {Jon Postel},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {1},
  publisher    = {RFC Editor},
  year         = {1980},
}
@TechReport{RFC0768,
  institution  = {RFC Editor},
  title        = {User Datagram Protocol},
  doi          = {10.17487/RFC0768},
  language     = {en},
  number       = {768},
  pagetotal    = {3},
  type         = {RFC},
  url          = {https://rfc-editor.org/rfc/rfc768.txt},
  editor       = {Jon Postel},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {8},
  publisher    = {RFC Editor},
  year         = {1980},
}
@TechReport{RFC0791,
  institution  = {RFC Editor},
  title        = {Internet Protocol},
  doi          = {10.17487/RFC0791},
  language     = {en},
  number       = {791},
  pagetotal    = {45},
  type         = {RFC},
  url          = {https://www.rfc-editor.org/rfc/rfc791.txt},
  editor       = {Jon Postel},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {9},
  publisher    = {RFC Editor},
  year         = {1981},
}
@TechReport{RFC1338,
  author       = {Fuller, Vincent and Li, Tony and Yu, Jessica and Varadhan, Kannan},
  institution  = {RFC Editor},
  title        = {Supernetting: an Address Assignment and Aggregation Strategy},
  doi          = {10.17487/rfc1338},
  language     = {en},
  number       = {1338},
  pagetotal    = {20},
  type         = {RFC},
  url          = {https://rfc-editor.org/rfc/rfc1338.txt},
  howpublished = {Internet Requests for Comments},
  issn         = {2070-1721},
  month        = {6},
  publisher    = {RFC Editor},
  year         = {1992},
}
@WWW{RIPE2019,
  author   = {{RIPE NCC}},
  date     = {2019-08-23},
  title    = {What is IPv4 Run Out?},
  url      = {https://www.ripe.net/manage-ips-and-asns/ipv4/ipv4-run-out},
  urldate  = {2020-10-11},
  urltime  = {14:57},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
  Some reference\autocite[See][]{RFC0791} and specifically\autocite[See][2]{RFC0791}.
  Some reference\autocite[See][]{RFC0760} and specifically\autocite[See][2]{RFC0768}.
  Also interesting.\autocite[See][]{RFC1338} Another reference\autocite[See][]{RIPE2019}.

  \printbibliography
\end{document}

相关内容