0

In the MWE I would like the numbering:

enter image description here

\documentclass[11pt]{book}
%================================================ Begin PREAMBLE 
\usepackage{relsize}        %Set the font size relative to the current font size    
\usepackage[neveradjust]{paralist}%
\usepackage{titlesec} 
\usepackage{etoolbox} %what does it do, why is it here?
 \usepackage[dotinlabels]{titletoc} 
\usepackage{tcolorbox}% 
\tcbuselibrary{%Begin load libraries for tcolorbox  
    skins,%
    raster,%
    breakable,%
    xparse,%
        }%End load libraries for tcolorbox      
\usepackage[hyperfootnotes=false]{hyperref}%[pdfborder={0 0 0}]
\usepackage{cleveref}% should be the last package
%============== Begin definition of EXAMPLE
\newcounter{XPL}%
\newtcolorbox%
[%beginForReferences
use counter= XPL,
number within=chapter,%
crefname={\textsc{example}}{\textsc{examples}},%
Crefname={\textsc{Example}}{\textsc{Examples}},%
]%endForReferences
{EXAMPLE}%NameEnvironment
[2][]%WhateverThatIs
{%beginDescription
detach title,before upper={\tcbtitle\quad},
left=-1mm,right=-1mm,
breakable,
enhanced,%
%grow to left by=5mm,
fontupper=\sffamily,
colback=white,
colframe=white,
fonttitle=\sffamily,
fonttitle=\bfseries,
coltitle=black,%
title={E\smaller{XAMPLE} \larger{\thetcbcounter}.\notblank{#2}{\hspace{2mm} #2}{}},%
#1,%
}%end Description
%============== End definition of EXAMPLE 
%============== Begin definition of DEMO
\newcounter{DMO}%[chapter]
\newtcolorbox%
[%beginForReferences
use counter= DMO,
number within=chapter,%
list inside= DMO,%creates the list under tcblistof
%number freestyle={\noexpand\thechapter.\noexpand\arabic{\tcbcounter}~\noexpand\mytitlemod},%Makes for LONG titles in the references.
crefname={\textsc{demo}}{\textsc{demos}},%
Crefname={\textsc{Demo}}{\textsc{Demos}}%
]%endForReferences
{%beginNameEnvironment
DEMO%
}%endNameEnvironment
[2]%
[]%WhateverThatIs
{%begin Description OUTER tcbox
    breakable,
    enhanced,%
    detach title,
attach title to upper=~,%
lower separated=true,
bicolor,%
    boxrule=1mm,%
    colframe=white,%controls both the background color for the top and the frame of the bottom
    colback=white,%This is the background color below the title.
    colbacklower=white,%This is the background color below the title.
    top=0pt,
    bottom=0pt,
    boxsep=0pt,% Sets a common padding between text and frame of box. Added to left, right, top, bottom, and middle.
    outer arc=2mm,%when line is thick. Else, can just use arc.
    fontupper=\sffamily,
    fontlower=\sffamily,
%   fonttitle=\small\sffamily,
fonttitle=\bfseries,
    coltitle=black,%
title={\textbf{D\smaller{EMO}}\hspace{1.5mm}\textbf{\thetcbcounter} \hspace{2mm} #2},%
#1%
}%end Description OUTER tcbox
%=========== End definition of DEMO
        %================= Begin definition of DEFINITION
    \newcounter{DFN}%[chapter] %To be entered in Control>ALL
    \newtcolorbox%
    [%beginForReferences
    use counter= DFN,
    number within=chapter,
    list inside= DFN,%creates the list under tcblistof
    %list type=definition,
    crefname={\textsc{definition}}{\textsc{definitions}},%
    Crefname={\textsc{Definition}}{\textsc{Definitions}},%
    ]%endForReferences
    {%beginNameEnvironment
    DEFINITION%
    }%EndNameEnvironment
    [2][]%Two brackets say to enter one label and one title?
    {%beginDescription
    detach title,%
    before upper={\tcbtitle\quad},%
    breakable,%
    enhanced,%
    arc=0.2mm,%
    %fontupper=\sffamily,%NotSerifBecauseNotPartOfText
    colback= yellow!30,%
    colframe= yellow!35!black,%
    fonttitle=\bfseries,%
    coltitle=black,%
    %code={\gdef\mytitlealert{#2}},%Used to make for LONG titles in the references.
    title=D\smaller{EFINITION} \larger{\thetcbcounter\, #2},%
    nameref={#2},%
    list entry={D\smaller{EFINITION}~\larger{\thetcbcounter ~ #2}},%the default format puts the label upfront
    #1,%Required for references.
    }%end Description
    %==================== End definition of DEFINITION
    %================ Begin definition of DEFINITIONrestated as per YASMAR and STURM
    \newcounter{DFNrst}
    \newtcolorbox%
    [%beginForReferences
    use counter=DFNrst,
    list inside= DFN,
    %number within=chapter,%
    crefname={definition (Restated)}{definitions (Restated)},%
    Crefname={Definition (Restated)}{Definitions (Restated)},%
    ]%endForReferences
    {%begin name environment
    DEFINITIONrestated%
    }%end name Environment
    [3][]%
    {%begin Format
    detach title,%This prevents the top from being the color of the frame
    before upper={\tcbtitle\quad},%This prevents the top from being the color of the frame
    %breakable,%WHY NOT?
    enhanced,%
    arc=0.2mm,%
    colback= yellow!30,%
    colframe= yellow!35!black,%
    fonttitle=\bfseries,%
    coltitle=black,%
    %begin TITLE
    title= D\smaller{EFINITION} ~\larger{\ref{#2}}~(Restated) \nameref{#2},%
    nameref={\getrefbykeydefault{#2}{name}{UNDEFINED REFERENCE}},%
    list entry= D\smaller{EFINITION}  ~\larger{\ref{#2}}~\nameref{#2} (Restated),%Order not the same as in THEOREMrestated
    label type={DFNrst},
    code={\renewcommand{\theDFNrst}{\getrefnumber{#2}}},
    #1%,
    %end TITLE
    }%end Format
    %============================== End definition of DEFINITIONrestated

as per YASMAR and STURM %================================================ End PREAMBLE \begin{document} \chapter{Something}\label{1-0-0}. \begin{EXAMPLE}[label={XPL:1-1}]{~} Text \end{EXAMPLE} \begin{EXAMPLE}[label={XPL:1-2}]{~} Text \end{EXAMPLE} \begin{EXAMPLE}[label={XPL:1-3}]{~} Text \end{EXAMPLE} \begin{EXAMPLE}[label={XPL:1-4}]{~} Text \end{EXAMPLE} \begin{EXAMPLE}[label={XPL:1-5}]{~} Text \end{EXAMPLE}

References: \Cref{XPL:1-1}, \Cref{XPL:1-2}, \Cref{XPL:1-3}

\bigskip
\begin{DEMO}[label={DMO:1-1}]{}
Text
\end{DEMO}
\begin{DEMO}[label={DMO:1-2}]{}
Text
\end{DEMO}
\begin{DEMO}[label={DMO:1-3}]{}
Text
\end{DEMO}
\begin{DEMO}[label={DMO:1-4}]{}
Text
\end{DEMO}
\begin{DEMO}[label={DMO:1-5}]{}
Text
\end{DEMO}

References: \Cref{DMO:1-1}, \Cref{DMO:1-2a}, \Cref{DMO:1-2b}, \Cref{DMO:1-2c}, \Cref{DMO:1-3}
    %============================== begin DEFINITION
    % \INDEX[]{direct problems}     \INDEX[]{reverse problems}        \INDEX[]{given reference info}     \INDEX[]{given info of concern} 
    \begin{DEFINITION}[label={DFN:1-1}]{Title}

    This is yak, yak.
    \end{DEFINITION}
    %============================== end DEFINITION
    %============================== begin DEFINITION restated
    \begin{DEFINITIONrestated}[label={DFN:1-1a}]{DFN:1-1}{~}%

    This is now restated as YAK, YAK
    \end{DEFINITIONrestated}
    %================================== end DEFINITION restated

\end{document}

Simon Dispa
  • 39,141
schremmer
  • 2,107
  • What's the reason for tcolorbox when you essentially use no box? – egreg May 07 '21 at 22:05
  • You should see the Magnum Opus! I use them with a vengeance. I just thought of the continued example to replace "In \Cref{XPL:1-n}" in a couple of places. As for the DEMOs, normally, I use a DEMO after each PROCEDURE but in a few places I need more than one DEMO after the PROCEDURE and I thought it would be better to keep the numbering of the DEMOS matched.with the numbering of the PROCEDURES. So, it;s not crucial but I sure hope you can fix it. – schremmer May 08 '21 at 13:02
  • Hi, who are you directing this comment to? ("it;s not crucial but I sure hope you can fix it") – Simon Dispa May 09 '21 at 13:19
  • @Simon Dispa That one was, before there was any answer, for egreg who, by the way, later cleaned up my MWE a bit. But I did send you a comment which should appear below your answer. – schremmer May 09 '21 at 21:56
  • I have added DEFINITION and DEFINITIONrestated as per YASMAR and STURM as a possible clue to the reference issue. – schremmer May 09 '21 at 22:13
  • (1) You probably got the code between updates. Sorry for that. (2) The problem with the link you found is not coming from the code but from hyperlink Needs to be loaded as \usepackage[hypertexnames=false, hyperfootnotes=false]{hyperref}. (3) I update my answer with your coloring recommendations and \newpage to test the links. More fun! – Simon Dispa May 09 '21 at 22:18
  • Just in case: I just updated the code. Only two tcolorbox for EXAMPLE. All the links work fine. – Simon Dispa May 10 '21 at 18:29
  • @SimonDispa Re. EXAMPLE, it was perfect but I will check the update later. Re. DEMOS To see the issues, in your file, change the DEMOs' text to: Single DEMO for PROCEDURE 1.1, First DEMO for PROCEDURE 1.2, Second DEMO for PROCEDURE 1.2,Third DEMO for PROCEDURE 1.2, etc, Single DEMO for PROCEDURE 1.3. And I should have made it clear that I need links to refer to all DEMOs. I truly appreciate the work you put into it. My MWE was dismal but I really need the best possible reference system: the readers I am writing for need it absolutely. Else they drop out or, worse, try to memorize. – schremmer May 10 '21 at 21:10
  • Thank for your feedback. To clarify: with links all DEMOS /PROCEDURES including the marked as "with no label" in your MWE, as DEMO 1.2c for example? – Simon Dispa May 10 '21 at 21:15
  • @SimonDispa All DEMOs should have links because I learned that, while students will read the PROCEDURE, they will use the DEMO. Until now, all PROCEDUREs had one DEMO but I recently ran into a situation where one PROCEDURE, namely PROCEDURE 1.2, required five DEMOs to cover all cases and then I realized this was now going to happen again and again. Hence this question. But, as I said, the MWE was terrible. So, thank YOU. – schremmer May 10 '21 at 23:17
  • UPDATE #2 with PROCEDURE, all linked. Disregard previous code. – Simon Dispa May 11 '21 at 13:34
  • @SimonDispa Almost perfect !!! If you look below, you will see, e.g. PROCEDURE 1.2.a. Would it be possible to get rid of the dot between the 2 and the a and get PROCEDURE 1.2a ? – schremmer May 12 '21 at 18:36
  • Updated to remove the dot. Changed the figure and the code (only two lines changed). How close am I from perfect? :-) I do not mind having your feedback to refine the code. On the contrary. – Simon Dispa May 12 '21 at 18:56
  • @SimonDispa Works fine in the text but not in the \tcblistof[\chapter]{DMO}{List of Demos}. See pp. 91, 92 and 107 of link – schremmer May 12 '21 at 22:04
  • Updated to get the List of Procedures. New files: main code and PROCEDURE_def.. Figure added to the answer. To produce the list use \tcblistof[\chapter]{PROC}{List of Procedures} . – Simon Dispa May 13 '21 at 04:39
  • @SimonDispa Sorry to be late. Got the list of Procedures but couldn't get rid of the front reference as in 1.1 PROCEDURE 1.1 instead of PROCEDURE 1.1 Otherwise, everything seems OK. – schremmer May 14 '21 at 05:41
  • @SimonDispa Not quite: if you move PROCEDURE 1-4, PROCEDURE 1-5, PROCEDURE 1-6a, PROCEDURE 1-6b, ... PROCEDURE 1-7, to Chapter 2, you will see that the numbering is wrong: ... PROCEDURE 1-3, PROCEDURE 2-4, PROCEDURE 2-5, PROCEDURE 2-6a, PROCEDURE 2-6b,... PROCEDURE 2-7, instead of ... PROCEDURE 1-3, PROCEDURE 2-1, PROCEDURE 2-2, PROCEDURE 2-3a, PROCEDURE 2-3b, ... PROCEDURE 2-4. In other words, the procedure number is not reset with the new chapter. – schremmer May 14 '21 at 08:34
  • Added a new update. Changes in main and PROCEDURES_def. Added more examples for chapter 2. Please download all the files and test again. Thank you for your patience and feedback. – Simon Dispa May 14 '21 at 21:40
  • @SimonDispa You seem to have solved the second issue (about restarting the procedure number when there is a new chapter number) but, according to what I see below, you forgot about the first issue, which is that, in the List of Procedures it should be PROCEDURE 1.1 instead of 1.1 PROCEDURE 1.1. (In other words,1.1 should appear only once, after Procedure) – schremmer May 14 '21 at 22:29
  • Sorry. I was using the default and forgot. It is corrected now. Use the new PROCEDURE_def. – Simon Dispa May 14 '21 at 22:48
  • @SimonDispa Everything is now fine. This link will show you that all the work you did was for a good, open source, cause. Thanks for these readers. – schremmer May 15 '21 at 00:11
  • Thank you for sharing. – Simon Dispa May 16 '21 at 13:31
  • @SimonDispa Sorry to bother you again but, when I add DEMOS to the document, the numbering of the DEMOS is strangely wrong. See link for a complete compilable example that includes yours. Details on the first page of Document.pdf – schremmer May 18 '21 at 22:06
  • I will look the issue. We never tried before an intertwined of demos an procedures. Try to see if there are more configurations to test. Otherwise the development will never end. – Simon Dispa May 19 '21 at 13:36
  • @SimonDispa I will try to think of other configurations but I think that's it. But sorry for the bother anyway. – schremmer May 19 '21 at 16:12
  • @SimonDispa Found one thing I had forgotten. See the above link which I updated. – schremmer May 20 '21 at 02:57
  • Please test this new delivery Fixes – Simon Dispa May 21 '21 at 15:40
  • @SimonDispa On page 6, it shouldn't be PROCEDURE 1.10a and PROCEDURE 1.10b but PROCEDURE 1.10 and the new tcbox PROCEDURErestated 1.10 which Yasmar -Sturm defined to automatically get its number from PROCEDURE 1.10. See my link. And then, after PROCEDURE 1.10, there should be DEMO 1.10a, DEMO 1.10b, DEMO 1.10c and after PROCEDURErestated 1.10 there should be the new tcbox DEMOrestated 1.10a, DEMOrestated 1.10b, DEMOrestated 1.10c which automatically get their numbers from DEMO 1.10a, DEMO 1.10b, DEMO 1.10c. – schremmer May 21 '21 at 22:46
  • @SimonDispa See https://tex.stackexchange.com/questions/348263/how-to-restate-a-theorem-keeping-the-same-number and https://tex.stackexchange.com/questions/404553/how-to-label-a-restated-theorem – schremmer May 22 '21 at 07:38
  • To get PROCEDURE 1.10 change \begin{PROCEDUREsub}[label={PROC:1-10}] to \begin{PROCEDURE}[label={PROC:1-10}]. DEMOS 1.10a to c are fine after. I do not understand the restarted. You want to reuse a previous number? – Simon Dispa May 23 '21 at 23:06
  • @SimonDispa I will check tomorrow. Re "the restated" (not "the restarted") here is how Sturm put it in `https://tex.stackexchange.com/questions/348263/how-to-restate-a-theorem-keeping-the-same-number': "If I understand the problem correctly, you want to restate der theorem number, but put a modified text into the restated theorem (as in the yasmar answer)." – schremmer May 24 '21 at 02:21
  • I got it. This might be a new requirement You want to be able to have a PROCEDURE or DEMO with the same number of a former one with different content. And links to either of them? It seems you already have a solution but in your last zip you did not included the code used for DEMOrestated so I changed ro DEMOsub etc. Sorry for the confusion. Lets start again with the full code you are using and test cases. – Simon Dispa May 24 '21 at 14:18
  • @SimonDispa Absolutely correct. I am sorry for the confusion. Glad Sturm bailed me out. I want to double check my "solution" and upload a new zip at the same link. But I need a few hours and I will let you know when. Thanks for your patience. – schremmer May 24 '21 at 16:24
  • @SimonDispa I have "restated" (!!!) your FIXED here: link – schremmer May 24 '21 at 23:45
  • Clear as crystal. – Simon Dispa May 25 '21 at 15:44
  • @schremmer New delivery with restated DEMOsub and PROCEDUREDsub. Please keep me posted of the testing results. RestatedSUB – Simon Dispa May 25 '21 at 19:19
  • @SimonDispa Getting there: Demo 2.1a, 2.1b, 2.1c now correctly appear as Demo 1.10a Restated, Demo 1.10b Restated, Demo 1.10c Restated between Procedure 1.10 Restated and Procedure 1.11 Restated. You then restated Procedure 1.8a which appears correctly as Procedure 1.8a Restated but only AFTER Demo 1.11 Restated. Same for Demo 1.8a Restated, Procedure 1.8b Restated. And then there is a Procedure 1.8c Restated but there is NO Procedure 1.8c. From the title, it seems to be another restatement of Procedure 1.10 but from the subtitle it seems to be another restatement of Procedure 1.8b – schremmer May 25 '21 at 23:35
  • (1) The restated takes 3 parameters: (#1) Its own label, (#2) a label of the "original" and (#3) title of the "original". But #2 and #3 are in fact arbitrary and using for printing the output as (Restated) and making the links. There is no check that the "original" actually exists. It is just a rubber stamp with the content you choose. (Procedure 1.8c is there, page 5. see the list)

    (2) DEMO and PROCEDURE are independent chains. There are no sync between their numbers, they increase independently. Only the sub(s) take their number from their parent until end.

    – Simon Dispa May 26 '21 at 13:37
  • (3) In summary it is up to the user to insert the proper contents in the proper order. In the final examples I did it carelessly (not on purpose) restating PROC 1.8a to c after PROC 1.11, and using wrong titles, but serves to illustrate the point. – Simon Dispa May 26 '21 at 13:37
  • @SimonDispa Thanks for the info. In other words, what I had forgotten is that "originals" are numbered by LaTeX (according to where they are in the chapter) but that the numbering of "Restateds" depends only on the "original" and NOT on where they are. Shame on me. So, EVERYTHING WORKS. And, THANKS again for this epic amount of work. The Magnum Opus will never be the same. – schremmer May 26 '21 at 18:56
  • It was a pleasure and a privilege to participate in real work instead of misleading MWEs. Thanks for sharing. – Simon Dispa May 26 '21 at 19:59
  • @SimonDispa Your code is still rock solid but I ran into a glitch when I moved it to the working structure I am using for the Magnum Opus. I can of course abandon my working structure but I am wondering if you might be willing to take a look at glitch. – schremmer Jul 19 '21 at 00:17
  • @schremmer I will do my best. – Simon Dispa Jul 19 '21 at 12:58
  • @SimonDispa Not only did your best work (of course) but in two hours? I will move it to the magnum opus in a couple of days and watch out better for my mistakes. Thanks again. – schremmer Jul 20 '21 at 06:52
  • @schremmer Serendipity. – Simon Dispa Jul 20 '21 at 20:30

2 Answers2

1

UPDATE after several follow-up comments.

To get some automation, I defined several new tcolorboxes.

(1) For EXAMPLE mode: the normal tcolorbox and a second, used with the (Continuation), which keeps the same number and adds the word.

(2) For PROCEDURE mode: the normal box, the middle tcolorboxes with an alpha counter added, and the last one of this mode to reset the counters.

(3) The package hyperref has to be loaded with the option hypertexnames=false to avoid the jumping to wrong places. https://tex.stackexchange.com/a/3197/161015

I run several tests:

(1) Copy and pasted several boxes in the middle in both modes to test the automatisms.

(2) Started a new chapter to verify the first number and correct initialization.

(3) Checked all links.

To unclutter up the code, I put the EXAMPLE definitions and the DEMOS definitions in separate files, and also for the examples of use of EXAMPLE and PROCEDURE.

a

c

x1

x3

This the main code (updated)

% !TEX TS-program = pdflatex

\documentclass[11pt]{book} %================================================ Begin PREAMBLE %

%%% added <<<<<<<<<<<<<<<<< \usepackage{xpatch} \xpretocmd{\chapter}{% reset counters & add some space in list \setcounter{PROCstore}{0}% \setcounter{DMOstore}{0}% \setcounter{DMOm}{0}% \setcounter{subDMOm}{0}% \setcounter{PROCm}{0}% \setcounter{subPROCm}{0}% \addtocontents{PROC}{\protect\addvspace{10pt}}% \addtocontents{DMO}{\protect\addvspace{10pt}}}% {}{} %% <<<<<<<<<<<<<<<<<<<<<<<<<<<
\usepackage[usenames,dvipsnames,table]{xcolor}
\definecolor{LightGray}{gray}{0.990}%gray is pre-defined; 1 is white \definecolor{DarkGray}{gray}{0.85}%gray is pre-defined; 1 is white \colorlet{LightBlue}{blue!3!white}%d color for the rest \colorlet{DarkBlue}{blue!20!white}%second color for the rest \newcommand{\INDEX}[2][]{\phantomsection% \if\relax\detokenize{#1}\relax\index{#2}\label{ind:#2}% \else\index{#2}\label{ind:#1}\fi% }% \newcommand{\DEX}[2][]{% \if\relax\detokenize{#1}\relax\hyperref[ind:#2]{#2}% % (\Cpageref{ind:#2})% \else\hyperref[ind:#1]{#2}% %(\Cpageref{ind:#1})% \fi% }% \usepackage{relsize} %Set the font size relative to the current font size
\usepackage[neveradjust]{paralist}% \usepackage{titlesec} \usepackage{etoolbox} %what does it do, why is it here? \usepackage[dotinlabels]{titletoc}
\usepackage{tcolorbox}% \tcbuselibrary{%Begin load libraries for tcolorbox
skins,% raster,% breakable,% xparse,% }%End load libraries for tcolorbox

\usepackage[hypertexnames=false, hyperfootnotes=false]{hyperref} % changed <<<<<<<<<<<<<<< \usepackage{cleveref}% should be the last package

\input{EXAMPLE_def} % EXAMPLE tcolorboxes

\input{PROCEDURE_def} % PROCEDURE tcolorboxes needs patch to reset chapter number

\input{DEMO_def} % DEMO tcolorboxes needs patch to reset chapter number

%================================================ End PREAMBLE \begin{document}

\input{TestingText}

\end{document}

This the file EXAMPLE_def.tex

%%%%%% file EXAMPLE_def starts G2-3 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

%============== Begin definition of EXAMPLE \newcounter{XPL}% \newcounter{XPLm}% just in case \newtcolorbox% [%beginForReferences use counter= XPL, number within=chapter,% crefname={\textsc{example}}{\textsc{examples}},% Crefname={\textsc{Example}}{\textsc{Examples}},% ]%endForReferences {EXAMPLE}%NameEnvironment [2][]%WhateverThatIs {%beginDescription detach title, before upper={\tcbtitle\quad}, left=-1mm,right=-1mm, breakable, enhanced,% %grow to left by=5mm, fontupper=\sffamily, colback=white, colframe=cyan, fonttitle=\sffamily, fonttitle=\bfseries, coltitle=black,% top=0pt, bottom=0pt, title={E\smaller{XAMPLE} \larger{\theXPL}.\notblank{#2}{\hspace{2mm} #2}{}},% #1,% }%end Description %============== End definition of EXAMPLE

%============== Begin definition of EXAMPLEcont \newtcolorbox% [%beginForReferences use counter= XPL, number within=chapter,% crefname={\textsc{example}}{\textsc{examples}},% Crefname={\textsc{Example}}{\textsc{Examples}},% ]%endForReferences {EXAMPLEcont}%NameEnvironment [2][]%WhateverThatIs {%beginDescription detach title,before upper={\tcbtitle\quad}, before title= \addtocounter{XPL}{-1}\addtocounter{XPLm}{1}, % count med in case if needed left=-1mm,right=-1mm, breakable, enhanced,% %grow to left by=5mm, fontupper=\sffamily, colback=white, colframe=yellow, fonttitle=\sffamily, fonttitle=\bfseries, coltitle=black,% top=0pt, bottom=0pt, title={E\smaller{XAMPLE} \larger{\theXPL}.\notblank{#2}{\hspace{2mm}(Continued) #2}{}},% #1,% }%end Description %============== End definition of EXAMPLEcont

%%%%%% file EXAMPLE_def ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

This is the file file PROCEDURE_def.tex (updated on request)

    %%%%%% file PROCEDURE_def starts G4 1 needs patch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

\newcounter{PROC}%[chapter] % \renewcommand{\thePROC}{\number\numexpr\value{PROC}+1\relax}% Display PROC+1 \newcounter{PROCm}% \newcounter{PROCstore}% \newcounter{subPROCm}% a b c . \newcounter{subPROCpass}%% on off

%============== Begin definition of PROCEDURE \newtcolorbox[% auto counter, number freestyle={\noexpand\thechapter.\noexpand\arabic{PROC}}, number within=chapter,% list inside= PROC,%creates the list under tcblistof. crefname={\textsc{procedure}}{\textsc{procedures}},% Crefname={\textsc{Procedure}}{\textsc{Procedures}}%
] {PROCEDURE}[2][]{% code=%
\setcounter{PROC}{\value{PROCstore}}%
\setcounter{subPROCpass}{0}%
\addtocounter{PROC}{1} , after title=%
\setcounter{PROCstore}{\value{PROC}}, enhanced, breakable, detach title, attach title to upper=~,% lower separated=true, bicolor,% % boxrule=1mm,% colframe=DarkBlue,%controls both the background color for the top and the frame of the bottom colback=DarkBlue,%This is the background color below the title. colbacklower=LightBlue,%This is the background color below the title. top=0pt, bottom=0pt, boxsep=5pt,% Sets a common padding between text and frame of box. Added to left, right, top, bottom, and middle. outer arc=2mm,%when line is thick. Else, can just use arc. fontupper=\sffamily, fontlower=\sffamily, coltitle=black,% nameref={#2},% list entry={\textbf{P\smaller{ROCEDURE}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% title={\textbf{P\smaller{ROCEDURE}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% #1% } %=========== End definition of PROCEDURE

%============== Begin definition of PROCEDUREsub
\newtcolorbox[% %use counter= PROC, auto counter, number within=chapter, number freestyle={\noexpand\thechapter.\noexpand\arabic{PROCm}\noexpand\alph{subPROCm}},% list inside= PROC,%creates the list under tcblistof. crefname={\textsc{procedure}}{\textsc{procedures}},% Crefname={\textsc{Procedure}}{\textsc{Procedures}},%
] {PROCEDUREsub}[2][]{% code=% \setcounter{PROCm}{\value{PROCstore}}%
\addtocounter{PROCm}{1}% \addtocounter{subPROCm}{1}, after title=% \addtocounter{\tcbcounter}{1} , enhanced, breakable, detach title, attach title to upper=~,% lower separated=true, bicolor,% % boxrule=1mm,% colframe=DarkBlue,%controls both the background color for the top and the frame of the bottom colback=DarkBlue,%This is the background color below the title. colbacklower=LightBlue,%This is the background color below the title. top=0pt, bottom=0pt, boxsep=5pt,% Sets a common padding between text and frame of box. Added to left, right, top, bottom, and middle. outer arc=2mm,%when line is thick. Else, can just use arc. fontupper=\sffamily, fontlower=\sffamily, coltitle=black,% nameref={#2},% list entry= {\textbf{P\smaller{ROCEDURE}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% title= {\textbf{P\smaller{ROCEDURE}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% #1% }
%=========== End definition of PROCEDURE sub

%============== Begin definition of PROCEDUREend \newtcolorbox[% %%use counter= PROCm, auto counter, number within=chapter, number freestyle={\noexpand\thechapter.\noexpand\arabic{PROCm}\noexpand\alph{subPROCm}},% list inside= PROC,%creates the list under tcblistof. crefname={\textsc{procedure}}{\textsc{procedures}},% Crefname={\textsc{Procedure}}{\textsc{Procedures}},%
] {PROCEDUREend}[2][]{% code=% \setcounter{PROCm}{\value{PROCstore}}%
\addtocounter{PROCm}{1}% \addtocounter{subPROCm}{1}% \setcounter{subPROCpass}{1} , after title=% \setcounter{PROCstore}{\value{PROCm}}% \setcounter{subPROCm}{0}, enhanced, breakable, detach title, attach title to upper=~,% lower separated=true, bicolor,% % boxrule=1mm,% colframe=DarkBlue,%controls both the background color for the top and the frame of the bottom colback=DarkBlue,%This is the background color below the title. colbacklower=LightBlue,%This is the background color below the title. top=0pt, bottom=0pt, boxsep=5pt,% Sets a common padding between text and frame of box. Added to left, right, top, bottom, and middle. outer arc=2mm,%when line is thick. Else, can just use arc. fontupper=\sffamily, fontlower=\sffamily, coltitle=black,% nameref={#2},% list entry={\textbf{P\smaller{ROCEDURE}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% title={\textbf{P\smaller{ROCEDURE}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% #1% }
%=========== End definition of PROCEDUREend

%%%%%% file PROCEDURE_def ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

This the file DEMO_def

%%%%%% file DEMO_def starts G4 1 needs patch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

\newcounter{DMO}%[chapter] % \renewcommand{\theDMO}{\number\numexpr\value{DMO}+1\relax}% Display DMO+1 \newcounter{DMOm}% \newcounter{DMOstore}% \newcounter{subDMOm}% a b c \newcounter{subDMOpass}%% on off

%============== Begin definition of DEMO \newtcolorbox[% auto counter, number freestyle={\noexpand\thechapter.\noexpand\arabic{DMO}}, number within=chapter,% list inside= DMO,%creates the list under tcblistof. crefname={\textsc{demo}}{\textsc{demos}},% Crefname={\textsc{Demo}}{\textsc{Demos}}% ] {DEMO}[2][]{% code=%
\setcounter{DMO}{\value{DMOstore}}% \setcounter{subDMOpass}{0}%
\addtocounter{DMO}{1}, after title=%
\setcounter{DMOstore}{\value{DMO}}, enhanced, breakable, detach title, attach title to upper=~,% lower separated=true, bicolor,% % boxrule=1mm,% colframe=DarkBlue,%controls both the background color for the top and the frame of the bottom colback=DarkBlue,%This is the background color below the title. colbacklower=LightBlue,%This is the background color below the title. top=0pt, bottom=0pt, boxsep=5pt,% Sets a common padding between text and frame of box. Added to left, right, top, bottom, and middle. outer arc=2mm,%when line is thick. Else, can just use arc. fontupper=\sffamily, fontlower=\sffamily, coltitle=black,% nameref={#2},% list entry={\textbf{D\smaller{EMO}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% title={\textbf{D\smaller{EMO}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% #1% } %=========== End definition of DEMO

%============== Begin definition of DEMO sub
\newtcolorbox[% %use counter= DMO, auto counter, number within=chapter, number freestyle={\noexpand\thechapter.\noexpand\arabic{DMOm}\noexpand\alph{subDMOm}},% list inside= DMO,%creates the list under tcblistof. crefname={\textsc{demo}}{\textsc{demos}},% Crefname={\textsc{Demo}}{\textsc{Demos}}% ] {DEMOsub}[2][]{% code=% \setcounter{DMOm}{\value{DMOstore}}%
\addtocounter{DMOm}{1}% \addtocounter{subDMOm}{1}, enhanced, breakable, detach title, attach title to upper=~,% lower separated=true, bicolor,% % boxrule=1mm,% colframe=DarkBlue,%controls both the background color for the top and the frame of the bottom colback=DarkBlue,%This is the background color below the title. colbacklower=LightBlue,%This is the background color below the title. top=0pt, bottom=0pt, boxsep=5pt,% Sets a common padding between text and frame of box. Added to left, right, top, bottom, and middle. outer arc=2mm,%when line is thick. Else, can just use arc. fontupper=\sffamily, fontlower=\sffamily, coltitle=black,% nameref={#2},% list entry={\textbf{D\smaller{EMO}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% title={\textbf{D\smaller{EMO}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% #1% } %=========== End definition of DEMO sub

%============== Begin definition of DEMO end \newtcolorbox[% %%use counter= DMOm, auto counter, number within=chapter, number freestyle={\noexpand\thechapter.\noexpand\arabic{DMOm}\noexpand\alph{subDMOm}},% list inside= DMO,%creates the list under tcblistof. crefname={\textsc{demo}}{\textsc{demos}},% Crefname={\textsc{Demo}}{\textsc{Demos}}%
] {DEMOend}[2][]{% code=% \setcounter{DMOm}{\value{DMOstore}}%
\addtocounter{DMOm}{1}% \addtocounter{subDMOm}{1}% \setcounter{subDMOpass}{1}, after title=% \setcounter{DMOstore}{\value{DMOm}}% \setcounter{subDMOm}{0}%
\setcounter{DMOm}{0}, enhanced, breakable, detach title, attach title to upper=~,% lower separated=true, bicolor,% % boxrule=1mm,% colframe=DarkBlue,%controls both the background color for the top and the frame of the bottom colback=DarkBlue,%This is the background color below the title. colbacklower=LightBlue,%This is the background color below the title. top=0pt, bottom=0pt, boxsep=5pt,% Sets a common padding between text and frame of box. Added to left, right, top, bottom, and middle. outer arc=2mm,%when line is thick. Else, can just use arc. fontupper=\sffamily, fontlower=\sffamily, coltitle=black,% nameref={#2},% list entry={\textbf{D\smaller{EMO}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% title={\textbf{D\smaller{EMO}}\hspace{1.5mm}\textbf{\thetcbcounter}\hspace{2mm} #2},% #1% }
%=========== End definition of DEMOend

%%%%%% file DEMO_def ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Simon Dispa
  • 39,141
  • In my preamble, I replaced my definition of EXAMPLE by your definition of EXAMPLE, EXAMPLEcont and EXAMPLEend in ref2 and it compiles. But there is something wrong with the references. 2. To trace, I changed colback=white to cyan in your EXAMPLE, to yellow in your EXAMPLEcont, and to green in your EXAMPLEend. (This showed that you forgot to use EXAMPLEend for the last EXAMPLE 1.2) The problem is that Cref{XPL:1-3} refers to the first EXAMPLE (Continued).
  • – schremmer May 09 '21 at 18:52
  • @schremmer Please see my updated answer. – Simon Dispa May 09 '21 at 23:02
  • Will look it up tomorrow. Thanks – schremmer May 09 '21 at 23:44