2

I was wondering if someone knows how to "tell" LaTeX to print an Index of Boxes ("Recuadros" for me), in a similar way to the regular Index of Tables. In the last case there is an extra space between tables from different sections, something I have been unable to to in the case of boxes.

The way I am doing the boxes is first to define the style and then the numbering for the boxes (using mdframed): ....

\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{MyFrame}{%
    nobreak,    
    linecolor=blue,
    outerlinewidth=0.5pt,
    roundcorner=20pt,
    innertopmargin=\baselineskip,
    innerbottommargin=\baselineskip,
    innerrightmargin=20pt,
    innerleftmargin=20pt,
    frametitlealignment=\center,
    backgroundcolor=gray!30!white}
\usepackage{tocloft}
\newcounter{infobox}
\newenvironment{infobox}[1][]{%
\refstepcounter{infobox}%
\begin{mdframed}[%
style=MyFrame,
frametitle={Recuadro \theinfobox\ #1},
]%
\addcontentsline{lob}{section}{\numberline{\theinfobox}#1}%
}{%
\end{mdframed}
}
\makeatletter
\newcommand\listboxname{Índice de recuadros}
\newcommand\listofboxes{
\chapter*{\listboxname}
\@starttoc{lob}
}
\renewcommand{\theinfobox}{\thechapter.\arabic{infobox}}
\makeatother
....

The way LaTeX prints the results for tables and boxes are:

enter image description here

You can see there is an extra space between tables from different chapters which is what I am trying to do for the boxes.

  • This requires adding code to the \chapter command and this depends on the used documentclass. Side comment: You're using tocloft already, which provides 'easier' ways to define such \listof... commands ;-) – user31729 Dec 6 '15 at 23:05
2

Here's a solution for the book class: Modifying \@chapter slightly to add automatically vertical spacing to the .lob file after each \chapter starts.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{MyFrame}{%
    nobreak,    
    linecolor=blue,
    outerlinewidth=0.5pt,
    roundcorner=20pt,
    innertopmargin=\baselineskip,
    innerbottommargin=\baselineskip,
    innerrightmargin=20pt,
    innerleftmargin=20pt,
    frametitlealignment=\center,
    backgroundcolor=gray!30!white}
\usepackage{tocloft}
\usepackage{xpatch}


\newcounter{infobox}[chapter]
\newenvironment{infobox}[1][]{%
  \refstepcounter{infobox}%
  \begin{mdframed}[%
    style=MyFrame,
    frametitle={Recuadro \theinfobox\ #1},
    ]%
    \addcontentsline{lob}{section}{\protect\numberline{\theinfobox~}#1}%
  }{%
  \end{mdframed}
}

\makeatletter
\xpatchcmd{\@chapter}{%
  \chaptermark{#1}%
}{
  \chaptermark{#1}%
  \addtocontents{lob}{\protect\addvspace{10\p@}}%
}{\typeout{success}}{}


%
\newcommand\listboxname{Índice de recuadros}
\newcommand\listofboxes{%
  \chapter*{\protect\listboxname}
  \@starttoc{lob}
}
\renewcommand{\theinfobox}{\thechapter.\arabic{infobox}}
\makeatother




\begin{document}
\tableofcontents
\listofboxes
\listoffigures
\chapter{First}
\begin{infobox}[Some box]
  And now for something completely different
\end{infobox}
\begin{figure}
  \caption{second}
\end{figure}

\begin{figure}
  \caption{second}
\end{figure}

\begin{figure}
  \caption{second}
\end{figure}


\chapter{Second}
\begin{infobox}[Some box]
  And now for something completely different
\end{infobox}

\begin{infobox}[Some box]
  And now for something completely different
\end{infobox}

\begin{figure}
  \caption{second}
\end{figure}

\end{document}

enter image description here

  • Thank you Christian, unfortunately it is still throwing the output in same way. Could it be because I am using "LaTex + Bib(la) tex + LaTex (x2) + dvip + ps2pdf + Ver PDF"? – Fernando Dec 7 '15 at 17:59
  • @Fernando: I would say: No -- it's perhaps a different document class, but you did not say which class you're using. I asked you already in a comment below your question, but you did not give feedback to it :-( – user31729 Dec 7 '15 at 19:14
  • I am sorry Christian. I forgot that. What I am using is: "\documentclass[twoside]{book}". Thank you very much! – Fernando Dec 8 '15 at 19:52
  • @Fernando: I've used book too, I don't know what breaks in your case. – user31729 Dec 9 '15 at 16:34

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.