Tell me more ×
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 noticed that tabsize only affects lstlisting and lstinline macros.

Here is the output. The top figure is displayed using lstinputlisting and the bottom one is displayed using lstlisting. The tabsize does not affect the top one. But it does for the bottom one.

alt text

How to make it works for all macros?

\documentclass[dvips,dvipsnames,rgb,table]{article}
\usepackage[a4paper,hmargin=20mm,vmargin=20mm]{geometry}
\usepackage{xcolor}

\usepackage{listings}
\lstset%
{%
    literate={ï}{}0
           {»}{}0
           {¿}{}0,
    language={[Sharp]C},
    breaklines=true,
    breakindent=0pt,
    tabsize=2,
    basicstyle=\color{White}\ttfamily\scriptsize,
    keywordstyle=\color{Orange}\sffamily\bfseries,
    commentstyle=\color{Green}\itshape,
    stringstyle=\color{Cyan}\rmfamily,
    showstringspaces=true,
    aboveskip=0pt,
    belowskip=0pt,
    backgroundcolor=\color{Black}%,
    %rangeprefix=\%,
    %rangesuffix=\%,
    %includerangemarker=false,
    %linerange=start-stop%
}


\usepackage{fancyvrb}
\def\MyOwn%
{%        
    \VerbatimEnvironment%
  \begin{VerbatimOut}{\jobname.tmp}%
}
\def\endMyOwn%
{%
    \end{VerbatimOut}% 
    \lstinputlisting{\jobname.tmp}%     
}


\begin{document}
\begin{MyOwn}
using System;
class Foo
{
    void Main()
    {
        Console.WriteLine("using lstinputlisting");
    }
}
\end{MyOwn}

\vspace{1cm}

\begin{lstlisting}
using System;
class Foo
{
    void Main()
    {
        Console.WriteLine("using lstlisting");
    }
}
\end{lstlisting}
\end{document}

Does the \VerbatimEnvironment cause this problem?

share|improve this question
2  
Look at the output file, does it contain tabs? If not, then tabsize doesn't do anything. – TH. Jan 4 '11 at 5:51

1 Answer

up vote 3 down vote accepted

use also:

\usepackage{fancyvrb}
\fvset{tabsize=2}
share|improve this answer
thanks. It works now. :-) – xport Jan 4 '11 at 7:41

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.