1

I am using mdframed to create boxes, that have titles and all.

I would like to have a list of these immediately after the table of contents, just like a list of figures, or of tables.

I saw a solution, here: List of Boxes in Table of Contents

But it is way too complicated for me (I am not too skilled), because it seems to use a new environment.

I want to do it in the book environment, but I might need it also for article in the future.

Any simple solution out there, before I plunge into the headache of defining new environments?

Thanks!!!

Francesco

  • Welcome to TeX.SE. Are you sticking to mdframed? With tcolorbox you can make boxes as well, and generating a List of Boxes is ...(pun intended!) straight out of the box ;-) – user31729 Jan 20 '17 at 17:29
  • The provided solution by Gonzalo Medina in the link above seems to be what you request. Unless you don't show us what you have done so far it's hard to tell what a possible solution will be. And most likely you mean book class, not book. environment – user31729 Jan 20 '17 at 17:47
1

I suggest to use the startcode option of mdframed and apply an \addcontentsline with \mdf@frametitle which is defined to hold the content of the frametitle option.

\documentclass{article}

\usepackage{mdframed}

\usepackage{blindtext}
\makeatletter


\newmdenv[startcode={\addcontentsline{mdbox}{section}{\mdf@frametitle}}]{myenv}





\newcommand{\listofboxes}{%
  \section*{List of Boxes}
  \@starttoc{mdbox}%
}
\makeatother


\begin{document}
\listofboxes

\clearpage

\begin{myenv}[frametitle={Foo}]
Stuff

\blindtext[5]
\end{myenv}

\begin{myenv}[frametitle={Foobar}]
Other Stuff

\blindtext[2]
\end{myenv}


\end{document}

enter image description here

  • Hi, thank you very much. I think I got it! Yes of course it was class, sorry I wrote fast – Francesco Saraceno Jan 20 '17 at 18:50
  • Hi, sorry for the long wait, I was actually writing the text of boxes. So I tried to work out a file similar to the one suggested by Christian, basically using startcode as an option to mdframed (in order not to change all the frames. – Francesco Saraceno Apr 18 '17 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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