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

In my document preamble, I'm using:


It means I can indicate that things are to be rendered as code with |This_is_monospaced|, but now I'm trying to use vertical bars to represent magnitude in a formula, as such: $|V|$ (typeset with amsmath)

What I'm currently getting is a verbatim environment within my formula.

Is there a way of temporarily disabling the monospacing behaviour so my formula still renders normally?

share|improve this question
up vote 7 down vote accepted

You can load amsmath


and then use

$\lvert V\rvert$

Another option is to use \UndefineShortVerb:



$\lvert V\rvert$



enter image description here

As Andrew Swann mentions in his comment, in general it is preferable to use \lvert...\rvert instead of just |...|.

share|improve this answer
Thanks for the fast reply! Spot on. – Fabian Tamp Sep 13 '12 at 14:21
and I'm already using amsmath :) – Fabian Tamp Sep 13 '12 at 14:21
In fact you should always use \lvert and \rvert for |V| to get correct spacing. – Andrew Swann Sep 13 '12 at 14:25
@AndrewSwann Can you please provide an example showing a difference in spacing using |...| and \lvert...\rvert? (I've been trying to produce one but haven't found it) – Gonzalo Medina Sep 13 '12 at 14:29
@GonzaloMedina Actually looking this up in the TeX book page 170, there are only two situations where \lvert which is class Open and | which is class Ord differ in spacing: when they are next to an Op, i.e. a large operator. So \( \bigoplus \lvert V \rvert \) has less space than \( \bigoplus |V| \), similarly when the first two terms are swapped. There are more cases when spacing for \rvert differs from that for |, including the situation where the V is replaced by a \left/\right pair. amsldoc explains that there are semantic reasons to prefer \lvert etc. – Andrew Swann Sep 13 '12 at 15:31

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.