19

Every time I want a bold text, I want it colored blue. Currently, I am using:

\textcolor{blue}{\textbf{some bold and colored text}}

To save time, I can define a command to do both at once. How can I do it?

1
  • 3
    \newcommand\bluebf[1]{\textcolor{blue}{\textbf{#1}}} ? This is \bluebf{blue bold text}
    – Zarko
    May 6, 2016 at 0:54

2 Answers 2

19

Simply

\newcommand\boldblue[1]{\textcolor{blue}{\textbf{#1}}}
2
  • Could you explain a little bit how 1 and #1 works there? Your solution worked for me, but my attept was \newcommand{\boldblue}{\textcolor{blue}{\textbf{}} and gave me a compile error and I'm trying to understand how that 1 and #1 that solves the problem.
    – Chris
    Jun 21, 2021 at 0:03
  • 1
    1 means that the macro \boldblue will have one argument*. Later #1 is a reference for the first argument of \boldblue. * by the way: [1] means that this is an optional argument of \newcommand
    – Tom Solid
    Jun 21, 2021 at 13:18
0

Another approach is to use font-switching commands within \DeclareTextFontCommand, here:

\DeclareTextFontCommand{\bblue}{\color{blue}\bfseries}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .