# mdframed boxes in table of content

in reference to this question I asked here: List of Boxes in Table of Contents, I tried the following code, in which I try to use startcode as an option to the package mdframed that creates a table of contents entry. Unfortunately it does not seem to work (while the previous one, commented works perfectly). Any suggestions on what I am doing wrong? The objective is to avoid defining a new environment, and keep using the standard mdframed commands in the text. This is why I'd really like to define the addtocontents line part in the optrions of mdframed

Thanks!

\documentclass[12pt,a4paper,final]{book}
\definecolor{grigiochiaro}{gray}{0.90}
\makeatletter
\newcommand{\listofboxes}{%
\section*{List of Focus}
\@starttoc{mdbox}%
}
\makeatother
\begin{document}
\tableofcontents
\listofboxes

\chapter{Chapter 1}

text text text text text text text text text text text text text
text text text text text

\section{Section 1}
text text text text text text text text text text text text text
text text text text text
\begin{mdframed}[frametitle={Title of frame}]
\vspace{-15pt}
\singlespacing
text of frame text of frame text of frame text of frame text of frame
text of frame text of frame text of frame
text of frame text of frame
\end{mdframed}
text text text text text text text text text text text text text

\end{document}


The main problem is that startcode or startinnercode is not a package option, but an option for an mdframed environment. You can use it directly after \begin{mdframed} or when defining an mdframe style or environment.

Moreover, \definecolor is defined by the package \xcolor, which is loaded implicitly by mdframed, so you can use it only after loading the package.

Finally, there was an unbalanced brace.

\documentclass[12pt,a4paper,final]{book}
\makeatletter
\usepackage[framemethod=tikz,rightmargin=5,leftmargin=5,backgroundcolor=grigiochiaro,roundcorner=10pt]{mdframed}
\newcommand{\listofboxes}{%
\section*{List of Focus}
\@starttoc{mdbox}%
}
\makeatother
\definecolor{grigiochiaro}{gray}{0.90}
\begin{document}
\tableofcontents
\listofboxes

\chapter{Chapter 1}

text text text text text text text text text text text text text
text text text text text

\section{Section 1}
text text text text text text text text text text text text text
text text text text text
\makeatletter
\begin{mdframedtoc}[frametitle={Title of frame}]
\vspace{-15pt}
%\singlespacing
text of frame text of frame text of frame text of frame text of frame
text of frame text of frame text of frame
text of frame text of frame
\end{mdframedtoc}
\makeatother
text text text text text text text text text text text text text

\end{document}

• Thank you, it worked! I would also want to number the box titles (by chapter), but that, is way less important than listing them in the table of content. Thank you again! – Francesco Saraceno Apr 18 '17 at 16:15
• @FrancescoSaraceno Well, if you have further questions, then ask them, but please as separate questions and not in the comments. It is unlikely that anyone except me sees the comments. – gernot Apr 18 '17 at 16:16