TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to make the character ` active in one environment so that `some text` will be formatted using black background and white for the text.

This feature must be activated only inside the environment.

share|improve this question
up vote 3 down vote accepted

You need to make ` active and read everything up to the next `. The colors can be set using \colorbox and \textcolor from the xcolor package.

You might also want to compensate for the added left/right space as shown below.



    \catcode96=\active% ASCII ` = 96



    text text text

    text `text` text



With the \hspaces you get:

Result with \hspace's

Without you get:

Result without \hspace's

You could also just take half the \fboxsep away to get an intermediate result.

share|improve this answer
Thanks for this solution and the comments in the code. – projetmbc Dec 8 '11 at 13:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.