如何仅在 fullcite 命令中将作者字体更改为小写字母?

如何仅在 fullcite 命令中将作者字体更改为小写字母?

我已经搜索了一段时间,并试图依靠这个问题及其可接受的答案修改\fullcite命令,使作者姓名在此特定cite命令中以小写字母显示,但对于其余cite命令则保持正常字体。不幸的是,我一定是做错了什么,因为我在所有cite命令中都以小写字母显示作者。以下是 MWE:

\documentclass{article}

% PACKAGES 

\usepackage{xpatch} % To modify the fullcite command.
\usepackage{filecontents} % To get the bibliography inside the tex file

\begin{filecontents}{jobname.bib}
@book{author_book,
title = {Book's title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
date = {2005},
}
\end{filecontents}

\usepackage[isbn=false,giveninits=true,uniquename=init,style=authoryear-comp,backend=biber,natbib,maxbibnames=99,maxcitenames=3,hyperref=true]{biblatex} % To get fancy bibliography as desired.
\addbibresource{jobname.bib}

% REDEFINITION 

\newtoggle{fullcite}

\AtBeginDocument{
  \renewcommand*{\mkbibnamefamily}[1]{%
    \iftoggle{fullcite}{#1}{\textsc{#1}}}
}

\xpretobibmacro{fullcite}{\toggletrue{fullcite}}{}{}
\xapptobibmacro{fullcite}{\togglefalse{fullcite}}{}{}

% DOCUMENT 

\begin{document}

\fullcite{author_book} [This is fine]

\citet{author_book} [This is wrong: it should remain in normal font]

\citeauthor{author_book} [This is wrong: it should remain in normal font]

\end{document}

这是输出:

在此处输入图片描述

我怎样才能仅在命令中更改作者的字体fullcite?谢谢大家。

编辑1:虽然 Ivan 的解决方案有效,但当序言包含以下行时,它就会失败\DeclareNameAlias{author}{family-given}。我需要找到一个与兼容的解决方案\DeclareNameAlias{author}{family-given}。谢谢大家!

编辑2:我已经打开了一个新问题更好地说明我的需求。

答案1

首先我们必须重新定义 \fullcite 命令以使用我们称之为的另一种名称格式scname

\DeclareCiteCommand{\fullcite}
{\usebibmacro{prenote}}
{\usedriver
 {\DeclareNameAlias{sortname}{scname}}%<<modified
 {\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}

然后我看到了两个可能的解决方案。

第一个解决方案:

\letbibmacro{scname:given-family}{name:given-family}
\xpretobibmacro{scname:given-family}
 {\renewcommand*{\mkbibnamefamily}[1]{\textsc{#1}}}{}{}

\DeclareNameFormat{scname}{%
 \ifgiveninits
 {\usebibmacro{scname:given-family}%<<modified
  {\namepartfamily}
  {\namepartgiveni}
  {\namepartprefix}
  {\namepartsuffix}}
 {\usebibmacro{name:given-family}
  {\namepartfamily}
  {\namepartgiven}
  {\namepartprefix}
  {\namepartsuffix}}%
 \usebibmacro{name:andothers}}

第二种解决方案:(这里不需要xpatch。)

\DeclareNameFormat{scname}{%
 \ifgiveninits
 {\usebibmacro{name:given-family}
  {\scshape\namepartfamily}%<<modified
  {\namepartgiveni}
  {\namepartprefix}
  {\namepartsuffix}}
 {\usebibmacro{name:given-family}
  {\namepartfamily}
  {\namepartgiven}
  {\namepartprefix}
  {\namepartsuffix}}%
 \usebibmacro{name:andothers}}

平均能量损失

\begin{filecontents}[overwrite]{\jobname.bib}
 @book{author_book,
  title = {Book's title},
  author = {Author, Some},
  location = {The City},
  publisher = {Publisher},
  date = {2005},
 }
\end{filecontents}
\documentclass{article}
\usepackage{xpatch}
\usepackage[isbn=false,giveninits=true,uniquename=init,style=authoryear-comp,backend=biber,natbib,maxbibnames=99,maxcitenames=3,hyperref=true]{biblatex} % To get fancy bibliography as desired.
\addbibresource{\jobname.bib}

\DeclareCiteCommand{\fullcite}
{\usebibmacro{prenote}}
{\usedriver
 {\DeclareNameAlias{sortname}{scname}}
 {\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}

% FIRST SOLUTION
\letbibmacro{scname:given-family}{name:given-family}
\xpretobibmacro{scname:given-family}
{\renewcommand*{\mkbibnamefamily}[1]{\textsc{#1}}}{}{}

\DeclareNameFormat{scname}{%
 \ifgiveninits
 {\usebibmacro{scname:given-family}
  {\namepartfamily}
  {\namepartgiveni}
  {\namepartprefix}
  {\namepartsuffix}}
 {\usebibmacro{name:given-family}
  {\namepartfamily}
  {\namepartgiven}
  {\namepartprefix}
  {\namepartsuffix}}%
 \usebibmacro{name:andothers}}
    
%SECOND SOLUTION
%\DeclareNameFormat{scname}{%
% \ifgiveninits
% {\usebibmacro{name:given-family}
%  {\scshape\namepartfamily}
%  {\namepartgiveni}
%  {\namepartprefix}
%  {\namepartsuffix}}
% {\usebibmacro{name:given-family}
%  {\namepartfamily}
%  {\namepartgiven}
%  {\namepartprefix}
%  {\namepartsuffix}}%
% \usebibmacro{name:andothers}}

\begin{document}
 
 \fullcite{author_book} [This is fine]
 
 \citet{author_book} [This is wrong: it should remain in normal font]
 
 \citeauthor{author_book} [This is wrong: it should remain in normal font]
 
\end{document}

这使:

在此处输入图片描述

答案2

使用名称包装器格式,您可以避免重新定义或修补名称格式。您只需在打印名称之前注入小型大写的重新定义即可。

\documentclass{article}
\usepackage[
  backend=biber,
  style=authoryear-comp,
  giveninits=true, uniquename=init,
  maxbibnames=99, maxcitenames=3,
  isbn=false,
  natbib,
]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareNameWrapperFormat{smallcaps}{%
  \renewcommand*{\mkbibnamefamily}{\textsc}%
  #1}

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\usedriver
     {\DeclareNameAlias{sortname}{default}%
      \DeclareNameWrapperAlias{author}{sortname}%
      \DeclareNameWrapperAlias{editor}{sortname}%
      \DeclareNameWrapperAlias{translator}{sortname}%
      \DeclareNameWrapperAlias{sortname}{smallcaps}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\begin{document}
\fullcite{sigfridsson}

\citet{sigfridsson}

\citeauthor{sigfridsson}
\end{document}

小型大写的“E. Sigfridsson 和 U. Ryde”

在 MWE 中,三行

      \DeclareNameWrapperAlias{author}{sortname}%
      \DeclareNameWrapperAlias{editor}{sortname}%
      \DeclareNameWrapperAlias{translator}{sortname}%

是多余的,但是不同的风格可能需要它们,所以我认为保留它们可能是个好主意(请检查style=numeric,是否需要这些线的情况)。

相关内容