12

I use the listings package for code listings and I turned the line numbers on. But they appear left of the paragraph. I want them inside the paragraph. In the documentation it looks just right. Here is my code:

\documentclass[12pt,a4paper]{scrartcl}
\usepackage{listings}
\lstset{numbers=left}
\begin{document}
\section{Test}
Test
\begin{lstlisting}
    test()
\end{lstlisting}
\end{document}
24

use

\lstset{numbers=left,xleftmargin=2em,frame=single,framexleftmargin=1.5em}
  • ok that helps, but I use frame=lines and the lines change too with this setting – dbrettschneider Jul 5 '11 at 12:38
  • I tried framexleftmargin=-1.5em but it ignores the minus – dbrettschneider Jul 5 '11 at 12:41
  • see edited answer – user2478 Jul 5 '11 at 12:55
  • ah thanks, misunderstood the framexleftmargin – dbrettschneider Jul 5 '11 at 13:29

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.