% Listing configuration file

% !TeX encoding = utf8

\makeatletter

\let\scr@float@addtolists@warning\relax
\definecolor{lightergray}{gray}{0.99}

\lstset{%
	language=[LaTeX]TeX,
	basicstyle=\ttfamily,
	keywordstyle=\color{RoyalBlue},
	commentstyle=\color{darkgray},
	backgroundcolor=\color{lightergray},
	stringstyle=\rmfamily,
	numbers=none,
	showstringspaces=false,
	breaklines=true,
	%frameround=ftff,
	frame=lines,
	escapeinside={£*}{*£},
	tabsize=2,
	morekeywords={unless}}

\lstnewenvironment{code}
	{\lstset{columns=fullflexible,keepspaces=true,%
	 	basicstyle=\ttfamily\small}}{}

\lstnewenvironment{sidebyside}
 {\global\let\lst@intname\@empty 
  \setbox\z@=\hbox\bgroup 
  \lstset{columns=fullflexible,% 
   linewidth=0.45\linewidth,keepspaces=true,%
   breaklines=true,% 
   breakindent=0pt,%
   boxpos=t,%
   basicstyle=\ttfamily\small}%
  \lst@BeginAlsoWriteFile{\jobname.tmp}}
 {\lst@EndWriteFile\egroup 
  \begin{center}% 
   \begin{minipage}{0.45\linewidth}% 
    \hbox to\linewidth{\box\z@\hss} 
   \end{minipage}% 
   \qquad 
   \begin{minipage}{0.45\linewidth}%
    \lstset{frame=none}% 
    \leavevmode \catcode`\^^M=5\relax 
    \small\input{\jobname.tmp}% 
   \end{minipage}% 
  \end{center}} 

\DeclareRobustCommand*{\clsname}{%
	\texorpdfstring{\@ifstar\@clsname\@@clsname}{}}
	\def\@clsname#1{{\normalfont\textsf{#1}}}
	\def\@@clsname#1{{\normalfont\textsf{#1}\clsindex{#1}}}
\DeclareRobustCommand*{\pkgname}{%
	\texorpdfstring{\@ifstar\@pkgname\@@pkgname}{}}
	\def\@pkgname#1{{\normalfont\textsf{#1}}}
	\def\@@pkgname#1{{\normalfont\textsf{#1}\pkgindex{#1}}}
\DeclareRobustCommand*{\optname}{%
	\texorpdfstring{\@ifstar\@optname\@@optname}{}}
	\def\@optname#1{{\normalfont\texttt{#1}}}
	\def\@@optname#1{{\normalfont\texttt{#1}\optindex{#1}}}
\DeclareRobustCommand*{\othname}{%
	\texorpdfstring{\@ifstar\@othname\@@othname}{}}
	\def\@othname#1{{\normalfont\texttt{#1}}}
	\def\@@othname#1{{\normalfont\texttt{#1}\othindex{#1}}}
\DeclareRobustCommand*{\envname}{%
	\texorpdfstring{\@ifstar\@envname\@@envname}{}}
	\def\@envname#1{{\normalfont\texttt{#1}}}
	\def\@@envname#1{{\normalfont\texttt{#1}\envindex{#1}}}
\DeclareRobustCommand*{\cmdname}{%
	\texorpdfstring{\@ifstar\@cmdname\@@cmdname}{\textbackslash}}
	\def\@cmdname#1{{\ttfamily\textbackslash\textcolor{RoyalBlue}{#1}}}
	\def\@@cmdname#1{{\ttfamily\textbackslash\textcolor{RoyalBlue}{#1}}\cmdindex{#1}}

\def\clsindex#1{\index{#1@\textsf{#1}}%
	\index{#1@\textsf{#1} \textit{\textit{(class)}}}}
\def\pkgindex#1{\index{Package!#1@\textsf{#1}}%
	\index{#1@\textsf{#1} \textit{(pack.)}}}
\def\optindex#1{\index{Option!#1@\texttt{#1}}%
	\index{#1@\texttt{#1} \textit{(opt.)}}}
\def\othindex#1{\index{#1@\texttt{#1}}}
\def\envindex#1{\index{Environment!#1@\texttt{#1}}%
	\index{#1@\texttt{#1} \textit{(env.)}}}
\def\cmdindex#1{\index{#1@\texttt{\hspace*{-1.2ex}%
	\textbackslash#1}}}

\DeclareRobustCommand\meta[1]{%
	$\langle${\normalfont\itshape#1}$\rangle$}
\DeclareRobustCommand\mail[1]{\href{mailto:#1}{\texttt{#1}}}

%\def\dotfill{\leaders\hbox to.6em{\hss .\hss}\hskip\z@ plus  1fill}%
%\def\dotfil{\leaders\hbox to.6em{\hss .\hss}\hfil}%
%\def\pfill{\unskip~\dotfill\penalty500\strut\nobreak
%	\dotfil~\ignorespaces}

\makeatother