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.

For any unknown reason I have to use verbatim instead of listings.

Note: This issue also appear when using listings but Herbert's answer can fix it. Unfortunately, the trick Herbert used there cannot be applied here. I attempted to use the same trick but it failed as follows.

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}


\begin{document}

\defverbatim[colored]
\Lst
{
    \begin{verbatim}
            class Foo
            {
                    public static void Main()
                    {
                            Console.WriteLine("hello xport");
                    }
            }
    \end{verbatim}
}

\begin{frame}{hello xport}
\Lst
\end{frame}

\end{document}

enter image description here


It was compiled by pdflatex and latex->dvips->ps2pdf provided by TeX Live 2010 on Windows 7. And my editor is TeXnicCenter.


Caution:

If you want to try my code above, you must copy them in Edit mode. Copying the code directly from the rendered HTML will make my original tabs changed to spaces. :-)

share|improve this question
    
I assume that beamer ignores all spaces outside frames by default. Maybe place the code inside the frame and the fragile option. –  Martin Scharrer Jul 16 '11 at 18:21
    
I tested it and I got indentation. –  Stefan Kottwitz Jul 16 '11 at 18:21

1 Answer 1

up vote 4 down vote accepted

The \defverbatim ignores the tab character. Use instead spaces for the indentation or the package fancyvrb which can replace the tabs with a given number of spaces.

share|improve this answer

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.