lstlisting 和 tcolorbox - 行号边距

lstlisting 和 tcolorbox - 行号边距

我想让我的代码看起来像这样:

图片

但我对行号位置有疑问,它在框线上。

\documentclass{scrartcl}

\usepackage[a4paper,top=2cm,bottom=3cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage[ngerman]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[most]{tcolorbox} % Farbige Boxen
\usepackage{listings, xcolor} % Code
  
\lstset{
    tabsize = 4, 
    showstringspaces = false, 
    numbers = left, 
    commentstyle = \color{green},
    keywordstyle = \color{blue}, 
    stringstyle = \color{red}, 
    rulecolor = \color{black}, 
    basicstyle = \normalfont \ttfamily , 
    breaklines = true,
    numberstyle = \normalfont,
}



\begin{document}


\begin{tcolorbox}[colback=white!5!white,colframe=black!75!black,title=Abzutippender Code]

\begin{lstlisting}[language = Java , firstnumber = last , escapeinside={(*@}{@*)}]
class HelloWorld {
    public static void main(String[] args) {   
        System.out.println("Hello World");
    }
}
\end{lstlisting}

\end{tcolorbox}

\end{document}

相关内容