¿Cómo puedo crear un entorno personalizado?

¿Cómo puedo crear un entorno personalizado?

Me gustaría escribir algunos teoremas como este:

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

Debe tener un aspecto como este:

**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, Claimy Proofdebe estar en negrita)

Lógica detrás del medio ambiente:

  • los teoremas deberían obtener automáticamente un número que comience en uno y cuente en uno para cada teorema
  • Dentro del entorno del teorema, solo se permiten los entornos preconditions, claimyproof
  • Dentro del entorno del teorema, se requiere que el entorno claimy proofsea exactamente una vez.
  • el contenido de la prueba y el contenido de las condiciones previas deben tener la misma intención.

Lo que he encontrado hasta ahora:

Pensé\nuevo ambientepodría ser lo que estoy buscando:

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

pero no pude descubrir cómo marcar los entornos internos según sea necesario.


El paquete amsthm parece tener entornos de prueba (fuente), pero no veo la posibilidad de anidar los diferentes entornos y hacer que se vean como quiero que se vean.


teoremaparece ofrecer muchas posibilidades. He creado 4 nuevos entornos de teoremas:

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

Utilicé el código de látex de arriba y obtuve esto: ingrese la descripción de la imagen aquí

Éste no tiene intención de los ambientes internos, los ambientes internos están numerados aunque no deberían estar numerados y nolápida sepulcralesta al final

Respuesta1

utilicé elthmtoolspaquete como interfaz para amsthmdefinir un nuevo Proofentorno; los otros dos entornos se crearon usando \newenvironment. Los entornos Proof, claimy preconditionse utilizan adjustwidthdesde elchangepagepaquete para aumentar el margen izquierdo. Por supuesto, siéntete libre de hacer los ajustes necesarios según tus necesidades:

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

ingrese la descripción de la imagen aquí

información relacionada