fancyvrb: multiple actives

this works great---well, I stole it right out of the docs:

{   \catcode`!=\active   \begin{Verbatim}[defineactive=\def!{\color{red}\bf}]     black !   red     black   \end{Verbatim} } 

now I would like to have multiple active characters, each designating a particular style. I could bore everyone with my code that tries to generalize this to two or three characters (define '-' as active, then add another defineactive with a comma), but they were all wrong.

is this easy?

a related question (not needed) is whether one can easy switch forth and back on the same line.

advice appreciated.

Replay

You can have multiple active characters:

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

\begin{document}

{
  \catcode`!=\active
  \catcode`@=\active
  \catcode`?=\active
  \begin{Verbatim}[defineactive={
    \def!{\color{red}}
    \[email protected]{\color{cyan}}
    \def?{\color{orange}}
    }
  ]
    black
!    red
@    blue
?    orange
  \end{Verbatim}
}

\end{document}

fancyvrb: multiple actives

and define a custom environment to handle this specification, but I'd strongly suggest you to switch to the listings package for heavy formatting of listings.

Category: fancyvrb Time: 2014-05-29 Views: 1
Tags: fancyvrb

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.185 (s). 12 q(s)