2

I'm trying to create a code listing and set custom options using pgfkeys. The below provided code works fine. The style handler for title option (currently commented out) is breaking TeX compilation by throwing the capacity exceeded error. What is wrong with the title style handler ?

\documentclass[12pt]{book}
\usepackage{tcolorbox}
\usepackage{hyperref}

\tcbuselibrary{breakable}
\tcbuselibrary{skins}
\tcbuselibrary{listings}

\pgfkeys{%
  /code listing/.cd,%
  title/.initial = {},%
  label/.initial = {},%
  %% title/.style = \pgfkeys{%
  %%   /tcb/.cd,%
  %%   title=#1,%
  %% }%
}

\newtcbinputlisting{\CodeListing}[2][]{%
  beamer, breakable, listing only,%
  colback=red!5!white, fonttitle=\ttfamily,%
  listing file=#2%
}

\newcommand{\IncludeCodeFromFile}[2][]{%
  \pgfqkeys{/code listing}{#1}%
  \CodeListing{#2}%
}

\begin{document}
\IncludeCodeFromFile[title=Some Code]{somefile.cxx}
\end{document}
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Surya
  • 709

1 Answers1

4

You should just cut out the \pgfkeys call within the .style and leave only the list of keys that was in its argument. Note that the .style handler is a kind of .code, one that implicitly passes its argument to \pgfkeysalso. Basically, it's a \pgfkeys macro that "expands" to the keys you give it.

Ryan Reich
  • 37,958