1

The "shorttitle", that is the text within the last { } in the code, appears both in the tcbox and in the tcblist.

But the "short title" often has to be too short to be really understandable so I also have, under the "short title but before the \tcblower, a "long title".

But then the "short title" is unnecessary in the tcbox

So, what I would like is for the "short title" not to show in the tcbox and to show only in the tcblist.

Here is a MWE:

% !TEX TS-program = pdflatexmk
\documentclass[11pt]{book}
%+++++Begin PREAMBLE%+++++Begin PREAMBLE%+++++Begin PREAMBLE%+++++Begin PREAMBLE
%+++++Begin PREAMBLE%+++++Begin PREAMBLE%+++++Begin PREAMBLE%+++++Begin PREAMBLE
\usepackage{relsize}        %Set the font size relative to the current font size    
\usepackage{titlesec} 
\usepackage{etoolbox} %what does it do, why is it here?
\usepackage[dotinlabels]{titletoc}
\usepackage{tcolorbox}% 
\usepackage[hypertexnames=false, hyperfootnotes=false]{hyperref}%[pdfborder={0 0 0}] %added hypertextnames=false as per Simon Dispa See https://tex.stackexchange.com/questions/3188/what-does-the-hyperref-option-hypertexnames-do
%=======Begin tcolorbox ---The PACKAGE must be here. The tcolorboxes must be defined after cleveref.
    \tcbuselibrary{%Begin load libraries for tcolorbox  
        skins,%
        raster,%
        breakable,%
            }%End load libraries for tcolorbox      
\usepackage{xpatch}
%%% added according to SimonDipsa<<<<<<<<<<<<Modified according to NoteFromSimon
\xpretocmd{\chapter}{% reset counters & add some space in list
  \setcounter{PRCstore}{0}%
  \setcounter{DMOstore}{0}%
  \setcounter{DMOm}{0}%
  \setcounter{subDMOm}{0}%
  \setcounter{PRCm}{0}%
  \setcounter{subPRCm}{0}%
  \addtocontents{PRC}{\protect\addvspace{10pt}}%
  \addtocontents{DMO}{\protect\addvspace{10pt}}}%
{}{}%% <<<<<<<<<<<<<<<<<<<<<<<<<<<  
\usepackage{cleveref}% should be the last package
\newcounter{PRC}%[chapter] %   \renewcommand{\thePRC}{\number\numexpr\value{PRC}+1\relax}% Display PRC+1
\newcounter{PRCm}%
\newcounter{PRCstore}%
\newcounter{subPRCm}% a b c .
\newcounter{subPRCpass}%% on off
\newcounter{DMO}%[chapter] %  }% Display DMO+1
\newcounter{DMOm}%
\newcounter{DMOstore}%
\newcounter{subDMOm}% a b c 
\newcounter{subDMOpass}%% on off
%============== Begin definition of PROCEDURE
\newtcolorbox[%
auto counter, 
number freestyle={\noexpand\thechapter.\noexpand\arabic{PRC}},
number within=chapter,%
list inside= PRC,%creates the list under tcblistof.
crefname={\textsc{procedure}}{\textsc{procedures}},%
Crefname={\textsc{Procedure}}{\textsc{Procedures}}%  
]%endForReferences
{%begin name environment
PROCEDURE%
}%end name Environment
[2][]{%Whatever that is
    code=%  
    \setcounter{PRC}{\value{PRCstore}}%   
    \setcounter{subPRCpass}{0}%     
    \addtocounter{PRC}{1}   ,
    after title=%   
    \setcounter{PRCstore}{\value{PRC}}, 
    enhanced,
    breakable,
    detach title,
    attach title to upper=~,%
    lower separated=true,
    bicolor,%
    %   boxrule=1mm,%
    colframe=black,%controls both the background color for the top and the frame of the bottom
    colback=cyan,%This is the background color below the title.
    colbacklower=yellow,%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= PRC,
auto counter, 
number within=chapter, 
number freestyle={\noexpand\thechapter.\noexpand\arabic{PRCm}\noexpand\alph{subPRCm}},%
list inside= PRC,%creates the list under tcblistof.
crefname={\textsc{procedure}}{\textsc{procedures}},%
Crefname={\textsc{Procedure}}{\textsc{Procedures}},%    
]
{PROCEDUREsub}[2][]{%
    code=%
    \setcounter{PRCm}{\value{PRCstore}}%   
    \addtocounter{PRCm}{1}% 
    \addtocounter{subPRCm}{1},
    after title=%
    \addtocounter{\tcbcounter}{1} , 
    enhanced,
    breakable,
    detach title,
    attach title to upper=~,%
    lower separated=true,
    bicolor,%
%   boxrule=1mm,%
    colframe=black,%controls both the background color for the top and the frame of the bottom
    colback=cyan,%This is the background color below the title.
    colbacklower=yellow,%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 PROCEDUREsub
%=============== Begin definition of PROCEDUREend
\newtcolorbox[%
%%use counter= PRCm,
auto counter, 
number within=chapter, 
number freestyle={\noexpand\thechapter.\noexpand\arabic{PRCm}\noexpand\alph{subPRCm}},%
list inside= PRC,%creates the list under tcblistof.
crefname={\textsc{procedure}}{\textsc{procedures}},%
Crefname={\textsc{Procedure}}{\textsc{Procedures}},%    
]
{PROCEDUREend}[2][]{%
    code=%
    \setcounter{PRCm}{\value{PRCstore}}%   
    \addtocounter{PRCm}{1}% 
    \addtocounter{subPRCm}{1}% 
    \setcounter{subPRCpass}{1}  ,
    after title=%
    \setcounter{PRCstore}{\value{PRCm}}% 
        \setcounter{subPRCm}{0}, 
    enhanced,
    breakable,
    detach title,
    attach title to upper=~,%
    lower separated=true,
    bicolor,%
    %   boxrule=1mm,%
    colframe=black,%controls both the background color for the top and the frame of the bottom
    colback=cyan,%This is the background color below the title.
    colbacklower=yellow,%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
%+++++End PREAMBLE+++++End PREAMBLE+++++End PREAMBLE+++++End PREAMBLE
%+++++End PREAMBLE+++++End PREAMBLE+++++End PREAMBLE+++++End PREAMBLE

\begin{document} %========================================== Begin PROCEDURE \begin{PROCEDURE}[label={PRC:1-1}]{Short Title 1}

Long Title 1

\tcblower

Text of PROCEDURE 1.

\end{PROCEDURE} %========================================== End PROCEDURE %========================================== Begin PROCEDURErsub \begin{PROCEDUREsub}[label={PRC:1-1}]{Short Title 2a}

Long Title 2a

\tcblower

Text of PROCEDURE 2a

\end{PROCEDUREsub} %========================================== End PROCEDURErsub %========================================== Begin PROCEDUREend \begin{PROCEDUREend}[label={PRC:1-1}]{Short Title 2b}

Long Title 2b

\tcblower

Text of PROCEDURE 2b

\end{PROCEDUREend} %========================================== End PROCEDUREend

\tcblistof[\chapter]{PRC}{List of Procedures}%

\end{document}

and here is a picture

enter image description here

schremmer
  • 2,107

1 Answers1

1

You can remove #2 (the second argument, i.e., the short title) from the definition of title in the boxes. You can leave it in listentry in order to keep the short title in the list of boxes. So, for all three boxes change

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},%

into

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}},%

