Re: 新規equation環境の作成

名前: .
日時: 2005-04-25 20:59:29
IPアドレス: 210.230.18.*

>>35580 とりあえず,2 点ほど問題があるようです. まず,ご質問にある定義では Equation 環境を \fbox{% $ \begin{equation} <Equation 環境の中身> \end{equation} $} とするように意図しているのではないかと思われますが, equation 環境は数式内で用いることはできません. ここでは, \fbox{% \begin{minipage}{\linewidth} \begin{equation} <Equation 環境の中身> \end{equation} \end{minipage}} と処理されるようにするとよいでしょう. # 丁寧には,minipage 環境の幅を \linewidth にするのではなく, # \linewidth から \fbox の枠と中身の間隔および罫線の太さを # 差し引いた値にするところですが,これは本質的なことではありません. 次に,括弧の対応に注意してください. マクロの引数には“括弧の対応がとれた”トークン列が用いられます. したがって,マクロの引数に単独の開き括弧・閉じ括弧を 含めることはできません. # ``The TeXbook'' の Appendix D にあるような,“展開時には単独の # 括弧として扱われる記述”はありますが,そのようなものも # 非展開時には“括弧の対応を崩さない”記述となっています. ご質問にある定義では,\fbox から最後の $} までの \fbox{$% \begin{equation}% }{% \end{equation}% $} の部分が \newenvironment の第 2 引数(今の例では \begin{Equation} で 行われる処理)になっています. # \newenvironment の第 3 引数(今の例では \end{Equation} で行われる処理)は # 欠けていますが,\newenvironment の記述全体の後に空白行があれば # その空白行に由来する \par が \newenvironment の第 3 引数になる, # ということになります.そうでなければ,Equation 環境の定義の直後の # 記述の一部が \newenvironment の第 3 引数となり,不可解なエラーが # 生じることでしょう. あとは,17488 以降の一連の話が参考になることでしょう. とりあえず,サンプルを挙げます. \documentclass[fleqn]{jarticle} \makeatletter \@ifl@aded{clo}{fleqn} {\let\@Equation@adjust\relax} {\let\@Equation@adjust\noindent} \newbox\@Equationbox \newenvironment{Equation} {\if@noskipsec \leavevmode \fi \ifhmode \par \fi \setbox\@Equationbox\hbox\bgroup \dimen0=\linewidth \advance\dimen0 by -2\fboxsep \advance\dimen0 by -2\fboxrule \begin{minipage}{\dimen0}% \@Equation@adjust \begin{equation}} { \end{equation}% \end{minipage}% \egroup% \box\@Equationbox の終端 \noindent\fbox{\box\@Equationbox}% \par \vskip\belowdisplayskip \@endpetrue} \makeatother \begin{document} サンプルです.サンプルです.サンプルです.サンプルです.サンプルです. \begin{Equation} x^2 + 1 = (x + \sqrt{-1}\,) (x - \sqrt{-1}\,) \end{Equation} サンプルです.サンプルです.サンプルです.サンプルです.サンプルです. \begin{equation} x^2 + 1 = (x + \sqrt{-1}\,) (x - \sqrt{-1}\,) \end{equation} \begin{enumerate} \item サンプルです.サンプルです.サンプルです.サンプルです. \begin{Equation} x^2 + 1 = (x + \sqrt{-1}\,) (x - \sqrt{-1}\,) \end{Equation} サンプルです.サンプルです.サンプルです.サンプルです. \item サンプルです.サンプルです.サンプルです.サンプルです. \begin{equation} x^2 + 1 = (x + \sqrt{-1}\,) (x - \sqrt{-1}\,) \end{equation} \end{enumerate} \end{document}

この書き込みへの返事:

お名前
題名 
メッセージ(タグは <a href="...">...</a> だけ使えます)