2

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.

  • 5
    Welcome to TeX.SE. Please provide a minimal working example that compiles and please have a look on the recording feature of tcolorbox, page 129 (section 8.3 of the current manual) – user31729 Jul 10 '17 at 21:59
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Reinstate Monica - M. Schröder Jul 10 '17 at 22:03
  • Thank you, I think the recording feature is what I needed. I will update when I figure it out. – Chris Jul 10 '17 at 22:10
5

The recording feature of tcolorbox simplifies redisplaying of content. There are some approaches to use recording, I present only one here:

  1. Define a tcolorbox environment, say displaythis 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.
  2. Say

    record={\string\redisplaythis[#1]{\jobname.display\thetcbcounter}} 
    

    at the options list of the displaythis environment, which instructs tcolorbox to write \redisplaythis{#1}{\jobname.display\thetcbcounter} to the record file.

  3. 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 to tcolorbox)

  4. Use \tcbstartrecording[myenvironments.env] before the first environment to be saved and \tcbstoprecording after the last one.

  5. 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}

enter image description here

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.