\usepackage{listings} \usepackage{courier} \usepackage{xcolor} \lstset{ basicstyle=\footnotesize\ttfamily, % Default font numbers=left, % Location of line numbers numberstyle=\tiny, % Style of line numbers % stepnumber=2, % Margin between line numbers numbersep=5pt, % Margin between line numbers and text tabsize=2, % Size of tabs extendedchars=true, breaklines=true, % Lines will be wrapped keywordstyle=\color{red}, frame=b, % keywordstyle=[1]\textbf, % keywordstyle=[2]\textbf, % keywordstyle=[3]\textbf, % keywordstyle=[4]\textbf, \sqrt{\sqrt{}} stringstyle=\color{white}\ttfamily, % Color of strings showspaces=false, showtabs=false, xleftmargin=17pt, framexleftmargin=17pt, framexrightmargin=5pt, framexbottommargin=4pt, % backgroundcolor=\color{lightgray}, showstringspaces=false } \lstloadlanguages{ % Check documentation for further languages ... % [Visual]Basic, % Pascal, % C, % C++, % XML, % HTML, TeX } %Listings line numbers that match the linerange specification \makeatletter \lst@Key{matchrangestart}{f}{\lstKV@SetIf{#1}\lst@ifmatchrangestart} \def\lst@SkipToFirst{% \lst@ifmatchrangestart\c@lstnumber=\numexpr-1+\lst@firstline\fi \ifnum \lst@lineno<\lst@firstline \def\lst@next{\lst@BeginDropInput\lst@Pmode \lst@Let{13}\lst@MSkipToFirst \lst@Let{10}\lst@MSkipToFirst}% \expandafter\lst@next \else \expandafter\lst@BOLGobble \fi} \makeatother %space: \makeatletter \def\lst@MSkipToFirst{% \global\advance\lst@lineno\@ne \ifnum \lst@lineno=\lst@firstline \def\lst@next{\lst@LeaveMode \global\lst@newlines\z@ \lst@OnceAtEOL \global\let\lst@OnceAtEOL\@empty \ifnum \c@lstnumber>0 \\ ... \vspace{2 mm} \fi \lst@InitLstNumber % Added to work with modified \lsthk@PreInit. \lsthk@InitVarsBOL \c@lstnumber=\numexpr-1+\lst@lineno % this enforces the displayed line numbers to always be the input line numbers \lst@BOLGobble}% \expandafter\lst@next \fi} \makeatother % end % \DeclareCaptionFont{blue}{\color{blue}} % \captionsetup[lstlisting]{singlelinecheck=false, labelfont={blue}, textfont={blue}} \usepackage{caption} \DeclareCaptionFont{white}{\color{white}} \DeclareCaptionFormat{listing}{\colorbox[cmyk]{0.43, 0.35, 0.35,0.01}{\parbox{\textwidth}{\hspace{15pt}#1#2#3}}} \captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={bf,footnotesize}} %--------