[Tex/LaTex] Which usepackage for theorem and lemma

environmentstheorems

the proof environment works, but the theorem environment doesn't.
I don't know why this doesn't work:

enter image description here

When I put the red box in comment, it all works without any problem, but not sure why, as I can use the order \begin{theorem}...\end{theorem}

The code is:

\documentclass[11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{mathtools}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{parskip}

\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{url}
\usepackage{here}
\usepackage{lmodern}
\usepackage{fancyvrb}

\usepackage[plainpages=false]{hyperref}
\usepackage{longtable}

\oddsidemargin=0.in
\topmargin=-1.5cm
\textheight=23cm
\textwidth=16cm

\renewcommand{\theequation}{\thesubsection.\arabic{equation}}
\renewcommand{\thefigure}{\thesubsection.\arabic{equation}}

\setlength{\parindent}{0cm}

\newcommand{\boxing}[1]{
\begin{center}
\framebox[\linewidth][c]{\parbox{15.5cm}{{#1}}}
\end{center}}

\begin{document}
\newpage
\begin{proof}
Test 1
\end{proof}

\begin{theorem}
Test 2
\end{theorem}
\end{document}

Best Answer

Mostly theorems are not defined by default. As some prefer writing thm as the environment name, others prefer theorem as the environment name.

You can use

\newtheorem{theorem}{Theorem}[section]

To create a new theorem environment, in this case its number will be dominated by the section number. (Note that this construction also create a new counter called theorem)

Often we'd like to have other theorem like constructions sharing the same counter, thus so we get Theorem 1.1, Lemma 1.2 etc.

This can be done using a slightly different syntax

\newtheorem{lemma}[theorem]{Lemma}

where we here pass the name of the already made counter, thus we do not make a new counter, we'll just use the one we have.

For further details, see the manual for the amsthm package.


BTW: LaTeX provides \newtheorem out of the box, not packages needed. The amsthm package just extends it in a convenient way. See also the thmtools package for an alternative syntax for making theorem like constructions.