\citet* のレンダリングを変更する

\citet* のレンダリングを変更する

\citet*より小さいフォントサイズと特定の色を使用してレンダリングを変更したいと思います。

以下のMWEは、の星なしバージョンで動作\citetし、

ここに画像の説明を入力してください

\documentclass{article}

\usepackage{filecontents}
\usepackage{natbib}
\usepackage{color}

\let\oldcitet=\citet
\renewcommand{\citet}[1]{{\footnotesize\textcolor[rgb]{.8, .1, .4}{\oldcitet{#1}}}}

\begin{filecontents}{refs.bib}
@book{ref,
title = {title},
author = {john and abi and fein},
location = {here},
publisher = {publisher},
year = {2017},
}
\end{filecontents}

\begin{document}

\citet{ref}

\citet*{ref}

\bibliography{refs.bib}

\bibliographystyle{plainnat}

\end{document}

の再定義により、星付きバージョンの定義が\citet壊れます。これを修正する方法について何か提案はありますか?

答え1

スター付きバージョンをセットアップに組み込むには、*次のような使用条件を設定する必要があります。

\let\oldcitet=\citet
\makeatletter
\renewcommand{\citet}{\@ifstar\newcitetstar\newcitet}
\newcommand{\newcitet}[1]{{\footnotesize\textcolor[rgb]{.8, .1, .4}{\oldcitet{#1}}}}
\newcommand{\newcitetstar}[1]{{\footnotesize\textcolor[rgb]{.8, .1, .4}{\oldcitet*{#1}}}}
\makeatother

ここに画像の説明を入力してください

他のオプションを交渉するより簡単な方法もあります。例えば、オプションの引数などです。より一般的なアプローチとしては、xparse

関連情報