# Creating a custom definition environment, with an optional argument and non default punctuation

This seems like it should be the most basic question, but I can't find a comprehensible answer on the site, I'm afraid. I'm trying to define a definition environment that 1) replaces the default period by a colon 2) allows for an optional argument with a parenthetical statement of the term being defined. I've constructed code that does this, but it's really hideously kludgy. Would somebody mind telling me how to do the same thing in an elegant and robust way? Thanks for any suggestions.

Here's my awful code:

\documentclass{amsart}
\usepackage{amsthm}
\usepackage{xpatch}
\theoremstyle{myStyle}
\newtheoremstyle{myStyle}% name
{3pt}% space above
{3pt}% space below
{italic}% body font
{}% indent amount

%Get rid of the default period after Defn
\makeatletter
\makeatother

\newtheorem{definition}{Defn}
\newenvironment{myDefn}[3]
{
\label{defn:#1}
\begin{definition}{{\bf{(#2):}}}
{#3}
\end{definition}}
{}

\newtheorem{definitionAlt}{Defn}
\newenvironment{myDefnAlt}[2]
{
\setcounter{definitionAlt}{\thedefinition}
\label{defn:#1}
\begin{definitionAlt}{{\hspace*{-0.1in} \bf :}}
{#2}
\end{definitionAlt}}
{\setcounter{definition}{\thedefinitionAlt}}
\begin{document}
\begin{myDefn}
{myLabel}
{Dog}
{A dog is something that you take for a walk}
\end{myDefn}
\begin{myDefnAlt}
{myLabelAlt}
{A dog is something that you take for a walk}
\end{myDefnAlt}
\begin{myDefn}
{myLabel}
{Dog}
{A dog is something that you take for a walk}
\end{myDefn}
\begin{myDefnAlt}
{myLabelAlt}
{A dog is something that you take for a walk}
\end{myDefnAlt}
\end{document}


And here's what it produces:

As you can find here: New Theorem Style:

\documentclass{article}
\usepackage{amsthm}

\newtheoremstyle{definition}% name of the style to be used
{\topsep}% measure of space to leave above the theorem.
{\topsep}% measure of space to leave below the theorem.
{\itshape}% name of font to use in the body of the theorem
{0pt}% measure of space to indent
{:}% punctuation between head and body
{ }% space after theorem head; " " = normal interword space
{\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}} % defines the theorem heading, where:
% #1 is the name of the given theorem
% #2 is its number
% #3 is the optional argument
% \thmname, \thmnumber and \thmnote print their arguments
%    in the style previously specified (e.g. in boldface...)

\theoremstyle{definition}
\newtheorem{definition}{Defn}

\begin{document}

\begin{definition}[Dog]
\label{A}
A dog is something that you take for a walk
\end{definition}

\begin{definition}
\label{B}
A dog is something that you take for a walk
\end{definition}

\begin{definition}[Dog]
\label{C}
A dog is something that you take for a walk
\end{definition}

\begin{definition}
\label{D}
A dog is something that you take for a walk
\end{definition}

\end{document}


• Would you mind adding to your answer something that illustrates \thmname, \thmnumber, \thmnote? These commands are mentioned in online documents about \newtheoremstyle but I have not been able to find an example. – Leo Simon Feb 12 at 17:56