![\citet* のレンダリングを変更する](https://rvso.com/image/353029/%5Ccitet*%20%E3%81%AE%E3%83%AC%E3%83%B3%E3%83%80%E3%83%AA%E3%83%B3%E3%82%B0%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%99%E3%82%8B.png)
\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
。