Full MWE, shortened a bit (with manual counter settings and article instead of book to keep the boxes and the list on one page):

\documentclass[11pt]{article}
\usepackage{relsize}        %Set the font size relative to the current font size    
\usepackage{tcolorbox}% 
\usepackage{hyperref}
\tcbuselibrary{%Begin load libraries for tcolorbox  
   skins,%
   raster,%
   breakable,%
}%End load libraries for tcolorbox 
\newcounter{PRC}
\newcounter{PRCm}
\newcounter{subPRCm}
\newtcolorbox[%
auto counter, 
number freestyle={\noexpand\thesection.\noexpand\arabic{PRC}},
number within=section,%
list inside= PRC,%creates the list under tcblistof.
]%endForReferences
{%begin name environment
PROCEDURE%
}%end name Environment
[2][]{%Whatever that is
    enhanced,
    breakable,
    detach title,
    attach title to upper=~,%
    lower separated=true,
    bicolor,%
    colframe=black,%controls both the background color for the top and the frame of the bottom
    colback=cyan,%This is the background color below the title.
    colbacklower=yellow,%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}},%
    #1%
}%
%============== End definition of PROCEDURE
%============== Begin definition of PROCEDUREsub   
\newtcolorbox[%
auto counter, 
number within=section, 
number freestyle={\noexpand\thesection.\noexpand\arabic{PRCm}\noexpand\alph{subPRCm}},%
list inside= PRC,%creates the list under tcblistof.
]
{PROCEDUREsub}[2][]{%
    enhanced,
    breakable,
    detach title,
    attach title to upper=~,%
    lower separated=true,
    bicolor,%
%   boxrule=1mm,%
    colframe=black,%controls both the background color for the top and the frame of the bottom
    colback=cyan,%This is the background color below the title.
    colbacklower=yellow,%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}},%
    #1%
}%
%================ End definition of PROCEDUREsub
%=============== Begin definition of PROCEDUREend
\newtcolorbox[%
auto counter, 
number within=section, 
number freestyle={\noexpand\thesection.\noexpand\arabic{PRCm}\noexpand\alph{subPRCm}},%
list inside= PRC,%creates the list under tcblistof.
]
{PROCEDUREend}[2][]{%
    enhanced,
    breakable,
    detach title,
    attach title to upper=~,%
    lower separated=true,
    bicolor,%
    %   boxrule=1mm,%
    colframe=black,%controls both the background color for the top and the frame of the bottom
    colback=cyan,%This is the background color below the title.
    colbacklower=yellow,%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}},%
    #1%
}%
%=========== End definition of PROCEDUREend

\begin{document} %========================================== Begin PROCEDURE \setcounter{PRC}{1} \setcounter{PRC}{1} \begin{PROCEDURE}[label={PRC:1-1}]{Short Title 1}

Long Title 1

\tcblower

Text of PROCEDURE 1.

\end{PROCEDURE} %========================================== End PROCEDURE %========================================== Begin PROCEDURErsub \setcounter{PRCm}{2} \setcounter{subPRCm}{1} \begin{PROCEDUREsub}[label={PRC:2-1}]{Short Title 2a}

Long Title 2a

\tcblower

Text of PROCEDURE 2a

\end{PROCEDUREsub} %========================================== End PROCEDURErsub %========================================== Begin PROCEDUREend \setcounter{subPRCm}{2} \begin{PROCEDUREend}[label={PRC:2-2}]{Short Title 2b}

Long Title 2b

\tcblower

Text of PROCEDURE 2b

\end{PROCEDUREend} %========================================== End PROCEDUREend

\tcblistof[\section]{PRC}{List of Procedures}% \end{document}

Result:

enter image description here

Marijn
  • 37,699
  • Looks exactly like what I want but I can't check it in the "Magnum Opus" right now. Also, I want to check if the "long title" can now start on the first line, to the right of PROCEDURE 0.x, that is where the "short title" used to be. No reason why not but I will let you know as soon as I can how everything goes. Thanks in any case. – schremmer Aug 22 '21 at 22:26