In a book with figures, tables and listings, I figured out that all listings and some tables and figures look better when presented in a tcolorbox. The book has the usual tables of contents:
\tableofcontents{}
\listoffigures{}
\listoftables{}
\lstlistoflistings{}
but tcolorboxes have their own headlines (and may define their own counters), so it seems redundant (and unattractive) to have the usual captions and labels for figures, tables and listings too.
So my question is how to produce the lists of figures/tables/listings the reader expects after the ToC when
- tcolorbox is used exclusively?
- tcolorbox is used sometimes, while the plain listings package and regular table/figure environments are used in other cases?
EDIT: Here is a MWE (adapted from T.F.Sturm) that has figures, tables and listings as well as a tcolorbox theorem and listing with a label and a counter. How do I make them appear in the ToC section in the beginning of the file?
\documentclass{article}
\usepackage{tikz}
\usepackage{here}
\usepackage[listings,theorems]{tcolorbox}
\tcbset{noparskip}
\begin{document}
\tableofcontents{}
\listoffigures{}
\listoftables{}
\lstlistoflistings{}
\pagebreak{}
%----------------------------------------------------------
\section{Colored boxes}
\begin{tcolorbox}[colback=red!5,colframe=red!75!black]
My box.
\end{tcolorbox}
\begin{tcolorbox}[colback=blue!5,colframe=blue!75!black,title=My title]
My box with my title.
\end{tcolorbox}
%----------------------------------------------------------
\section{\LaTeX-Examples}
\begin{tcblisting}{colback=red!5,colframe=red!75!black}
This is a \LaTeX\ example:
$\displaystyle\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}$.
\end{tcblisting}
%----------------------------------------------------------
\section{Theorems}
\newcounter{mytheorem}[section]
\def\themytheorem{\thesection.\arabic{mytheorem}}
\tcbmaketheorem{theo}{Theorem}{fonttitle=\bfseries\upshape, fontupper=\slshape,
arc=0mm, colback=blue!5,colframe=blue!75!black}{mytheorem}{theorem}
\begin{theo}{Summation of Numbers}{summation}
For all natural number $n$ it holds:\\[2mm]
$\displaystyle\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}$.
\end{theo}
We have given Theorem \ref{theorem:summation} on page \pageref{theorem:summation}.
\pagebreak{}
%----------------------------------------------------------
\section{Tables, Listings and Figures}
%----------------------------------------------------------
This is table 1
%----------------------------------------------------------
\begin{table}[H]
\centering
\begin{tabular}{ll}
Header1 & Header2 \\ \hline
Cell1 & Cell2 \\
\end{tabular}
\caption{My Table No1}
\label{tab:tab-1}
\end{table}
%----------------------------------------------------------
This is table 2
\begin{table}[H]
\centering
\begin{tabular}{ll}
Header3 & Header4 \\ \hline
Cell3 & Cell4 \\
\end{tabular}
\caption{My Table No2}
\label{tab:tab-1}
\end{table}
%----------------------------------------------------------
This is figure 1
%----------------------------------------------------------
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw (0,0) node {A} --
(2,0) node {B};
\end{tikzpicture}
\caption{Figure No1}
\label{fig:fig-1}
\end{figure}
%----------------------------------------------------------
This is figure 2
%----------------------------------------------------------
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw (0,0) node {C} --
(2,0) node {D};
\end{tikzpicture}
\caption{Figure No2}
\label{fig:fig-2}
\end{figure}
\begin{lstlisting}[caption={Java Logic 1},label=java1]
public class Main
{
public Main(String args[])
{
// Java logic in listing 1
}
}
\end{lstlisting}
%\label{code:Listing-1}
\begin{lstlisting}[caption={Java Logic 2},label=java2]
public class Main
{
public Main(String args[])
{
// More Java logic in listing 2
}
}
\end{lstlisting}
%\label{code:Listing-2}
\end{document}
Here is the output:
toc
to look like in your specific example? You don't have to create it usingTeX
, just type it out in your question :)