1

I am trying to figure out how to ALWAYS add the default separator to my custom tcbtheorem.

As the title suggests, I use the tcolorbox package and define the environment with the newtcbtheorem. The separator (standard :) is only shown when there is a title given.

I didn't get far with the documentation on this one.

1
  • 4
    Please show us an example of small complete document with code which you try so far.
    – Zarko
    May 17, 2020 at 14:19

1 Answer 1

3

In the following example, a new tcolorbox boolean option force separator sign is provided.

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\usepackage{xpatch}

\makeatletter
% new tcolorbox boolean option "force seperator sign"
\newif\iftcb@thm@separatorsign
\tcbset{
  force seperator sign/.is if=tcb@thm@separatorsign,
  force seperator sign/.default=true
}

\xpatchcmd\tcb@theo@title
  {\unhbox\z@\kvtcb@terminatorsign}
  {\mbox{\unhbox\z@\iftcb@thm@separatorsign\kvtcb@separatorsign\fi}%
   \kvtcb@terminatorsign
  }
  {}{\fail}
\makeatother

% thm env always shows "separator sign"
\newtcbtheorem{thm}{Theorem}{
  separator sign=., 
  colframe=blue!50!black,
  force seperator sign
}{thm}

% cor env hides "seperator sign" if thm-title is empty
\newtcbtheorem{cor}{Corollary}{}{cor}

\begin{document}
\begin{thm}{}{}
  ``separator sign" is forced to be typeset in ``thm" env.
\end{thm}

\begin{thm}{Name}{}
  ``separator sign" is forced to be typeset in ``thm" env.
\end{thm}

\begin{cor}{}{}
  content
\end{cor}

\begin{cor}{Name}{}
  content
\end{cor}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .