% !TEX root = ../manual.tex
% !TEX program = xelatexmk
% !TEX spellcheck = en_GB

\section{Source Code Listings}
Sometimes you have to show your code, for example in a document for a \LaTeX\ course. 
The |listings| package provides the |lstlisting| environment and the |lstinputlisting| command:

\begin{multicols}{2}
\begin{lstlisting}[escapeinside={\%*}{*)}]
Regular listing:
%*\textbackslash*)begin{lstlisting}
[Some source code here]
%*\textbackslash*)end{lstlisting}
Input from (this) file:
\lstinputlisting[firstline=22, lastline=23]{manual.tex}
\end{lstlisting}
\columnbreak
Regular listing:
\begin{lstlisting}
[Some source code here]
\end{lstlisting}
Input from (this) file:
\begin{lstlisting}
\usepackage{csquotes,fontspec,
geometry,babel,listings,
parskip,xparse,multicol,
titlesec,amsmath,metalogo
fancyhdr,lipsum}
\usepackage[ocgcolorlinks]
{hyperref}
\end{lstlisting}
\end{multicols}

You can also style your source code listings so they stand out more:
\begin{lstlisting}
\lstset{
	language=[LaTeX]TeX,
	upquote=true,
	basicstyle=\small\ttfamily,
	numberstyle=\tiny\color{Gray}\ttfamily,
	stepnumber=1,
	numbersep=5pt,
	rulecolor=\color{black},
	backgroundcolor=\color{black!10},
	tabsize=4,
	captionpos=b,
	breaklines=true,
	title=\lstname,
	keywordstyle=\color{RoyalBlue},
	commentstyle=\color{ForestGreen},
	stringstyle=\color{WildStrawberry},
}
\end{lstlisting}
