style=authoryear 在参考书目列表前面添加额外块

style=authoryear 在参考书目列表前面添加额外块

这是我用来生成第一个参考书目的命令。但是我想要第二张图片的格式,即在参考文献前面有一个额外的块。文件可以在下面的 onedrive 链接中找到。

\documentclass{article}

\usepackage[citestyle=authoryear-comp,bibstyle=authortitle,sorting=nyt,dashed=false,%
    maxcitenames=1]{biblatex}

\newcounter{mymaxcitenames}
\AtBeginDocument{%
  \setcounter{mymaxcitenames}{\value{maxnames}}%
}

\renewbibmacro*{begentry}{%
  \printtext[brackets]{%
    \begingroup
    \defcounter{maxnames}{\value{mymaxcitenames}}%
    \printnames{labelname}%
    \setunit{\nameyeardelim}%
    \usebibmacro{cite:labelyear+extrayear}%
    \endgroup
    }%
  \quad% or \addspace
}

\DeclareNameAlias{sortname}{first-last}

\usepackage{filecontents}

\begin{filecontents}{biblatextest.bib}
@misc{A01,
  author = {Author, A. and Buthor, B.},
  year = {2001},
  title = {Alpha},
}
\end{filecontents}

\addbibresource{biblatextest.bib}

\begin{document}

Some text \autocite{A01}.

\printbibliography

\end{document}

https://onedrive.live.com/redir?resid=231B471A96C9FC0E!1268&authkey=!ALCb5Oz421IDx0w&ithint=file%2cpdf

现在命令以这种样式生成参考书目:

在此处输入图片描述

但我希望它像这样:

在此处输入图片描述

答案1

这个答案大量使用奥黛丽非常棒回答表格书目biblatex锁住在参考书目条目开头添加 [AuthorYear] 块的答案

\printbibtabular除了我们只需要的定义

\newcounter{mymaxcitenames}
\AtBeginDocument{%
  \setcounter{mymaxcitenames}{\value{maxnames}}%
}

\newbibmacro*{bibcite}{%
  \defcounter{maxnames}{\value{mymaxcitenames}}%
    \iffieldundef{shorthand}
      {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
         {\usebibmacro{cite:label}%
          \setunit{\addspace}}
         {\printnames{labelname}%
          \setunit{\nameyeardelim}}%
       \usebibmacro{cite:labelyear+extrayear}}
      {\usebibmacro{cite:shorthand}}}

最后一段代码取自于authoryear.cbx,它将模拟这里的引用行为(我们没有从中获取代码,authoryear-comp以避免不必要的引用压缩,在某些情况下这会让我们只剩下年份)。

那么适当的bibtabular格式可以是

\defbibtabular{bibtabular}
  {\begin{tabular}{p{0.2\textwidth}p{0.8\textwidth}}}
  {\end{tabular}}
  {\usebibmacro{bibcite}}
  {}

平均能量损失

\documentclass{article}

\usepackage[citestyle=authoryear-comp, bibstyle=authortitle, sorting=nyt, dashed=false,%
    maxcitenames=1]{biblatex}


\DeclareNameAlias{sortname}{first-last}

\addbibresource{biblatex-examples.bib}

\makeatletter

% user-level command for printing tabular bibliography
\let\printbibtabular\printbibliography
\patchcmd{\printbibtabular}{\blx@printbibliography}{\bbx@printbibtabular}{}{}
\patchcmd{\printbibtabular}{\blx@printbibliography}{\bbx@printbibtabular}{}{}
\let\bbx@printbibtabular\blx@printbibliography
\patchcmd{\bbx@printbibtabular}{\blx@bibliography}{\bbx@bibtabular}{}{}
\patchcmd{\bbx@printbibtabular}
  {\def\blx@theenv{bibliography}}{\def\blx@theenv{bibtabular}}{}{}

% underlying macros
\def\bbx@bibtabular#1{%
  \blx@bibheading\blx@theheading\blx@thetitle
  \blx@bibnote\blx@theprenote
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@bibempty
  \ifnum\bibinitsep=\z@
    \let\blx@initsep\relax
  \fi
  \ifnum\bibnamesep=\z@
    \let\blx@namesep\relax
  \fi
  \csuse{blx@hook@bibinit}%
  % copy filtered list of entries to internal list macro
  \def\blx@do##1{%
    \blx@ifdata{##1}{%
      \begingroup
      \blx@getdata{##1}
      \blx@bibcheck
      \iftoggle{blx@skipentry}{}{%
        \global\let\blx@noitem\@empty
        \listadd\blx@tempa{##1}}%
      \endgroup}{}}
  \let\blx@done\relax
  \blx@listloop{#1}
  % tabular output for each item in list macro
  \def\do##1{\bbx@tab@label{##1} & \bbx@tab@item{##1} \\}
  \csuse{blx@env@\blx@theenv}%
  \dolistloop{\blx@tempa}
  \csuse{blx@endenv@\blx@theenv}%
  \blx@bibnote\blx@thepostnote
  \endgroup}

\def\bbx@tab@label#1{%
  \begingroup
  \blx@getdata{#1}%
  \blx@setoptions@type\abx@field@entrytype
  \blx@setoptions@entry
  \blx@thelabelnumber
  \blx@addprefixnumber
  \addtocounter{instcount}\@ne
  \csuse{bbx@tabenv@\blx@theenv}\relax
  \endgroup}

\def\bbx@tab@item#1{%
  \begingroup
  \blx@getdata{#1}%
  \blx@setoptions@type\abx@field@entrytype
  \blx@setoptions@entry
  \csuse{blx@item@\blx@theenv}\relax
  \blx@initsep
  \blx@namesep
  \csuse{blx@hook@bibitem}%
  \blx@execute
  \blx@initunit
  \blx@anchor
  \blx@beglang
  \bibsentence
  \blx@pagetracker
  \blx@driver\abx@field@entrytype
  \blx@postpunct
  \blx@endlang
  \endgroup}

% user-level command for defining tabular bibliography format
\newrobustcmd*{\defbibtabular}[5]{%
  \long\csdef{blx@env@#1}{#2}%
  \long\csdef{blx@endenv@#1}{#3}%
  \long\csdef{bbx@tabenv@#1}{#4}%
  \long\csdef{blx@item@#1}{#5}}

\makeatother

\newcounter{mymaxcitenames}
\AtBeginDocument{%
  \setcounter{mymaxcitenames}{\value{maxnames}}%
}

\newbibmacro*{bibcite}{%
  \defcounter{maxnames}{\value{mymaxcitenames}}%
    \iffieldundef{shorthand}
      {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
         {\usebibmacro{cite:label}%
          \setunit{\addspace}}
         {\printnames{labelname}%
          \setunit{\nameyeardelim}}%
       \usebibmacro{cite:labelyear+extrayear}}
      {\usebibmacro{cite:shorthand}}}

\defbibtabular{bibtabular}
  {\begin{tabular}{p{0.2\textwidth}p{0.8\textwidth}}}
  {\end{tabular}}
  {\usebibmacro{bibcite}}
  {}

\begin{document}

Some text \autocite{sigfridsson, geer, nussbaum, worman, knuth:ct:b, knuth:ct:c}.

\printbibtabular
\end{document}

表格书目:左栏包含 \cite 的结果,右栏包含项目信息

相关内容