Text Formatting ⇒ Defining new commands
-
dearleader
- Posts: 3
- Joined: Fri Nov 27, 2009 10:19 pm
Defining new commands
I was wondering if someone could help me with the following problem. I am trying to define a new command \bf so that \bf{a} gives \textcolor{red}{\textbf{a}}. So far I have defined
\renewcommand{\bf}{\textbf} so that \bf{a} gives \textbf{a}.
but i don't know how to incorporate the \textcolor into this. Since I used \bf{a} extensively throughout my document already, i was hoping someone knows a way to incorporate the \textcolor into this without me having to chance \bf{a} to something else througout my document.
Thank you in advance,
Jong-il
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Defining new commands
\renewcommand{\bf}[1]{\textbf{#1}}
I think you'd be better served, however, by using a new name, to avoid conflicts... pick any name you haven't used yet:
\newcommand{\mybf}[1]{\textbf{#1}}
Color is not hard. Load the xcolor package:
\usepackage{xcolor}
And then you can use:
\newcommand{\redbf}[1]{\textcolor{red}{\textbf{#1}}}
(Or use renewcommand if needed, etc.)
I'm using red, but change that to whatever, as specified in the xcolor documentation.
I don't see the problem with your having already used \bf throughout the document. Doesn't your editor have a Find and Replace command?