5

I am using the tcolorbox package (version 2.32, as provided by texlive 2013 on my gentoo linux system) to define a new theorem-like environment for typesetting tasks.

When the title is omitted, the theorem is displayed with a trailing colon in the title bar after the theorem name. See the example below.

\documentclass{standalone}

\usepackage[theorems]{tcolorbox}
\usepackage{lipsum}

\newcounter{task}
\tcbmaketheorem{task}{Task}{fonttitle=\bfseries}{task}{tk}

\begin{document}

\begin{task}[width=3in]{Important homework}{major}
  \lipsum[3]
\end{task}

\begin{task}[width=3in]{}{minor}
  \lipsum[3]
\end{task}

\end{document}

tcbcolorbox theorem without a title

How can the trailing colon be suppressed from the title bar when no title is given to the theorem?

5
  • I cannot recreate this with version 2.51. Commented Oct 12, 2013 at 12:51
  • 3
    Neither can I; with the current version the colon is not printed if the title is empty. I suggest you to say \tcbmaketheorem{task}{\strut Task}{fonttitle=\bfseries}{task}{tk} so the title bar will have a predetermined height (you see that the heights are different in your example, due to the “p” with a descender in the left box).
    – egreg
    Commented Oct 12, 2013 at 13:36
  • 1
    The colon is automatically removed starting from version 2.40. Additionally, theorems can now be created with the more powerful new macro \newtcbtheorem with automatic numbering. For your example with egreg's addition, this would be \newtcbtheorem{task}{\strut Task}{fonttitle=\bfseries}{tk}. Numbering can be influenced by options, e.g. \newtcbtheorem[number within=section]{task}{\strut Task}{fonttitle=\bfseries}{tk} numbers within sections. More options are given in the documentation. Commented Oct 12, 2013 at 17:14
  • @ThomasF.Sturm: I would suggest to turn your comment into an answer.
    – Daniel
    Commented Oct 12, 2013 at 18:35
  • @Daniel: Done :-) Commented Oct 13, 2013 at 9:29

1 Answer 1

2

I follow the suggestion of Daniel and turn my comment into an answer. The simple answer (as already given by the other comments) is to update tcolorbox to the recent version 2.51; this solves the original problem. Additionally, my suggestion is to exchange \tcbmaketheorem by the more powerful macro \newtcbtheorem. With it, the MWE of the question gets a tick easier since no counter task has to be created by hand:

\documentclass{standalone}

\usepackage[theorems]{tcolorbox}% version 2.51 (2013/09/16)
\usepackage{lipsum}

\newtcbtheorem{task}{\strut Task}{fonttitle=\bfseries}{tk}

\begin{document}

\begin{task}[width=3in]{Important homework}{major}
  \lipsum[3]
\end{task}

\begin{task}[width=3in]{}{minor}
  \lipsum[3]
\end{task}

\end{document}

enter image description here

Another advantage of \newtcbtheorem is that you can easily add chapter or section numbers. Of course, you could achieve this also by altering the number output with the known LaTeX mechanisms, but now it is again a tick easier as the following example shows using number within=section:

\documentclass[a4paper]{article}

\usepackage[theorems]{tcolorbox}% version 2.51 (2013/09/16)
\usepackage{lipsum,amssymb}

\newtcbtheorem[number within=section]{task}{\strut Task}{fonttitle=\bfseries,colframe=red!50!black}{tk}

\begin{document}
\section{Just a Test}

\begin{task}{Important homework}{major}
  \lipsum[2]
\end{task}

\begin{task}{}{minor}
  \lipsum[2]
\end{task}

\begin{task}[separator sign dash]{Another separator}{some}
  \lipsum[2]
\end{task}

\begin{task}[separator sign={\ $\blacktriangleright$}]{Yet another separator}{other}
  \lipsum[2]
\end{task}

\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 .