
我正在編寫一份文檔,我希望所有粗體文字都是紅色。我想知道如何才能將renewcommand
命令textbf
包含在 中\textcolor{red}
?
謝謝
答案1
預設定義textbf
是
\DeclareTextFontCommand{\textbf}{\bfseries}
要添加新功能,您可以簡單地添加\color{red}
\DeclareTextFontCommand{\textbf}{\bfseries\color{red}}
\DeclareTextFontCommand
覆蓋原始定義而不會出現錯誤。您只能透過以下方式獲得資訊\@latex@info
這是完整的 MWE:
\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\DeclareTextFontCommand{\textbf}{\bfseries\color{red}}
\begin{document}
text \textbf{foo} bar
\end{document}