%% The LaTeX package tcolorbox - version 4.11 (2017/09/14)
%% tcblistings.code.tex: Code for colorboxes with listings
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2006-2017 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `author-maintained'.
%%
%% This work consists of all files listed in README
%%
%\makeatletter
\tcb@set@library@version{4.11}

\RequirePackage{listings}[2007/02/22]

\tcbuselibrary{listings@core}

\let\tcb@listing@MakeCaption@org=\lst@MakeCaption

\def\tcb@listing@set@MakeCaption@org{%
  \let\lst@MakeCaption\tcb@listing@MakeCaption@org}
\def\tcb@listing@set@MakeCaption@empty{%
  \lst@HRefStepCounter{lstlisting}%
  \let\lst@MakeCaption\@gobble}

\lstdefinestyle{tcblatex}{language={[LaTeX]TeX},
     aboveskip={0\p@ \@plus 6\p@}, belowskip={0\p@ \@plus 6\p@},
     columns=fullflexible, keepspaces=true,
     breaklines=true, breakatwhitespace=true,
     basicstyle=\ttfamily\small, extendedchars=true, nolol,
     inputencoding=\kvtcb@listingencoding}

\def\tcb@listing@input@listing#1#2{%
  \begingroup%
  \toks@=\expandafter{#1}%
  \edef\tcb@temp{\noexpand\lstinputlisting[nolol,\the\toks@]}%
  \tcb@listing@set@MakeCaption%
  \tcb@temp{#2}%
  \endgroup%
}%


\def\tcb@listing@uselistinglisting{%
  \tcb@listing@input@listing{\kvtcb@listingoptions}{\kvtcb@listingfile}%
}%

\def\tcb@listing@usetemplisting{%
  \tcb@listing@input@listing{\kvtcb@listingoptions}{\kvtcb@tempfile}%
}%

\def\tcb@listing@doc@usetemplisting{%
  \tcb@listing@input@listing{\kvtcb@doclistingoptions}{\kvtcb@tempfile}%
}

\tcbset{%
  listing options/.store in=\kvtcb@listingoptions,%
  listing style/.style={listing options={style=#1}},%
  no listing options/.style={listing options=},%
  listing inputencoding/.store in=\kvtcb@listingencoding,%
  listing remove caption/.is choice,
  listing remove caption/true/.code={\let\tcb@listing@set@MakeCaption\tcb@listing@set@MakeCaption@empty},
  listing remove caption/false/.code={\let\tcb@listing@set@MakeCaption\tcb@listing@set@MakeCaption@org},
  listing remove caption/.default=true,
  listing engine/listings/.code={\let\tcbuselistinglisting\tcb@listing@uselistinglisting%
    \let\tcbusetemplisting\tcb@listing@usetemplisting%
    \let\tcb@doc@usetemplisting\tcb@listing@doc@usetemplisting},
  every listing line/.code={%
    \def\lst@NewLine{%
      \ifx\lst@OutputBox\@gobble\else
          \par\noindent \hbox{}#1%
      \fi
      \global\advance\lst@newlines\m@ne
      \lst@newlinetrue}},%
  every listing line*/.style={every listing line={#1},%
    code={\setbox\z@=\hbox{#1}\tcbdimto\kvtcb@rightupper{\kvtcb@rightupper+\wd\z@}}},%
}


\tcbset{%
  reset@listings/.style={%
    listing style=tcblatex,
    listing inputencoding=\inputencodingname,
    listing remove caption,
    listing engine=listings,
  },
  initialize@reset=reset@listings,
}

