
入力するのは面倒です
\begin{theorem}
...
\end{theorem}
\begin{proof}
...
\end{proof}
授業中にライブテキストで文書を送信するとき。
私が宣言するとき
\newcommmand{\theorem}[2]{\begin{theorem} {#1} \begin{proof} {#2} \end{proof} \end{theorem}}
\theorem
それはすでに定義されていると理解しています。
もし私が試したら
\renewcommmand{\theorem}[2]{\begin{theorem} {#1} \begin{proof} {#2} \end{proof} \end{theorem}}
致命的なエラーが発生します。
「始まり」、「終わり」、「証明」という単語を何度も入力しなくて済む方法はありますか? これは、授業中にリアルタイムでテキストでメモを送ったりするときに重要です。
答え1
あなたもできる
\newcommand{\thmpr}[2]{%
\begin{theorem}#1\end{theorem}%
\begin{proof}#2\end{proof}%
}
しかし、これはもっと悪いことだと警告しておきます。互いに非常に離れてしまう可能性のある中括弧を追跡する必要があります。
授業のノートを取っている場合は、タグ付けする方がはるかに簡単です。
THEOREM\\
Whatever the guy at the blackboard is saying
PROOF\\
Something even more mysterious that I'll go through later
そうすることで、資料を修正するときに必要なものを簡単に配置してタグを付けること\begin
ができます。\end
問題は、内部目的のためにマクロ\newtheorem{theorem}{Theorem}
を定義していることです。そのため、LaTeXは;を拒否しますが、\theorem
\newcommand{\theorem}[2]{...}
\renewcommand{\theorem}[2]{\begin{theorem}...}
\theorem
それ自体について定義しているため、無限ループが発生します。
答え2
定義の問題は、 が\begin{theorem}
暗黙的に を呼び出すことです\theorem
。そのため、最初の試行では「すでに定義されています」エラーが発生します。(最終的には、環境は実際にはそのマクロです。) 2 回目の試行では、再定義したいマクロ内でマクロを呼び出します。そのため、無限ループに陥ります。次のよう\theorem
にして のバージョンを保存してみてください。
\let\oldtheorem\theorem
そして、2 回目の試みは基本的にうまくいくはずです。
\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}
また、proof
環境は通常 内にネストされずtheorem
、引数をグループ化する必要もありません (つまり、 ' {#1}
' は不要です)。