Global counter for different tcolor boxes

In my preamble I have defined three types of tcolor boxes (theorems, definitions, examples). I want to number the boxes independently of their type and the selection they appear in, with the title lines starting with (1), (2), (3) etc... How can I achieve this? At the moment the three types of boxes are numbered separately...

I would also like to be able to attach labels to the boxes which, when called up, show the number of the corresponding box in brackets: e.g. (1), (2), (3), ...

I would much appreciate your help! Any ideas for general improvement of the preamble would also be welcome!

This issue is documented in the tcolorbox manual, at the section 5.1, Numbered Boxes.

Replace auto counter with use counter=mycounter to set a common counter to your boxes. For example for the definitionbox, using a custom counter commonbox:

You can still use \thetcbcounter inside the box. Don't forget to declare the counter with

in the preamble.

Full example:



Ask AI
#1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 #15 #16 #17 #18 #19 #20 #21 #22 #23 #24 #25 #26 #27 #28 #29 #30 #31 #32 #33 #34 #35 #36 #37 #38 #39 #40 #41 #42 #43 #44 #45 #46 #47 #48 #49 #50 #51 #52 #53 #54 #55 #56 #57 #58 #59 #60 #61 #62 #63 #64 #65 #66 #67 #68 #69 #70