TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

When posting on SE, users can "highlight" code by using the ` symbol. Is there any way to get that in LaTeX?

My intention is to highlight segments of code or particular functions. To be clear, I'm not speaking of something like Syntax highlighting for different programming languages. I want to be able output this_instead (no magic wizardry involved).

I'm not sure what this is called, so I didn't know how to search for it. I'll delete it if it's a duplicate though.

share|improve this question
Perhaps others share my thoughts, but I'm definitely not clear on what you're after... – Werner Apr 4 '13 at 21:19
@Werner I think the OP would like the output from \lstinline!this_instead! but without typing \lstinline! and only typing backticks.... sounds like some category code wizardry would be needed, and a very dangerous path... – cmhughes Apr 4 '13 at 21:21
@Werner DL6ER has exactly what I wanted. – AlanH Apr 4 '13 at 21:21
up vote 3 down vote accepted

Customize for your own needs

share|improve this answer
You ought to mention that you need color package for \colorbox and if you use the ! color syntax you need xcolor – David Carlisle Apr 4 '13 at 21:22

Using Martin Scharrer's newverbs package:




Note that the save bin \verbbox is provided by the package.

The usage of \severb is identical to \verb (including the *-variant).

enter image description here

share|improve this answer

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.