2

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. :-)

Display Name
  • 46,933

1 Answers1

5

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.