# How can I create a customized environment?

I would like to write some theorems down like this:

\begin{theorem}
\begin{preconditions}
$A := \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$\\
$B := \begin{pmatrix} 2 & 2 \\ 3 & 4 \end{pmatrix}$\\
$n \in \mathbb{N}$
\end{preconditions}

\begin{claim}
$\sqrt{2} \notin \mathbb{Q}$
\end{claim}

\begin{proof}{directly}
[... the proof ...]
\end{proof}

\end{theorem}


It should look like this:

**Theorem 123**
**Preconditions**:
$A := \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$\\
$B := \begin{pmatrix} 2 & 2 \\ 3 & 4 \end{pmatrix}$\\
$n \in \mathbb{N}$

**Claim**: √2 ∉ Q

**Proof**: directly

[... the proof ...]
[.. the end]                 ■


(Theorem 123, Preconditions, Claim and Proof should be bold)

Logic behind the environment:

• the theorems should automatically get a number that starts by one and counts up by one for each theorem
• inside of the theorem environment, only the preconditions, claim and proof environments are allowed
• inside of the theorem environment, the claim and proof environment are required to be exactly once.
• the content of proof and the content of preconditions should have the same intendation.

What I've found so far:

I thought \newenvironment might be what I am searching for:

\newenvironment{name}[num]{before}{after}


but I could not figure out how to mark internal environments as required.

The amsthm package seem to have environments for proof (source), but I can't see a possibility to nest the different environments and make them look like I want them to look

ntheorem seems to offer a lot of possibilities. I have created 4 new theorem environments:

\newtheorem{theorem}{Theorem}
\newtheorem{preconditions}{Preconditions}
\newtheorem{proof}{Proof}
\newtheorem{claim}{Claim}


I have used the latex code from above and got this: This one has no intendation of the inner environments, the inner environments are numbered although they shouldn't be numbered and no tombstone is at the end

I used the thmtools package as a front-end for amsthm in order to define a new Proof environment; the other two environments were created using \newenvironment. The Proof, claim and precondition environments use adjustwidth from the changepage package to increase the left margin. Of course, feel free to make the necessary adjustments according to your needs:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{changepage}
\usepackage[nopar]{lipsum}% just to generate some text

\newlength\Thmindent
\setlength\Thmindent{20pt}

\newenvironment{precondition}
\newenvironment{claim}

\declaretheoremstyle[
spaceabove=0pt,spacebelow=0pt,
numbered=no,
qed=\qedsymbol
]{proof}
\declaretheorem[style=proof]{Proof}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
\lipsum
\begin{precondition}
\begin{itemize}
\item $A := \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$
\item $B := \begin{pmatrix} 2 & 2 \\ 3 & 4 \end{pmatrix}$
\item $n \in \mathbb{N}$
\end{itemize}
\end{precondition}
\begin{claim}
$\sqrt{2}\notin\mathbb{Q}$
\end{claim}
\begin{Proof}
\lipsum
\end{Proof}
\end{theorem}

\end{document} 