GeneralVerbatim color

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kazyka
Posts: 2
Joined: Mon Feb 21, 2011 5:44 pm

Verbatim color

Post by kazyka »

Hi I have a problem. I wish to make color to my verbatim cause the reader needs to see differens between input and output.

I have this

Code: Select all

\renewcommand{\FancyVerbFormatLine}[1]{%
  \ifnum\value{FancyVerbLine}<5\color{red}#1%
  \else\color{blue}#1\fi}
\begin{Verbatim}
line 1
line 2
line 3
line 4
line 5
line 6
line 7
\end{Verbatim}
But what I wish to make is

\begin{Verbatim}
line 1 Red
Line 2 Black
Line 3 Red
Line 4 green
\end{Verbatim}

and

\begin{Verbatim}
line 5 Red
Line 6 Black
Line 7 black
Line 8 red
\end{Verbatim}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

Verbatim color

Post by Frits »

Code: Select all

\usepackage{color}
\usepackage{fancyvrb}

\begin{document}

\begin{Verbatim}[commandchars=\\\{\}]
\color{blue}First verbatim line.
\color{red}Second line.
\color{black}Third verbatim line.
\end{Verbatim}

\end{document}
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
Post Reply