2

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
2

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:

Output of the amended code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.