[Tex/LaTex] Redefining formatting commands to add colors

colormacros

I'm writing a document, and I'd like for all bold text to be red. I was wondering how I could renewcommand the textbf command so that it would be wrapped in \textcolor{red}?

Thanks

Best Answer

The default definition of textbf is

\DeclareTextFontCommand{\textbf}{\bfseries}

To add a new feature you can simple add \color{red}

\DeclareTextFontCommand{\textbf}{\bfseries\color{red}}

\DeclareTextFontCommand overrides the original definition without errors. You only get an info by \@latex@info

Here the complete MWE:

\documentclass[]{article}

\usepackage[T1]{fontenc}
\usepackage{xcolor}
\DeclareTextFontCommand{\textbf}{\bfseries\color{red}}
\begin{document}
text \textbf{foo} bar
\end{document}

enter image description here

Related Question