カスタマイズされた環境を作成するにはどうすればよいですか?

カスタマイズされた環境を作成するにはどうすればよいですか?

いくつかの定理を次のように書き留めたいと思います。

\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}

次のようになります:

**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くださいProof

環境の背後にあるロジック:

  • 定理は自動的に1から始まり、定理ごとに1ずつ増加する番号を取得する必要があります。
  • 定理環境内では、、および環境のみpreconditionsが許可されますclaimproof
  • 定理環境内では、claimおよびproof環境は正確に 1 回存在する必要があります。
  • 証明の内容と前提条件の内容は同じ意図を持つべきです。

これまでに発見したこと:

私は思った\新しい環境私が探しているものかもしれません:

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

しかし、内部環境を必須としてマークする方法がわかりませんでした。


amsthm パッケージには証明のための環境があるようです (ソース)、しかし、異なる環境をネストして、自分の望むように見せる可能性は見当たりません。


n定理多くの可能性を提供しているようです。私は 4 つの新しい定理環境を作成しました。

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

上記の LaTeX コードを使用して、次の結果を得ました。 ここに画像の説明を入力してください

これは内部環境の意図がなく、内部環境は番号が付けられているが、番号が付けられるべきではないし、墓石最後に

答え1

私はthmtoolsパッケージをフロントエンドとして使用してamsthm新しい環境を定義しますProof。他の2つの環境は を使用して作成されました\newenvironmentProofclaimおよびprecondition環境adjustwidthでは、changepageパッケージを使用して左余白を増やします。もちろん、必要に応じて自由に調整してください。

\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}
  {\par\medskip\adjustwidth{\Thmindent}{}\normalfont\textbf{Preconditions:}\par\nobreak}
  {\endadjustwidth}
\newenvironment{claim}
  {\par\medskip\adjustwidth{\Thmindent}{}\normalfont\textbf{Claim:}}
  {\endadjustwidth}

\declaretheoremstyle[
  spaceabove=0pt,spacebelow=0pt,
  preheadhook=\adjustwidth{\Thmindent}{},
  prefoothook=\endadjustwidth,
  headpunct=:,
  numbered=no,
  qed=\qedsymbol
]{proof}
\declaretheorem[style=proof]{Proof}

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

\begin{document}

\begin{theorem}
\lipsum[2]
\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[2]
\end{Proof}
\end{theorem}

\end{document}

ここに画像の説明を入力してください

関連情報