\documentclass[a4paper]{report} \usepackage{listings} \newcommand{\xmlcode}{ \lstset{frameround=tttt,language=XML, basicstyle=\footnotesize, stepnumber=1, stringstyle={\ttfamily}, frame=single, breaklines=true, showspaces=false, showstringspaces=false, numbers=left} } \begin{document} This is a test {\xmlcode \begin{lstlisting} \end{lstlisting} } \end{document}