1
\documentclass{article}
\usepackage{lstlistings}
\lstset {language=C++,
    basicstyle=\small
    columns=flexible,
    stepnumber=0.8,
    numbersep=8pt,
    tabsize=4,
    showspaces=false,
    showstringspaces=false
    }

\begin{document}
\begin{lstlisting}
CODE
\end{listing}
\end{document}

The problem is that the when I create the PDF I get

somewhat like

PDF Starts:

columns

CODE

:PDF Ends

Why is there a "columns" before my CODE and how can I remove it?

  • 1
    Welcome to TeX.SX! There is a bunch of errors: \usepackage{listings}, not lstlistings and there is , missing after \small (which causes your problem), but another error is \end{listing} .. it should read \end{lstlisting} – user31729 Jan 4 '17 at 16:55
  • 1
    (1) welcome, (2) see if you are not missing a comma after \small – daleif Jan 4 '17 at 16:56
2

The comma missing after \small makes the pdfcompiler write columns in your pdf. In the following code the script is correct.

\documentclass{article}
\usepackage{listings}
\lstset {language=C++,
    basicstyle=\small,
    columns=flexible,
    stepnumber=0.8,
    numbersep=8pt,
    tabsize=4,
    showspaces=false,
    showstringspaces=false
    }

\begin{document}
\begin{lstlisting}
CODE
\end{lstlisting}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.