嘗試使用 parenciteauthor 指令,skipbib 和skipbiblist 的行為不同

嘗試使用 parenciteauthor 指令,skipbib 和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(作者 1)和論文 2(作者 2),兩者都帶有選項「skip-biblist=true」。一起引用論文 1 和 2:(作者 1;作者 2)。引用論文 3 (Author3) 和論文 4 (Author4),兩者都帶有選項skibib=true。一起引用論文 3 和 4:(作者 3;作者 4)。


正如我上面提到的,問題根本不是由您的定義引起的,而是

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

會稍微更慣用 - 如果確實比

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

相關內容