0

To state a theorem, what we do usually :

\begin{theorem}

... (statement) ...

\end{theorem}

I want to change the macro so that I can use \theorem like \section:

\theorem

... (statement) ...

Is it possible do be done? We could have used definition/lemma/proposition in place of theorem (I use amsclass documentclass).

  • 3
    But how would you tell LaTeX where such theorem ends? – Phelype Oleinik Nov 16 '18 at 14:24
  • Good point. How about \theorem{... (statement) ...}? – Dragon Nov 16 '18 at 14:29
  • What I want is to minimize latexing effort. Any suggestion regarding this is very much welcome. – Dragon Nov 16 '18 at 14:32
  • Depending on the editor you are using the "minimization of effort" will be minimal. With the editor I use I save 5 keystrokes when using the second alternative, with the downside of not having the code syntax-highlighted. Believe me, it looks like you are "minimizing" effort, but this is generally not a good idea. – Phelype Oleinik Nov 16 '18 at 14:41
3

Define your theorem with a different name:

\newtheorem{theoremx}{Theorem}

then do

\newcommand{\theorem}[1]{\begin{theoremx}#1\end{theoremx}}

Now compare

\begin{theoremx}
This is the statement.
\end{theoremx}

with

\theorem{This is the statement.}

and decide whether this is worthy the effort.

If you decide to pursue this strategy (I definitely don't recommend it), you can do

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn

\NewDocumentCommand{\newargumenttheorem}{momo}
 {
  \NewDocumentCommand{#1}{om}
   {
    \IfValueTF{##1}
     {
      \begin{\cs_to_str:N #1-inner}[##1] ##2 \end{\cs_to_str:N #1-inner}
     }
     {
      \begin{\cs_to_str:N #1-inner} ##2 \end{\cs_to_str:N #1-inner}
     }
   }
  \IfValueTF{#2}
   {
    \newtheorem{\cs_to_str:N #1-inner}[#2-inner]{#3}
   }
   {
    \IfValueTF{#4}
     {
      \newtheorem{\cs_to_str:N #1-inner}{#3}[#4]
     }
     {
      \newtheorem{\cs_to_str:N #1-inner}{#3}
     }
   }
 }
\ExplSyntaxOff

\newargumenttheorem{\theorem}{Theorem}[section]
\newargumenttheorem{\lemma}[theorem]{Lemma}
\newargumenttheorem{\definition}{Definition}

\begin{document}

\section{Test}

\definition{This is a definition.}

\lemma{This is a lemma.}

\theorem[Important]{\label{important}This is a theorem.}

Theorem \ref{important} is very important.

\end{document}

enter image description here

1

The theorem environment, like many other LaTeX environments, already has a macro \theorem.

\documentclass{article}
\newtheorem{theorem}{Theorem}

\begin{document}
\section{Introduction}
Theorems can easily be defined

\theorem {
Let $f$ be a function whose derivative exists in every point, then $f$ 
is a continuous function.
}

\end{document}

Edit:

Another option which avoids the problem noted out by @PhelypeOleinik:

\documentclass{article}
\newtheorem{theorem}{Theorem}

\let\oldtheorem\theorem
\let\endoldtheorem\endtheorem
\renewcommand\theorem[1]{\begin{oldtheorem}#1\end{oldtheorem}}

\begin{document}
\section{Introduction}
Theorems can easily be defined

\theorem {
Let $f$ be a function whose derivative exists in every point, then $f$ 
is a continuous function.
} 

Let $f$ be a function whose derivative exists in every point, then $f$ 
is a continuous function

\end{document}

enter image description here

  • 2
    Try to add some text after the \theorem... – Phelype Oleinik Nov 16 '18 at 14:38
0

To answer to the version you stated in the comments you could simply do it like this:

\newcommand{\mytheorem}[1]{\begin{theorem}#1\end{theorem}}

That should do it. It's not tested though.

  • 1
    You could do something to deal with the optional argument of \begin{theorem}. – Phelype Oleinik Nov 16 '18 at 14:34

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.