Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Looks like \pgfkeys inside \pgfkeys is giving problem. I've removed the \pgfkeys inside style handler and it is working now. –  Surya Aug 23 '13 at 4:45
    
Yes, a .style key collects other styles, a .code key would be the right choice for a key with \pgfkeys. What are you trying to do, though? You first define a value key title and then overwrite it with title/.style. — Anyway, it would be better to do title/.style={/tcb/title={#1}}, see Key that takes a list of other keys as argument and sets them –  Qrrbrbirlbel Aug 23 '13 at 4:54
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.