![修改 \citet* 的渲染](https://rvso.com/image/353029/%E4%BF%AE%E6%94%B9%20%5Ccitet*%20%E7%9A%84%E6%B8%B2%E6%9F%93.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
。