[Tex/LaTex] Use color in verbatim environment

colorverbatim

Inside the verbatim environment, is it possible to use a different color, please? For example, I want a to be normal, i.e., black. But I want b to be red.

\documentclass[]{article}

\begin{document}

\begin{verbatim}
a (black)
b (I want this letter to be red)
\end{verbatim}

\end{document}

Follow-up Question:

The solution provided by Ignasi was neat. However, there is a problem. If I need to write the entire verbatim in a non-black color, then it will not work.

\documentclass[]{article}
\usepackage{fancyvrb}
\usepackage{xcolor}

\begin{document}

I want the following to look exactly like the way I put, i.e., like an align. But it displays in one line. How to fix?

\begin{Verbatim}[commandchars=\\\{\}]
\textcolor{red}{
a = b + 1
  = x + y
  = s + t
  = c - d
  = o * p
}
\end{Verbatim}

\end{document}

Best Answer

Not exactly the same solution pointed by flav:

\documentclass[]{article}
\usepackage{fancyvrb}
\usepackage{xcolor}

\begin{document}

\begin{Verbatim}[commandchars=\\\{\}]
a (black)
\textcolor{red}{b} (I want this letter to be red)
\end{Verbatim}

\end{document}

enter image description here

Note: Credits to fancyvrb documentation

Answer to follow-up question:

To change the color for all contents of verbatim use a colored scope.

\documentclass[]{article}
\usepackage{fancyvrb}
\usepackage{xcolor}

\begin{document}

\begin{Verbatim}[commandchars=\\\{\}]
a (black)
\textcolor{red}{b} (I want this letter to be red)
\end{Verbatim}

{
\color{blue}%
\begin{Verbatim}[commandchars=\\\{\}]
a (black)
\textcolor{red}{b} (I want this letter to be red)
\end{Verbatim}
}

\end{document}

enter image description here