0

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
{bold}% theorem head font
{:}% punctuation after theorem head
{.5em}% space after theorem head
{}% theorem head spec

%Get rid of the default period after Defn
\makeatletter
    \xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
\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:enter image description here

1

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
  {\bfseries}% name of head font
  {:}% 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}

PDF sample

Please note that:

  • You should use a theorem style only after having defined it.
  • Theorems, definitions, etc. already have the optional argument that you are asking for.
  • 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
  • @LeoSimon I've commented the code a little more, hoping that you find it useful. – zetaeffe Feb 12 at 18:19

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.