尝试使用 parenciteauthor 命令,skippib 和 skipbiblist 的行为有所不同

尝试使用 parenciteauthor 命令,skippib 和 skipbiblist 的行为有所不同

我的目标是引用几个来源shortauthor(不带日期),并将引用放在括号中。由于没有\parenciteauthor命令,我定义了一个依赖于的命令\citeauthor

skipbib=true此外,我希望使用或选项从参考列表中排除这些条目skipbiblist=true

我的方法有效,只要我引用单身的来源。不幸的是,当我引用时,我只能让这两个要求中的一个起作用多种的来源。

如果我使用选项skipbiblist=true,我可以同时引用两个来源(参见输出的第 2 行)。但是,条目仍显示在参考文献列表中。如果我改用选项skipbib=true,则条目将成功从参考文献列表中省略。引用单个来源也可以正常工作(输出的第 3 行)。但是,如果我同时引用多个来源,则带有引用的括号为空(输出的第 4 行)。

有没有办法同时实现这两个要求?为什么使用时括号是空的skipbib=true

我的输出如下:

MEW 输出

新风:

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

\usepackage[style=authoryear-icomp,
  backend=biber, 
  bibstyle=authoryear
  ]{biblatex}

\newcommand{\parenciteauthor}[1]{(\citeauthor{#1})}

\begin{filecontents*}[overwrite]{publist.bib}

@misc{test1,
author = {Author1},
shortauthor = {T1},
title = {Paper 1},
year = {2010},
howpublished = {Paper presented at the meeting of Organization Name, Location},
options = {skipbiblist=true}
}

@misc{test2,
author = {Author2},
shortauthor = {T2},
title = {Paper 2},
year = {2010},
howpublished = {Paper presented at the meeting of Organization Name, Location},
options = {skipbiblist=true}
}

@misc{test3,
author = {Author3},
shortauthor = {T3},
title = {Paper 3},
year = {2010},
howpublished = {Paper presented at the meeting of Organization Name, Location},
options = {skipbib=true}
}

@misc{test4,
author = {Author4},
shortauthor = {T4},
title = {Paper 4},
year = {2010},
howpublished = {Paper presented at the meeting of Organization Name, Location},
options = {skipbib=true}
}

\end{filecontents*}

\addbibresource{publist.bib}



\begin{document}

Cite paper 1 \parenciteauthor{test1} and paper 2 \parenciteauthor{test2}, both with the option skipbiblist=true.

Cite paper 1 and 2 together: \parenciteauthor{test1,test2}. % This is how I want to output to look like. Unfortunately, the sources still show up in the list of references.

Cite paper 3 \parenciteauthor{test3} and paper 4 \parenciteauthor{test4}, both with the option skipbib=true.

Cite paper 3 and 4 together: \parenciteauthor{test3,test4}. % The sources are omitted from the list of references as desired, but the citation does not work.

\printbibliography

\end{document}

答案1

更新

此处发现的错误已在biblatexv3.18 (2022-06-22) 中得到解决。如果您仍然遇到此问题,请更新系统。


此问题不是由您的任何定义引起的。它可能是以下错误引起的biblatexhttps://github.com/plk/biblatex/issues/1225


如果你需要立即修复,你可以包含以下修复https://github.com/plk/biblatex/issues/1225如下。请记住,\makeatletter ... \makeatother一旦biblatex更新,就删除该块。

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

\usepackage[
  backend=biber,
  style=authoryear-icomp,
]{biblatex}

\makeatletter
\protected\def\blx@bbl@endentry{%
  \csuse\blx@bbl@data
  \ifcsundef{blx@pref@\the\c@refsection @\abx@field@entrykey}
    {}
    {\blx@addpageref{\abx@field@entrykey}}%
  \nottoggle{blx@setonly}
    {}
    {\global\toggletrue{blx@addset}%
     \toggletrue{blx@skipbib}%
     \toggletrue{blx@skipbiblist}%
     \toggletrue{blx@skiplab}}%
  \expandafter\ifstrequal\expandafter{\blx@dlist@type}{entry}
    {\listcsxadd{blx@type@\the\c@refsection @\abx@field@entrytype}{\abx@field@entrykey}%
     \ifdef\abx@field@entrysubtype
       {\listcsxadd{blx@subt@\the\c@refsection @\abx@field@entrysubtype}{\abx@field@entrykey}}
       {}%
     \nottoggle{blx@setonly}
       {\listcsxadd{blx@dlist@centry@\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}}
       {}%
     \nottoggle{blx@skipbib}
       {\listcsxadd{blx@dlist@entry@\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}}
       {}}%
    {}%
  \nottoggle{blx@skipbiblist}
    {\expandafter\ifstrequal\expandafter{\blx@dlist@type}{list}
      {\blx@bbl@labelfields
        \listcsxadd{blx@dlist@\blx@dlist@type @\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}}
      {}}%
    {}%
  \nottoggle{blx@skiplab}
    {\iftoggle{blx@labelnumber}
       {\blx@bbl@labelnumber}
       {}%
     \iftoggle{blx@labelalpha}
       {\blx@bbl@labelalpha}
       {}%
     \iftoggle{blx@labeltitle}
       {\blx@bbl@labeltitle}
       {}%
     \iftoggle{blx@labeltitleyear}
       {\blx@bbl@labeltitleyear}
       {}%
     \iftoggle{blx@labeldateparts}
       {\blx@bbl@labeldate}
       {}%
     \blx@bbl@labelname}
    {}%
  \blx@bbl@titles
  \blx@bbl@hooks
  \endgroup}
\makeatother

\newcommand{\parenciteauthor}[1]{(\citeauthor{#1})}

\begin{filecontents*}[overwrite]{\jobname.bib}
@misc{test1,
  author       = {Author1},
  title        = {Paper 1},
  year         = {2010},
  options      = {skipbiblist=true},
}
@misc{test2,
  author       = {Author2},
  title        = {Paper 2},
  year         = {2010},
  options      = {skipbiblist=true}
}
@misc{test3,
  author       = {Author3},
  title        = {Paper 3},
  year         = {2010},
  options      = {skipbib=true}
}
@misc{test4,
  author       = {Author4},
  title        = {Paper 4},
  year         = {2010},
  options      = {skipbib=true}
}
\end{filecontents*}
\addbibresource{\jobname.bib}


\begin{document}
Cite paper 1 \parenciteauthor{test1}
and paper 2 \parenciteauthor{test2}, both with the option skipbiblist=true.

Cite paper 1 and 2 together: \parenciteauthor{test1,test2}.
Cite paper 3 \parenciteauthor{test3} and paper 4 \parenciteauthor{test4},
both with the option skipbib=true.

Cite paper 3 and 4 together: \parenciteauthor{test3,test4}. 

\printbibliography
\end{document}

引用论文 1 (Author1) 和论文 2 (Author2),两者都使用选项 skip-biblist=true。同时引用论文 1 和 2:(Author1; Author2)。引用论文 3 (Author3) 和论文 4 (Author4),两者都使用选项 skipbib=true。同时引用论文 3 和 4:(Author3; Author4)。


正如我上面提到的,这个问题根本不是由你的定义引起的,但是

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

会稍微更符合地道用法 - 虽然比

\newcommand{\parenciteauthor}[1]{(\citeauthor{#1})}

相关内容