I created a new environment using \newtcolorbox
, with auto numbering and a correctly-working TOC entry and everything. The individual items appear exactly where they should within the chapters. What I would like is to display all of these items again, at the end of a chapter or at the end of a part, or in an appendix or something. I don't want another TOC; I want to display the actual environment items, the way they appear in the main body of the text, again in one big collection. I haven't had any luck searching for an answer to this, so any advice will be greatly appreciated.
1 Answer
The recording
feature of tcolorbox
simplifies redisplaying of content. There are some approaches to use recording
, I present only one here:
- Define a
tcolorbox
environment, saydisplaythis
which is meant for the first display of content and stores the content to a file named\jobname.display\thetcbcounter
, which expands to\jobname.display1
,\jobname.display2
etc. Say
record={\string\redisplaythis[#1]{\jobname.display\thetcbcounter}}
at the options list of the
displaythis
environment, which instructstcolorbox
to write\redisplaythis{#1}{\jobname.display\thetcbcounter}
to the record file.Define a total
tcolorbox
reddisplaythis
which uses the mandatory argument in order to load the already stored content. (The\NewTotalTColorBox
has the advantage, that the content of the box can be specified as well, contrary totcolorbox
)Use
\tcbstartrecording[myenvironments.env]
before the first environment to be saved and\tcbstoprecording
after the last one.Apply
\tcbinputrecords[myenvironments.env]
for redisplay finally.
\documentclass{book}
\usepackage[most]{tcolorbox}
\usepackage{blindtext}
\makeatletter
\NewTColorBox[auto counter,list type=section,list inside=red]{displaythis}{O{}}{%
enhanced,
sharp corners,
title={My nice Environment \thetcbcounter},
saveto={\jobname.display\thetcbcounter},
record={\string\redisplaythis[#1]{\jobname.display\thetcbcounter}},
#1,
}
\NewTotalTColorBox[auto counter]{\redisplaythis}{O{}m}{
enhanced,
sharp corners,
title={My nice Environment (again) \thetcbcounter},
#1
}{\input{#2}}
\makeatother
\begin{document}
\tcbstartrecording[myenvironments.env]
\tcblistof{red}{List of environments}
\begin{displaythis}
\blindtext
\end{displaythis}
\begin{displaythis}[colback=white!60!yellow]
\blindtext[2]
\end{displaythis}
\tcbstoprecording
\tcbinputrecords[myenvironments.env]
\end{document}
tcolorbox
, page 129 (section 8.3 of the current manual)\documentclass{...}
and ending with\end{document}
.