你能帮我用这段代码创建一个环境吗:
\smallskip\centering\framebox[0.9\textwidth]{
\begin{minipage}[c]{0.8\textwidth}
\begin{eqnarray}
I & = & -\mu\frac{W}{L}\int_{V_{S}}^{V_{D}} Q_{m} \cdot \ud{}V_{ch} \\
v_{g} - \Delta\phi_{i} - v_{ch} + \ln(\frac{q_{int}}{2}) & = & 4 q_{g} + \ln(q_{g}) + \ln\left( 1 + q_{g}\frac{C_{ox}}{C_{Si}} \right) \\
i & \approx & -q_{mD}^2 + q_{mD} - (-q_{mS}^2 + q_{mS})
\end{eqnarray}
\[\mathrm{where:} \quad v_{x} = \frac{V_{x}}{U_{T}},\ q_{int} = \frac{e n_{i} t_{Si}}{4 C_{ox} U_{T}},\ q_{x} = \frac{Q_{x}}{4 C_{ox} U_{T}},\ C_{Si} = \frac{\varepsilon_{Si}} {t_{Si}}\]
\medskip
\end{minipage}}
我想到的是:
\newenvironment{\MyMathBox}
{\smallskip\centering\framebox[0.9\textwidth]{
\begin{minipage}[c]{0.8\textwidth}}
{\medskip
\end{minipage}}}
该eqnarray
块必须可以在环境内部实现。
答案1
请始终发布定义所有使用命令的完整文档(我为其编造了一些内容\ud
。
您需要lrbox
将内容保存到框寄存器中,然后您可以在其周围放置一个框架。正如评论所指出的那样,使用 ams 对齐通常比 eqnarray 更好。(尤其是因为它可以处理将标签移出大条目,如图所示,eqnarray 在这方面并不擅长。)
\documentclass{article}
\newenvironment{mymathbox}
{\par\smallskip\centering\begin{lrbox}{0}%
\begin{minipage}[c]{0.8\textwidth}}
{\end{minipage}\end{lrbox}%
\framebox[0.9\textwidth]{\usebox{0}}%
\par\medskip
\ignorespacesafterend}
\begin{document}
\def\ud{}
\begin{mymathbox}
\begin{eqnarray}
I & = & -\mu\frac{W}{L}\int_{V_{S}}^{V_{D}} Q_{m} \cdot \ud{}V_{ch} \\
v_{g} - \Delta\phi_{i} - v_{ch} + \ln(\frac{q_{int}}{2}) & = & 4 q_{g} + \ln(q_{g}) + \ln\left( 1 + q_{g}\frac{C_{ox}}{C_{Si}} \right) \\
i & \approx & -q_{mD}^2 + q_{mD} - (-q_{mS}^2 + q_{mS})
\end{eqnarray}
\end{mymathbox}
\end{document}
答案2
你见过解决方案吗TeXample 上的 TiKZ?
这是一个最小的工作示例:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\usepackage{amsmath,amssymb}
% Define box and box title style
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitle} =[fill=red, text=white]
\newcommand{\fancybox}[2][Title of the box]{%
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.50\textwidth}
#2
\end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {#1};
\node[fancytitle, rounded corners] at (box.east) {$\clubsuit$};
\end{tikzpicture}%
}
\begin{document}
\fancybox[MyTitle]{How is that?
I can put equations here as well
\begin{align}
E \Psi &= \hat H \Psi
\end{align}
}
\end{document}