TransWikia.com

Captions for tcolorbox

TeX - LaTeX Asked by sequence on November 26, 2020

I would like to add captions to a tcolorbox structure. How can I do so? The standard caption{} construct does not work in this case. Or is there a way to make the same thing (but with captions) without using tcolorbox?

begin{tcolorbox}
begin{verbatim}
{'maxs': [0.0,
  0.0006787988281249935,
  0.00032118164062514,
  0.0001609179687499518],
 'means': [0.0,
  0.00013521044921876194,
  8.352197265622923e-05,
  4.6293782552030614e-05]}
end{verbatim}
end{tcolorbox}

enter image description here

One Answer

Probably something like this as adapted from --

Splitting verbatim inside figure across pages

enter image description here

documentclass[a4paper]{article}

usepackage{listings}
usepackage{tcolorbox}

tcbuselibrary{breakable,skins,listings}

newtcblisting[use counter=lstlisting]{cmhlisting}[3][]{%
    width=textwidth,
    colback=blue!5!white,
    colframe=white!85!black,
    listing only,
    listing options={#1},
    center title,
    %breakable,
    %float,
    %floatplacement=!ht,
    title={color{black}{scshape My Caption thetcbcounter}: ~#2}
}

begin{document}
begin{cmhlisting}{Caption with verbatim in  texttt{tcolorbox}}
'maxs': [0.0,
    0.0006787988281249935,
    0.00032118164062514,
    0.0001609179687499518],
    'means': [0.0,
    0.00013521044921876194,
    8.352197265622923e-05,
    4.6293782552030614e-05]
end{cmhlisting}
end{document}

Answered by js bibra on November 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP