修改或创建引用命令,如 \citet{} 或 \citep{},以内联方式显示日期、月份和年份

修改或创建引用命令,如 \citet{} 或 \citep{},以内联方式显示日期、月份和年份

我正在编写一份引用电子邮件的文档,并尝试使用 .bib 文件来管理我引用的电子邮件。

我如何修改引用命令\citet{Smith:2023aa}\citep{Smith:2023aa},或者如何创建自定义引用命令,以在我的文档中生成显示为“Smith(2023 年 2 月 28 日)”或“(Smith,2023 年 2 月 28 日)”的内联引用?

我对文档中显示的日期的具体格式并不挑剔,只要以内联方式显示日、月、年即可。

梅威瑟:

\documentclass{article}

\begin{filecontents*}{\jobname.bib}
@misc{Smith:2020aa,
    title = {Subject: Minimum Working Example}
    author = {John Smith},
    date = {2020-02-28}
  }
\end{filecontents*}


\usepackage[
      style=apa,
      labeldate=comp, 
      dateabbrev= false,
      natbib,
      backend=biber,
    ]{biblatex}

\addbibresource{\jobname.bib}

\begin{document}

\citet{Smith:2020aa}

\printbibliography

\end{document}

感谢您对此的建议!

答案1

这里我创建了\citewithdatep,打印(作者,月日,年),以及\citewithdatet,打印作者(月日,年):

\documentclass{article}

\begin{filecontents*}{\jobname.bib}
@misc{Smith:2020aa,
    title = {Subject: Minimum Working Example},
    author = {John Smith},
    date = {2020-02-28}
  }
\end{filecontents*}

\usepackage[
    style=apa,
    labeldate=comp, 
    dateabbrev= false,
    natbib,
    backend=biber,
    ]{biblatex}

\DeclareCiteCommand{\citewithdatep}
  {\boolfalse{citetracker}% 
   \boolfalse{pagetracker}}
  {\mkbibparens{%
      \printnames{labelname}% 
      \addcomma\addspace%
      \printfield{month}%
      \addspace%
      \printfield{day}%
      \addcomma\addspace%
      \printfield{year}%
      }%
  }
  {\multicitedelim}
  {}

\DeclareCiteCommand{\citewithdatet}
  {\boolfalse{citetracker}% 
   \boolfalse{pagetracker}}
  {\printnames{labelname}% 
   \addspace%
   \mkbibparens{%
      \printfield{month}%
      \addspace%
      \printfield{day}%
      \addcomma\addspace%
      \printfield{year}%
      }%
  }
  {\multicitedelim}
  {}  
\addbibresource{\jobname.bib}

\begin{document}

This is an email citation in the format (Author, Month Day, Year):

\citewithdatep{Smith:2020aa}

This is an email citation in the format Author (Month Day, Year):

\citewithdatet{Smith:2020aa}

This is an ordinary citation
\citet{Smith:2020aa}

\printbibliography

\end{document}

在此处输入图片描述

相关内容