
Es un dolor escribir
\begin{theorem}
...
\end{theorem}
\begin{proof}
...
\end{proof}
cuando envías un documento por mensaje de texto en vivo en clase.
cuando declaro
\newcommmand{\theorem}[2]{\begin{theorem} {#1} \begin{proof} {#2} \end{proof} \end{theorem}}
Entiendo que \theorem
ya está definido.
si lo intento
\renewcommmand{\theorem}[2]{\begin{theorem} {#1} \begin{proof} {#2} \end{proof} \end{theorem}}
Recibo un error fatal.
¿Hay alguna manera de evitar tener que escribir las palabras principio, fin y prueba varias veces? Esto es importante cuando estoy enviando notas de texto en vivo en clase.
Respuesta1
Puedes hacerlo con
\newcommand{\thmpr}[2]{%
\begin{theorem}#1\end{theorem}%
\begin{proof}#2\end{proof}%
}
pero te advierto que esto es mucho peor: hay que estar atento a los brackets que pueden acabar muy alejados unos de otros.
Si estás tomando apuntes de clase, es mucho más fácil etiquetar:
THEOREM\\
Whatever the guy at the blackboard is saying
PROOF\\
Something even more mysterious that I'll go through later
Luego es fácil colocar la etiqueta requerida \begin
cuando \end
revisa el material.
El problema es que \newtheorem{theorem}{Theorem}
sí define una \theorem
macro para sus fines internos. Entonces LaTeX se niega a hacerlo \newcommand{\theorem}[2]{...}
; pero con
\renewcommand{\theorem}[2]{\begin{theorem}...}
estás definiendo \theorem
en términos de sí mismo y esto provocará un bucle infinito.
Respuesta2
El problema en su definición es que \begin{theorem}
implícitamente llama \theorem
. Es por eso que en su primer intento obtiene un error "ya definido". (El entorno al final es en realidad solo esa macro). En el segundo intento, llama a su macro dentro de la que desea redefinir. Por lo tanto terminas en un bucle infinito. Intente almacenar una versión de \theorem
diciendo
\let\oldtheorem\theorem
y luego tu segundo intento básicamente debería funcionar:
\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\let\oldtheorem\theorem
\let\endoldtheorem\endtheorem
\renewcommand\theorem[2]{\begin{oldtheorem}#1\end{oldtheorem}\begin{proof}#2\end{proof}}
\begin{document}
\theorem{a theorem}{with proof}
\end{document}
También tenga en cuenta que el proof
entorno normalmente no queda anidado dentro de theorem
y la agrupación alrededor de los argumentos, es decir, ' {#1}
' es innecesario.