# amsthm: Punctuation only when there is a title

So I have the following style for theorems, lemmas, etc.

\newtheoremstyle{Fancyplain}
{\topsep}
{\topsep}
{\itshape}
{0pt}
{\bfseries}
{:}
{5pt plus 1pt minus 1pt}
{\thmname{#1} \thmnumber{#2}. \thmnote{\normalfont\bfseries#3}}


Essentially it looks like this:

Theorem 11. Theorem Title:

However, I don't want the colon to appear when the theorem has no title. Because it looks like this:

Theorem 12.:

Is there any way to do this? My current solution is to have no punctuation, and manually add the colon when I have a title.

• I had overlooked a little bug that caused improper spacing when the title is missing: please see the edited answer. – GuM Aug 11 '16 at 22:36

Why not simply move the colon inside the argument of \thmnote? Note: I have edited the code in order to correct a bug, that I had overlooked, concerning proper spacing when the title is missing.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath,amsthm}

\newtheoremstyle{Fancyplain}
{\topsep}
{\topsep}
{\itshape}
{0pt}
{\bfseries}
{}
{5pt plus 1pt minus 1pt}
{\thmname{#1} \thmnumber{#2}.\thmnote{\ #3:}}

\theoremstyle{Fancyplain}
\newtheorem{thm}{Thorem}

\begin{document}

Text text text.

\begin{thm}
Without a title.
\end{thm}

Text text text.

\begin{thm}[A title]
With a title.
\end{thm}

Text text text.

\end{document}


The picture showing the output has been changed accordingly: