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

I am preparing a latex document. Inside the body of a function I need to use the ceiling function. How will I use the ceiling function inside verbatim?


Method a(b)


  return a(ceiling of sqrt(b));


Can anyone suggest me how to write ceiling inside verbatim?

share|improve this question

migrated from stackoverflow.com Mar 22 '13 at 0:43

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Mar 22 '13 at 5:23
up vote 3 down vote accepted

fancyvrb provides a stepping stone to mix regular math with verbatim content. Here's a small example:

enter image description here

\usepackage{fancyvrb}% http://ctan.org/pkg/fancyvrb
Method \mesc{a(b)}
return \mesc{a(\lceil\sqrt{b}\rceil)};

You can, of course, also try using listings, which provides the mathescape key; yielding similar results as above.

share|improve this answer
Thanks Werner, it works! Thanks for the example. – Neel Mar 21 '13 at 17:38

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.