3

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?

1
  • 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
    Commented Mar 22, 2013 at 5:23

1 Answer 1

4

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .