I want to show the output from verbatim
in blue color.
I have this:
\newcommand{\blockcode}[1]{\ttfamily\small#1}
{\blockcode \begin{verbatim}
alias vi="vim"
\end{verbatim}}
which works fine.
But when I do this
\newcommand{\blockcode}[1]{\ttfamily\small{\color{blue}#1}}
it throws an error
! Argument of \begin has an
extra }.
Update
I tried
\documentclass{article}
\usepackage{verbatim,color,lipsum}
\newcommand{\blockcode}{\ttfamily\small\color{blue}}
\begin{document}
\lipsum*[2]
{\blockcode \begin{verbatim}
alias vi="vim"
\end{verbatim}}
\lipsum*[3]
\end{document}
But the blockcode doesn't end… it flows on to the next element…
Update 2
If I do this:
\paragraph{Hello}
\begin{blockcode}
alias vi="vim"
\end{blockcode}
The Hello
also becomes blue in color. Any way I can stop this?
Update 3
Again a roadblock…
\subsubsection*{Definition}
\begin{blockcode}
:iabbrev <key> <expansion>
\end{blockcode}
This creates too much gap between Definition
and the code.
Best Answer
You have a number of better alternatives.
First. Package
verbatim
Pros: easy. Cons: not really customizable.
Second. Package
fancyvrb
Pros: very customizable. Cons: less easy to learn how to manage the definitions.
Third. Package
listings
Pros: keyword coloring for the supported languages. Cons: doesn't support UTF-8