Take the 2-minute tour ×
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.

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?

\begin{verbatim}

Method a(b)

    .
    .
    .

  return a(ceiling of sqrt(b));

\end{verbatim}

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

1 Answer 1

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

\documentclass{article}
\usepackage{fancyvrb}% http://ctan.org/pkg/fancyvrb
\newcommand{\mesc}[1]{$#1$}
\begin{document}
\begin{Verbatim}[commandchars=\\\{\}]
Method \mesc{a(b)}
    .
    .
    .
return \mesc{a(\lceil\sqrt{b}\rceil)};
\end{Verbatim}
\end{document}

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

 
discard

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.