4

I've got many tcolorboxes in my document and I want to add one to my table of contents.

A test code:

\documentclass[10pt,a4paper,twoside,spanish]{scrbook}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}
\usepackage{units}
\usepackage{endnotes}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}

\usepackage{scrhack}
\usepackage{graphicx}
\usepackage{color,xcolor}

\usepackage[most]{tcolorbox}
\tcbuselibrary{theorems}

\usepackage{tikz, pgf, pgfplots}
\usetikzlibrary{arrows,backgrounds,plotmarks,shapes.geometric,calc}

\pgfplotsset{width=7cm,compat=newest}
\pgfplotsset{plot coordinates/math parser=false}



\tcbset {
  teoestilo/.style={
    shadow={2mm}{-1mm}{0mm}{black!50!white},  
      colback=gray!20!white,
      coltext=black,
      coltitle=white,
      enlarge top by=\baselineskip/2+1mm,
      enlarge top at break by=0mm, 
      pad at break=2mm,
      fonttitle=\bfseries\large, 
      fontupper=\normalsize,
      enhanced,
      colframe=black,
      boxrule=1pt,
      arc=2mm,
      breakable,
      top=2mm,
      toptitle=1mm,
      bottomtitle=1mm,
      before=\vskip18pt,
      separator sign ={\ $\blacktriangleright$}
  },
}
\newtcbtheorem[auto counter, number within=section]{teorema}%
{Teorema}{teoestilo}{th}
\newtcbtheorem[auto counter, number within=section]{definicion}%
{Definicion}{teoestilo}{def}
\newtcbtheorem[auto counter, number within=section]{ejercicio}%
{Ejercicio}{teoestilo}{ejer}
\newtcbtheorem[auto counter, number within=section]{corolario}%
{Corolario}{teoestilo}{coro}
\newtcbtheorem[auto counter, number within=section]{ejemplo}%
{Ejemplo}{teoestilo}{ejem}
\newtcbtheorem[auto counter, number within=section]{nota}%
{Nota}{teoestilo}{not}
\newtcbtheorem[auto counter, number within=section]{propo}%
{Proposición}{teoestilo}{prop}

\begin{document}

\maketitle
\tableofcontents{}

\chapter{MÉTODOS ITERATIVOS PARA RAÍCES REALES}


\section{Método De la Bisección}


\subsection{Introducción}

text test

\begin{teorema}{Bolzano}{}
Sea una función cualquiera $f\: :[a,\: b]\longrightarrow\mathbb{R}$, tal que $f\in C([a,\: b])$. Entonces:\\
Si $f(a)\cdot f(b)<0\Rightarrow \exists c\in ]a,\: b[\:/\: f(c)=0$
\end{teorema}
\begin{definicion}{Definicion}{}
xdkdkdkdkd
\end{definicion}
\end{document}

Thanks

0

1 Answer 1

5

Ok, I've found information about that, tcolorbox has got tcblistof command, with this command you can make a table of contents from your own tcolorboxes. The code:

\documentclass[10pt,a4paper,twoside,spanish]{scrbook}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}
\usepackage{units}
\usepackage{endnotes}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}

\usepackage{scrhack}
\usepackage{graphicx}
\usepackage{color,xcolor}

\usepackage[most]{tcolorbox}
\tcbuselibrary{theorems}

\usepackage{tikz, pgf, pgfplots}
\usetikzlibrary{arrows,backgrounds,plotmarks,shapes.geometric,calc}

\pgfplotsset{width=7cm,compat=newest}
\pgfplotsset{plot coordinates/math parser=false}

% Fixing the tables with tcolorbox
\makeatletter
\renewcommand*\l@tcolorbox{\@dottedtocline{1}{1.5em}{3.0em}}
\makeatother


\tcbset {
  teoestilo/.style={
    shadow={2mm}{-1mm}{0mm}{black!50!white},  
      colback=gray!20!white,
      coltext=black,
      coltitle=white,
      enlarge top by=\baselineskip/2+1mm,
      enlarge top at break by=0mm, 
      pad at break=2mm,
      fonttitle=\bfseries\large, 
      fontupper=\normalsize,
      enhanced,
      colframe=black,
      boxrule=1pt,
      arc=2mm,
      breakable,
      top=2mm,
      toptitle=1mm,
      bottomtitle=1mm,
      before=\vskip18pt,
      separator sign ={\ $\blacktriangleright$}
  },
}
\newtcbtheorem[auto counter, number within=section,list inside=thm]{teorema}%
{Teorema}{teoestilo}{th}
\newtcbtheorem[auto counter, number within=section,list inside=thm]{definicion}%
{Definicion}{teoestilo}{def}
\newtcbtheorem[auto counter, number within=section,list inside=ej]{ejercicio}%
{Ejercicio}{teoestilo}{ejer}
\newtcbtheorem[auto counter, number within=section,list inside=thm]{corolario}%
{Corolario}{teoestilo}{coro}
\newtcbtheorem[auto counter, number within=section,list inside=ej]{ejemplo}%
{Ejemplo}{teoestilo}{ejem}
\newtcbtheorem[auto counter, number within=section,list inside=thm]{nota}%
{Nota}{teoestilo}{not}
\newtcbtheorem[auto counter, number within=section,list inside=thm]{propo}%
{Proposición}{teoestilo}{prop}

\begin{document}

\maketitle
\tableofcontents{}
\newpage
\tcblistof[\section*]{thm}{Listado de Teoremas, Proposiciones, Corolarios Y Definiciones}
\newpage

\tcblistof[\section*]{ej}{Listado Ejercicios y Ejemplos}
\newpage

\chapter{MÉTODOS ITERATIVOS PARA RAÍCES REALES}


\section{Método De la Bisección}


\subsection{Introducción}

text test

\begin{teorema}{Bolzano}{}
Sea una función cualquiera $f\: :[a,\: b]\longrightarrow\mathbb{R}$, tal que $f\in C([a,\: b])$. Entonces:\\
Si $f(a)\cdot f(b)<0\Rightarrow \exists c\in ]a,\: b[\:/\: f(c)=0$
\end{teorema}
\begin{definicion}{Definicion}{}
xdkdkdkdkd
\end{definicion}
\end{document}

It is fixed now, the image shows the bug before the fixing:

colorbox

1
  • 5
    You may use \renewcommand*\l@tcolorbox{\@dottedtocline{1}{1.5em}{2.3em}} and enlarge 2.3em to some higher value to get more space for the numbers in the TOC; see page 69 of the documentation. Dec 9, 2013 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .