Con el paquete de etoc
puedo generar fácilmente la lista de capítulos y secciones usando el comando\tableofcontents
También puede generar la lista de tablas y figuras con comando \locallistoftables
y\locallistoffigures
\tableofcontents % <-- line 41 in main.tex
\listoffigures % <-- line 43 in main.tex
\listoftables % <-- line 49 in main.tex
Pero, ¿cómo generar la lista de todos los ejemplos del libro?
Por ejemplo, tengo dos ejemplos en main.tex
, ¿cómo generar la lista de todos los ejemplos automáticamente como el comando \listoffigures
?
\newmdenv[ % <---- line 26 in main.tex, exambox environment with `mdframed` package
style=kaoboxstyle,
backgroundcolor=Gray!12!White,
frametitlebackgroundcolor=Gray!12!White,
]{exambox}
%% ... omit
\begin{exambox}[frametitle=Example 1] % <--- line 79 in main.tex
\blindtext[1]
\label{exampe1}
\end{exambox}
\begin{exambox}[frametitle=Example 2]
\blindtext[3]
\label{exampe2}
\end{exambox}
El mwe viene aquí:
\documentclass[10pt,a4paper]{book}
\usepackage{blindtext}
\RequirePackage{tikz}
\RequirePackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{kaoboxstyle}{
skipabove=1.5\topskip,
skipbelow=.5\topskip,
rightmargin=0pt,
leftmargin=0pt,
innerrightmargin=7pt,
innerleftmargin=7pt,
topline=false,
bottomline=false,
rightline=false,
leftline=false,
frametitlerule=true,
linecolor=black,
fontcolor=black,
frametitlealignment=\raggedright\noindent % 防止全局缩进时,标题缩进
}
\RequirePackage{etoc} % Required to insert local tables of contents
\newmdenv[
style=kaoboxstyle,
backgroundcolor=gray!12!white,
frametitlebackgroundcolor=gray!12!white,
]{exambox}
\begin{document}
\begingroup % Local scope for the following commands
% Turn on compatibility mode for the etoc package
\etocstandarddisplaystyle % "toc display" as if etoc was not loaded
\etocstandardlines % "toc lines as if etoc was not loaded
\tableofcontents % Output the table of contents
\listoffigures % Output the list of figures
% Comment both of the following lines to have the LOF and the LOT on different pages
\let\cleardoublepage\bigskip
\let\clearpage\bigskip
\listoftables % Output the list of tables
\endgroup
\chapter{First Chapter}
\blindtext
\begin{figure}
\centering
\includegraphics{example-image}
\caption{fig 1}
\label{fig:enter1}
\end{figure}
\begin{figure}
\centering
\includegraphics{example-image}
\caption{fig 2}
\label{fig:enter2}
\end{figure}
\chapter{Second Chapter}
\blindtext[2]
{\color{red} exambox ref: \ref{exampe1}}
\begin{exambox}[frametitle=Example 1]
\blindtext[1]
\label{exampe1}
\end{exambox}
\begin{exambox}[frametitle=Example 2]
\blindtext[3]
\label{exampe2}
\end{exambox}
\begin{figure}
\centering
\includegraphics{example-image}
\caption{fig 3}
\label{fig:enter3}
\end{figure}
\chapter{Third Chapter}
\blindtext
\begin{table}[ht]
\centering
\begin{tabular}{c|c}
a & b \\
c & d
\end{tabular}
\caption{table 1}
\label{tab:table1}
\end{table}
\chapter{Second Chapter}
\blindtext
\blindtext
\begin{table}[ht]
\centering
\begin{tabular}{c|c}
1 & 2 \\
3 & 4
\end{tabular}
\caption{table 2}
\label{tab:table2}
\end{table}
\end{document}